Expand description
A DNS-over-HTTPS server.
DoH serves RFC 8484 queries over HTTP/1.1 and HTTP/2, and optionally
Oblivious DoH and a JSON API.
With the tls feature, it can also handle TLS and reload certificates.
The server takes care of connections and timeouts, and a Resolver answers
the queries.
Forwarder sends them to a DNS server.
Applications can write their own resolver, or wrap a Forwarder:
use std::net::SocketAddr;
use libdoh::{DnsResponse, DoH, DoHError, Forwarder, Globals, Query, Resolver};
struct LocalOnly(Forwarder);
impl Resolver for LocalOnly {
fn allow_connection(&self, remote_addr: SocketAddr) -> bool {
remote_addr.ip().is_loopback()
}
async fn resolve(&self, query: Query) -> Result<DnsResponse, DoHError> {
self.0.resolve(query).await
}
}
let forwarder = Forwarder::new("9.9.9.9:53".parse()?, 64);
let globals = Globals {
max_clients: 512,
..Globals::default()
};
let listener = tokio::net::TcpListener::bind("127.0.0.1:3000").await?;
DoH::new(globals, LocalOnly(forwarder)).serve(listener).await?;Modules§
Structs§
- Cache
Policy - The
Cache-Controlheader of a response. - DnsResponse
- A DNS response, and how long HTTP caches may keep it.
- DoH
- A DoH server that answers queries with a
Resolver. - Forwarder
- Forwards queries to a DNS server over UDP, and retries over TCP when the response is truncated.
- Globals
- Settings of a DoH server.
- Query
- A DNS query received over HTTP.
Enums§
- Cache
Scope - Whether shared HTTP caches may store a response.
- DoHError
- DoHType
- How a query reached the server.
Constants§
Traits§
- Resolver
- Answers the queries that a DoH server receives.