adapter
ModuleAdapters: the transports a server listens on, on Tokio.
Contents
use utopia_dns::adapter::Bound;pub struct BoundThe transports of a Tokio adapter, bound.
use utopia_dns::adapter::Http;pub struct HttpDNS over HTTPS (RFC 8484): wire-format queries by GET (?dns= in
base64url) or POST (application/dns-message), on HTTP/1.1, or
HTTP/2 over TLS. Without a certificate it serves plain HTTP, behind a
TLS-terminating proxy.
use utopia_dns::adapter::Tcp;pub struct TcpTCP with 2-byte length prefixes (RFC 1035 §4.2.2, RFC 7766).
A connection is closed when it sends a zero-length or oversized frame,
when its unanswered bytes exceed max_buffer_size, after idle_timeout
without data, or when an answer exceeds 65535 bytes. Connections beyond
max_clients are closed at once. With proxy_protocol, every
connection must start with a PROXY protocol header, whose source
address is the client's.
use utopia_dns::adapter::Tokio;pub struct TokioThe Tokio adapter: any number of UDP, TCP and DNS-over-HTTPS transports in one runtime. UDP and TCP transports can share a port number; each HTTP transport needs its own.
Packets are handled concurrently; frames on one TCP connection are answered in order. Worker start callbacks run once, with id 0, after every transport is bound.
use utopia_dns::adapter::{Tcp, Tokio, Transport, Udp};
use utopia_dns::resolver::Memory;
use utopia_dns::{Server, Zone};
let adapter = Tokio::new(vec![
Transport::Udp(Udp::new("0.0.0.0", 5300)),
Transport::Tcp(Tcp::new("0.0.0.0", 5300)),
])?;
Server::new(Memory::new(zone)).start(adapter).await;Debug.use utopia_dns::adapter::Udp;pub struct UdpUDP (RFC 1035 §4.2.1): answers are cut to 512 bytes.
use utopia_dns::adapter::Transport;pub enum TransportA transport of the Tokio adapter.
use utopia_dns::adapter::Adapter;pub trait Adapter: Send + 'staticServes packets: listens on transports and hands every packet to a
Handler, sending back what it returns.
pub type WorkerStart = Box<dyn Fn(usize) + Send + Sync>A worker start callback: it gets the worker's id.
pub const CONTENT_TYPE: &str = "application/dns-message"The media type of DNS messages over HTTP.