proxyprotocol.result
¶
- proxyprotocol.result.is_local(result)[source]¶
Checks if the result is an unproxied local connection.
- Parameters:
result (ProxyResult) – The proxy protocol result.
- Return type:
- proxyprotocol.result.is_unknown(result)[source]¶
Checks if the result is a proxied connection from an unknown origin.
- Parameters:
result (ProxyResult) – The proxy protocol result.
- Return type:
- proxyprotocol.result.is_ipv4(result)[source]¶
Checks if the result is a proxied IPv4 connection.
- Parameters:
result (ProxyResult) – The proxy protocol result.
- Return type:
- proxyprotocol.result.is_ipv6(result)[source]¶
Checks if the result is a proxied IPv6 connection.
- Parameters:
result (ProxyResult) – The proxy protocol result.
- Return type:
- proxyprotocol.result.is_unix(result)[source]¶
Checks if the result is a proxied UNIX connection.
- Parameters:
result (ProxyResult) – The proxy protocol result.
- Return type:
- class proxyprotocol.result.ProxyResultType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
The type of proxy result.
- LOCAL = (1, 'AF_UNSPEC')¶
The connection is not proxied at all.
- UNKNOWN = (2, 'AF_UNSPEC')¶
The connection is proxied from an unknown address family.
- IPv4 = (3, 'AF_INET')¶
The connection is proxied from an IPv4 address.
- IPv6 = (4, 'AF_INET6')¶
The connection is proxied from an IPv6 address.
- UNIX = (5, 'AF_UNIX')¶
The connection is proxied from a UNIX socket.
- property family: AddressFamily¶
The address family corresponding to the proxy result type.
- Raises:
AttributeError – The address family does not exist on the current platform, e.g.
AF_UNIX
on Windows.
- class proxyprotocol.result.ProxyResult[source]¶
Base class for PROXY protocol results.
- abstract property type: ProxyResultType¶
The type of proxy result.
- abstract property proxied: bool¶
True if the result should override the information in the underlying socket.
- abstract property source: None | str | Tuple[IPv4Address, int] | Tuple[IPv6Address, int]¶
The original source address info for the connection.
- abstract property dest: None | str | Tuple[IPv4Address, int] | Tuple[IPv6Address, int]¶
The original destination address info for the connection.
- property family: AddressFamily¶
The original socket address family.
See also
- Raises:
AttributeError – An address family was proxied to a platform that does not support it. Use
type
instead when possible.
- abstract property tlv: ProxyProtocolTLV¶
Additional information about the connection.
- class proxyprotocol.result.ProxyResultLocal(*, tlv=ProxyProtocolTLV())[source]¶
Indicates that the connection should be treated as if it is not proxied. The real socket
getpeername()
andgetsockname()
will provide the correct address information.- Parameters:
tlv (ProxyProtocolTLV) – Additional information about the connection.
- property proxied: Literal[False]¶
True if the result should override the information in the underlying socket.
- property tlv: ProxyProtocolTLV¶
Additional information about the connection.
- class proxyprotocol.result.ProxyResultUnknown(exception=None, *, tlv=ProxyProtocolTLV())[source]¶
Indicates that the source of the connection is unknown.
- Parameters:
exception (Optional[Exception]) – The exception that occurred, if any.
tlv (ProxyProtocolTLV) – Additional information about the connection.
- property exception: Exception | None¶
An exception that occurred during reading or parsing the PROXY protocol header.
- property proxied: Literal[True]¶
True if the result should override the information in the underlying socket.
- property tlv: ProxyProtocolTLV¶
Additional information about the connection.
- class proxyprotocol.result.ProxyResultIPv4(source, dest, *, protocol=None, tlv=ProxyProtocolTLV())[source]¶
The original connection was made with an IPv4 socket. The
source
anddest
properties will contain a tuple of anIPv4Address
and a port number.- Parameters:
source (Tuple[IPv4Address, int]) – The source address of the connection.
dest (Tuple[IPv4Address, int]) – The destination address of the connection.
protocol (Optional[SocketKind]) – The socket protocol (or
type
).tlv (ProxyProtocolTLV) – Additional information about the connection.
- property proxied: Literal[True]¶
True if the result should override the information in the underlying socket.
- property source: Tuple[IPv4Address, int]¶
The original source address info for the connection.
- property dest: Tuple[IPv4Address, int]¶
The original destination address info for the connection.
- property tlv: ProxyProtocolTLV¶
Additional information about the connection.
- class proxyprotocol.result.ProxyResultIPv6(source, dest, *, protocol=None, tlv=ProxyProtocolTLV())[source]¶
The original connection was made with an IPv6 socket. The
source
anddest
properties will contain a tuple of anIPv6Address
and a port number.- Parameters:
source (Tuple[IPv6Address, int]) – The source address of the connection.
dest (Tuple[IPv6Address, int]) – The destination address of the connection.
protocol (Optional[SocketKind]) – The socket protocol (or
type
).tlv (ProxyProtocolTLV) – Additional information about the connection.
- property proxied: Literal[True]¶
True if the result should override the information in the underlying socket.
- property source: Tuple[IPv6Address, int]¶
The original source address info for the connection.
- property dest: Tuple[IPv6Address, int]¶
The original destination address info for the connection.
- property tlv: ProxyProtocolTLV¶
Additional information about the connection.
- class proxyprotocol.result.ProxyResultUnix(source, dest, *, protocol=None, tlv=ProxyProtocolTLV())[source]¶
The original connection was made with a UNIX socket. The
source
anddest
properties will contain a the full path to the socket file.- Parameters:
source (str) – The source address file of the connection.
dest (str) – The destination address file of the connection.
protocol (Optional[SocketKind]) – The socket protocol (or
type
).tlv (ProxyProtocolTLV) – Additional information about the connection.
- property proxied: Literal[True]¶
True if the result should override the information in the underlying socket.
- property tlv: ProxyProtocolTLV¶
Additional information about the connection.