CLI interface

Implementation of the aiodns-proxy Command

A datagram-based DNS-over-X proxy.

class aiodnsprox.cli.proxy.DTLSCredentialsAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

Argument parser Action class to parse PSK DTLS credentials into a dictionary.

class aiodnsprox.cli.proxy.HostPortAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: Action

Argument parser Action class to parse a (host, port) pair into a dictionary.

DEFAULT_HOST = 'localhost'
DEFAULT_PORTS = {'coap': None, 'dtls': 853, 'udp': 53}
class aiodnsprox.cli.proxy.UpstreamAction(option_strings, dest, nargs=None, const=None, default=None, type=None, choices=None, required=False, help=None, metavar=None)[source]

Bases: HostPortAction

Argument parser Action class to parse upstream parameters into a dictionary.

TRANSPORTS = {'tcp': DNSTransport.TCP, 'udp': DNSTransport.UDP, 'udp+tcp': DNSTransport.UDP_TCP_FALLBACK}
aiodnsprox.cli.proxy.build_argparser()[source]

Build argument parser for the proxy CLI command.

async aiodnsprox.cli.proxy.close_servers()[source]

Close all servers that got started by main().

aiodnsprox.cli.proxy.get_config(args, pre_config: Mapping | None = None)[source]

Get aiodnsprox.config.Config object from CLI arguments and configuration file as provided in the CLI arguments (CLI arguments take precedence over file configuration).

Parameters:

args (argparse.Namespace) – Parsed CLI arguments.

aiodnsprox.cli.proxy.get_factory(upstream, transport)[source]

Get server factory for transport.

Parameters:
  • upstream (aiodnsprox.dns_upstream.DNSUpstream) – The proxied DNS server.

  • transport (str) –

    One of the following strings:

    • "udp": Gets a DNS over UDP server factory.

    • "dtls": Gets a DNS over DTLS server factory.

    • "coap": Gets a DNS over CoAP server factory.

aiodnsprox.cli.proxy.loglevel(value)[source]

Type function to set the log level via command-line.

Parameters:

value – either a name for a log level or their numeric representation (as string).

Type:

str

Returns:

The (integer) log level.

async aiodnsprox.cli.proxy.main(config=None)[source]

Asynchronous entry point.

Parses CLI parameters and creates a config from it. Starts all serving DNS servers and sets up the upstream cliend towards the proxied DNS server.

aiodnsprox.cli.proxy.sync_main()[source]

Synchronous entry point.