class documentation

class twisted.protocols.haproxy._v2parser.V2Parser: (source)

View In Hierarchy

PROXY protocol version two header parser.

Version two of the PROXY protocol is a binary format.

Class Variable PREFIX Undocumented
Class Variable VERSIONS Undocumented
Class Variable COMMANDS Undocumented
Class Variable ADDRESSFORMATS Undocumented
Method __init__ Undocumented
Instance Variable buffer 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.
PREFIX = (source)

Undocumented

(type: bytes)
VERSIONS = (source)

Undocumented

(type: list[int])
COMMANDS = (source)

Undocumented

ADDRESSFORMATS = (source)

Undocumented

(type: dict[int, str])
def __init__(self): (source)

Undocumented

buffer = (source)

Undocumented

(type: bytes)
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 20.12.1 at 2021-02-28 19:53:36.