class documentation
class V1Parser: (source)
Implements interfaces: twisted.protocols.haproxy._interfaces.IProxyParser
PROXY protocol version one header parser.
Version one of the PROXY protocol is a human readable format represented by a single, newline delimited binary string that contains all of the relevant source and destination data.
Class Method | parse |
Parse a bytestring as a full PROXY protocol header line. |
Method | __init__ |
Undocumented |
Method | feed |
Consume a chunk of data and attempt to parse it. |
Constant | ALLOWED |
Undocumented |
Constant | NEWLINE |
Undocumented |
Constant | PROXYSTR |
Undocumented |
Constant | TCP4 |
Undocumented |
Constant | TCP6 |
Undocumented |
Constant | UNKNOWN |
Undocumented |
Instance Variable | buffer |
Undocumented |
Parse a bytestring as a full PROXY protocol header line.
Parameters | |
line:bytes | A bytestring that represents a valid HAProxy PROXY protocol header line. |
Returns | |
_info.ProxyInfo | A _interfaces.IProxyInfo containing the parsed data. |
Raises | |
InvalidProxyHeader | If the bytestring does not represent a valid PROXY header. |
InvalidNetworkProtocol | When no protocol can be parsed or is not one of the allowed values. |
MissingAddressData | When the protocol is TCP* but the header does not contain a complete set of addresses and ports. |
Consume a chunk of data and attempt to parse it.
Parameters | |
data:bytes | A bytestring. |
Returns | |
Union[ | 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 | |
InvalidProxyHeader | If the bytes fed to the parser create an invalid PROXY header. |