class documentation

PROXY protocol version two header parser.

Version two of the PROXY protocol is a binary format.

Class Method parse Parse a bytestring as a full PROXY protocol header.
Method __init__ Undocumented
Method feed Consume a chunk of data and attempt to parse it.
Constant ADDRESSFORMATS Undocumented
Constant COMMANDS Undocumented
Constant PREFIX Undocumented
Constant VERSIONS Undocumented
Instance Variable buffer Undocumented
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.

Parse a bytestring as a full PROXY protocol header.

Parameters
line:bytesA bytestring that represents a valid HAProxy PROXY protocol version 2 header.
Returns
_info.ProxyInfoA _interfaces.IProxyInfo containing the parsed data.
Raises
InvalidProxyHeaderIf the bytestring does not represent a valid PROXY header.
def __init__(self): (source)

Undocumented

Consume a chunk of data and attempt to parse it.

Parameters
data:bytesA bytestring.
Returns
Union[Tuple[_info.ProxyInfo, bytes], Tuple[None, None]]A 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.
Raises
InvalidProxyHeaderIf the bytes fed to the parser create an invalid PROXY header.
ADDRESSFORMATS: dict[int, str] = (source)

Undocumented

Value
{17: '!4s4s2H',
 18: '!4s4s2H',
 33: '!16s16s2H',
 34: '!16s16s2H',
 49: '!108s108s',
 50: '!108s108s'}
COMMANDS = (source)

Undocumented

Value
{0: _LOCALCOMMAND, 1: _PROXYCOMMAND}

Undocumented

Value
b'''\r
\r
\x00\r
QUIT
'''
VERSIONS: list[int] = (source)

Undocumented

Value
[32]

Undocumented

@staticmethod
def _bytesToIPv4(bytestring: bytes) -> bytes: (source)

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

Parameters
bytestring:bytes4 octets representing an IPv4 address.
Returns
bytesa dotted-quad notation IPv4 address.
@staticmethod
def _bytesToIPv6(bytestring: bytes) -> bytes: (source)

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

Parameters
bytestring:bytes16 octets representing an IPv6 address.
Returns
bytesa dotted-quad notation IPv6 address.