proxyprotocol.dnsbl

class proxyprotocol.dnsbl.Dnsbl[source]

Manages the optional lookup of the connecting IP address against a trusted DNSBL.

abstract async lookup(sock_info, *, loop=None)[source]

Looks up the connecting IP address and returns the DNSBL hostname and the lookup result. Any timeout or misconfiguration is treated as an empty result.

Parameters:
  • sock_info (SocketInfo) – The connection socket info.

  • loop (AbstractEventLoop | None)

Return type:

str | None

classmethod load(host, *, timeout=None)[source]

Given a DNSBL hostname, returns a Dnsbl implementation that best suits the given host.

Parameters:
  • host (str | None) – The DNSBL hostname, if any.

  • timeout (float | None) – The time to wait for a response, in seconds, or None for indefinite.

Raises:

ValueError – The host is invalid for this Dnsbl.

Return type:

Dnsbl

class proxyprotocol.dnsbl.NoopDnsbl[source]

Disables DNSBL lookup altogether, lookup() always returns None.

async lookup(sock_info, *, loop=None)[source]

Looks up the connecting IP address and returns the DNSBL hostname and the lookup result. Any timeout or misconfiguration is treated as an empty result.

Parameters:
  • sock_info (SocketInfo) – The connection socket info.

  • loop (AbstractEventLoop | None)

Return type:

str | None

class proxyprotocol.dnsbl.BasicDnsbl(host, timeout)[source]

A basic Dnsbl implementation that simply returns the DNSBL hostname if the DNS lookup returns any IP addresses.

Parameters:
map_results(addresses)[source]

Given a list of IP address results from a DNSBL lookup, return a single string categorizing the results or None to discard them.

Parameters:

addresses (Sequence[IPv4Address]) – The list of IP address results.

Return type:

str | None

async lookup(sock_info, *, loop=None)[source]

Looks up the connecting IP address and returns the DNSBL hostname and the lookup result. Any timeout or misconfiguration is treated as an empty result.

Parameters:
  • sock_info (SocketInfo) – The connection socket info.

  • loop (AbstractEventLoop | None)

Return type:

str | None

class proxyprotocol.dnsbl.SpamhausDnsbl(host, timeout)[source]

A Dnsbl designed for querying Spamhaus DNSBLs.

Parameters:
map_results(addresses)[source]

Given a list of IP address results from a DNSBL lookup, return a single string categorizing the results or None to discard them.

Parameters:

addresses (Sequence[IPv4Address]) – The list of IP address results.

Return type:

str | None