module documentation

Test cases for twisted.protocols.haproxy.V2Parser.

Class V2ParserTests Test twisted.protocols.haproxy.V2Parser behaviour.
Constant V2_SIGNATURE Undocumented
Function _makeHeaderIPv4 Construct a version 2 IPv4 header with custom bytes.
Function _makeHeaderIPv6 Construct a version 2 IPv6 header with custom bytes.
Function _makeHeaderUnix Construct a version 2 IPv4 header with custom bytes.
V2_SIGNATURE: bytes =

Undocumented

Value
b'''\r
\r
\x00\r
QUIT
'''
def _makeHeaderIPv4(sig: bytes = V2_SIGNATURE, verCom: bytes = b'!', famProto: bytes = b'\x11', addrLength: bytes = b'\x00\x0c', addrs: bytes = b'\x7f\x00\x00\x01\x7f\x00\x00\x01', ports: bytes = b'\x1f\x90"\xb8') -> bytes:

Construct a version 2 IPv4 header with custom bytes.

Parameters
sig:bytesThe protocol signature; defaults to valid V2_SIGNATURE.
verCom:bytesProtocol version and command. Defaults to V2 PROXY.
famProto:bytesAddress family and protocol. Defaults to AF_INET/STREAM.
addrLength:bytesNetwork-endian byte length of payload. Defaults to description of default addrs/ports.
addrs:bytesAddress payload. Defaults to 127.0.0.1 for source and destination.
ports:bytesSource and destination ports. Defaults to 8080 for source 8888 for destination.
Returns
bytesA packet with header, addresses, and ports.
def _makeHeaderIPv6(sig: bytes = V2_SIGNATURE, verCom: bytes = b'!', famProto: bytes = b'!', addrLength: bytes = b'\x00$', addrs: bytes = (b'\x00' * 15 + b'\x01') * 2, ports: bytes = b'\x1f\x90"\xb8') -> bytes:

Construct a version 2 IPv6 header with custom bytes.

Parameters
sig:bytesThe protocol signature; defaults to valid V2_SIGNATURE.
verCom:bytesProtocol version and command. Defaults to V2 PROXY.
famProto:bytesAddress family and protocol. Defaults to AF_INET6/STREAM.
addrLength:bytesNetwork-endian byte length of payload. Defaults to description of default addrs/ports.
addrs:bytesAddress payload. Defaults to ::1 for source and destination.
ports:bytesSource and destination ports. Defaults to 8080 for source 8888 for destination.
Returns
bytesA packet with header, addresses, and ports.
def _makeHeaderUnix(sig: bytes = V2_SIGNATURE, verCom: bytes = b'!', famProto: bytes = b'1', addrLength: bytes = b'\x00\xd8', addrs: bytes = (b'/home/tests/mysockets/sock' + b'\x00' * 82) * 2) -> bytes:

Construct a version 2 IPv4 header with custom bytes.

Parameters
sig:bytesThe protocol signature; defaults to valid V2_SIGNATURE.
verCom:bytesProtocol version and command. Defaults to V2 PROXY.
famProto:bytesAddress family and protocol. Defaults to AF_UNIX/STREAM.
addrLength:bytesNetwork-endian byte length of payload. Defaults to 108 bytes for 2 null terminated paths.
addrs:bytesAddress payload. Defaults to /home/tests/mysockets/sock for source and destination paths.
Returns
bytesA packet with header, addresses, and8 ports.