Implements interfaces: ._interfaces.IProxyParser

PROXY protocol version two header parser.

Version two of the PROXY protocol is a binary format.

Method __init__ Undocumented
Method feed Consume a chunk of data and attempt to parse it.
Class Method parse Parse a bytestring as a full PROXY protocol header.
Static Method _bytesToIPv4 Convert packed 32-bit IPv4 address bytes into a dotted-quad ASCII bytes representation of that address.
Static Method _bytesToIPv6 Convert packed 128-bit IPv6 address bytes into a colon-separated ASCII bytes representation of that address.
def __init__(self): (source)
Undocumented
def feed(self, data): (source)

Consume a chunk of data and attempt to parse it.

ParametersdataA bytestring. (type: bytes)
ReturnsA two-tuple containing, in order, a _interfaces.IProxyInfo and any bytes fed to the parser that followed the end of the header. Both of these values are None until a complete header is parsed.
RaisesInvalidProxyHeaderIf the bytes fed to the parser create an invalid PROXY header.
@staticmethod
def _bytesToIPv4(bytestring): (source)

Convert packed 32-bit IPv4 address bytes into a dotted-quad ASCII bytes representation of that address.

Parametersbytestring4 octets representing an IPv4 address. (type: bytes)
Returnsa dotted-quad notation IPv4 address. (type: bytes)
@staticmethod
def _bytesToIPv6(bytestring): (source)

Convert packed 128-bit IPv6 address bytes into a colon-separated ASCII bytes representation of that address.

Parametersbytestring16 octets representing an IPv6 address. (type: bytes)
Returnsa dotted-quad notation IPv6 address. (type: bytes)
@classmethod
def parse(cls, line): (source)

Parse a bytestring as a full PROXY protocol header.

ParameterslineA bytestring that represents a valid HAProxy PROXY protocol version 2 header. (type: bytes)
ReturnsA _interfaces.IProxyInfo containing the parsed data.
RaisesInvalidProxyHeaderIf the bytestring does not represent a valid PROXY header.
API Documentation for Twisted, generated by pydoctor at 2018-10-15 19:29:43.