slimta.util.proxyproto¶
Package providing support for the PROXY protocol on various edge services.
-
class
slimta.util.proxyproto.
ProxyProtocolV1
([*args[, **kwargs]])¶ Bases:
object
Implements version 1 of the proxy protocol, to avoid losing information about the original connection when routing traffic through a proxy. This process involves an extra line sent by the client at the beginning of every cconnection.
Mix-in before an implementation of
EdgeServer
to expect every connection to begin with a proxy protocol header. Theaddress
argument passed in to thehandle()
method will contain information about the original connection source, before proxying.-
classmethod
parse_pp_line
(cls, line)¶ Given a bytestring containing a single line ending in CRLF, parse into two source and destination address tuples of the form
(ip, port)
and return them.Parameters: line – Bytestring ending in CRLF Returns: Two tuples for source and destination addresses, as might be returned by getpeername()
andgetsockname()
.
-
classmethod
mixin
(cls, edge)¶ Dynamically mix-in the
ProxyProtocolV1
class as a base of the given edge object. Use with caution.Parameters: edge ( EdgeServer
) – the edge object to use proxy protocol on.Raises: ValueError
-
classmethod
-
class
slimta.util.proxyproto.
ProxyProtocolV2
([*args[, **kwargs]])¶ Bases:
object
Implements version 2 of the proxy protocol, to avoid losing information about the original connection when routing traffic through a proxy. This version is binary, and may be more efficient than version 1.
Mix-in before an implementation of
EdgeServer
to expect every connection to begin with a proxy protocol header. Theaddress
argument passed in to thehandle()
method will contain information about the original connection source, before proxying.-
classmethod
mixin
(cls, edge)¶ Dynamically mix-in the
ProxyProtocolV2
class as a base of the given edge object. Use with caution.Parameters: edge ( EdgeServer
) – the edge object to use proxy protocol on.Raises: ValueError
-
classmethod
-
class
slimta.util.proxyproto.
ProxyProtocol
([*args[, **kwargs]])¶ Bases:
object
Reads the first 8 bytes from the socket to determine which version of the proxy protocol is active before handing processing off to either
ProxyProtocolV1
orProxyProtocolV2
.Mix-in before an implementation of
EdgeServer
to expect every connection to begin with a proxy protocol header. Theaddress
argument passed in to thehandle()
method will contain information about the original connection source, before proxying.-
classmethod
mixin
(cls, edge)¶ Dynamically mix-in the
ProxyProtocol
class as a base of the given edge object. Use with caution.Parameters: edge ( EdgeServer
) – the edge object to use proxy protocol on.Raises: ValueError
-
classmethod