proxyprotocol.sock
¶
- class proxyprotocol.sock.SocketInfo(transport)[source]¶
Provides information about the connection, from either the underlying
asyncio
transport layer or overridden by the PROXY protocol result.- Parameters:
transport (TransportProtocol)
- classmethod get(transport, result, *, unique_id=b'', dnsbl=None)[source]¶
Choose the
SocketInfo
implementation based on whether the result indicates the connection isproxied
.- Parameters:
transport (TransportProtocol) – The
BaseTransport
orStreamWriter
for the connection.result (ProxyResult | None) – The PROXY protocol result.
unique_id (bytes) – A unique ID to associate with the connection, unless overridden by the PROXY protocol result.
dnsbl (str | None) – The DNSBL lookup result, if any.
- Return type:
- abstract property sockname: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The local address of the socket.
See also
- property sockname_ip: None | IPv4Address | IPv6Address¶
The IP address object from
sockname
, forAF_INET
orAF_INET6
connections.
- property sockname_port: int | None¶
The port number from
sockname
, forAF_INET
orAF_INET6
connections.
- property sockname_str: str | None¶
The
sockname
address as a string. ForAF_INET
/AF_INET6
families, this isip:port
.
- abstract property peername: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The remote address of the socket.
See also
- property peername_ip: None | IPv4Address | IPv6Address¶
The IP address object from
peername
, forAF_INET
orAF_INET6
connections.
- property peername_port: int | None¶
The port number from
peername
, forAF_INET
orAF_INET6
connections.
- property peername_str: str | None¶
The
peername
address as a string. ForAF_INET
/AF_INET6
families, this isip:port
.
- abstract property family: AddressFamily¶
The socket address family.
See also
- abstract property compression: str | None¶
The
compression()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.
- abstract property cipher: Tuple[str, str, int | None] | None¶
The
cipher()
value for encrypted connections.Note
For proxied connections, this data may be unavailable or partially available, depending on the server implementation and PROXY protocol version.
- abstract property peercert: Mapping[str, Any] | None¶
The
getpeercert()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.
- abstract property unique_id: bytes¶
A unique identifier for the connection. For proxied connections, the unique ID from the header (if any) is returned, otherwise returns the value passed in to the constructor.
- abstract property dnsbl: str | None¶
The DNSBL lookup result of the connecting IP address, if any.
This value is contextual to the DNSBL in use, but generally any value here other than
None
indicates the IP address should be blocked.
- property from_localhost: bool¶
True for local socket connections, if:
peername_ip
has Trueis_loopback
flag.
To be specific, True for
AF_UNIX
connections and True for IPv4/IPv6 connections with Trueis_loopback
flags.
- class proxyprotocol.sock.SocketInfoProxy(transport, result)[source]¶
Provides information about the connection, overridden by the PROXY protocol result.
- Parameters:
transport (TransportProtocol) – The
BaseTransport
orStreamWriter
for the connection.result (ProxyResult) – The PROXY protocol result.
- property sockname: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The local address of the socket.
See also
- property peername: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The remote address of the socket.
See also
- property family: AddressFamily¶
The socket address family.
See also
- property compression: str | None¶
The
compression()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.
- property cipher: Tuple[str, str, int | None] | None¶
The
cipher()
value for encrypted connections.Note
For proxied connections, this data may be unavailable or partially available, depending on the server implementation and PROXY protocol version.
- property peercert: Mapping[str, Any] | None¶
The
getpeercert()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.
- class proxyprotocol.sock.SocketInfoLocal(transport, *, unique_id=b'', dnsbl=None)[source]¶
Provides information about the connection, from the underlying
asyncio
transport layer.- Parameters:
transport (TransportProtocol) – The
BaseTransport
orStreamWriter
for the connection.unique_id (bytes) – A unique ID to associate with the connection, unless overridden by the PROXY protocol result.
dnsbl (Optional[str]) – The DNSBL lookup result, if any.
- property sockname: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The local address of the socket.
See also
- property peername: None | str | Tuple[str, int] | Tuple[str, int, int, int]¶
The remote address of the socket.
See also
- property family: AddressFamily¶
The socket address family.
See also
- property compression: str | None¶
The
compression()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.
- property cipher: Tuple[str, str, int | None] | None¶
The
cipher()
value for encrypted connections.Note
For proxied connections, this data may be unavailable or partially available, depending on the server implementation and PROXY protocol version.
- property peercert: Mapping[str, Any] | None¶
The
getpeercert()
value for encrypted connections.Note
For proxied connections, this data may be unavailable, depending on the server implementation and PROXY protocol version.