Package org.microproxy.dns
Interface DnsTransport
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
Sends a DNS query message to a recursive resolver and returns the raw response. The resolver
only needs to pass DNSSEC records through; all validation happens locally.
-
Method Summary
Modifier and TypeMethodDescriptionbyte[]exchange(byte[] query) Sends a wire-format DNS query and reads its response.static DnsTransportfailover(List<DnsTransport> transports) Each oftransportsin turn: a query that fails with anIOException(a resolver that cannot be reached, times out or answers with an HTTP error) is sent to the next, and only when every one has failed does the query fail, with the last failure and the earlier ones suppressed in it.static DnsTransportDNS over HTTPS (RFC 8484) to a resolver such ashttps://cloudflare-dns.com/dns-queryorhttps://dns.google/dns-query.static List<InetSocketAddress> Thenameservers of/etc/resolv.conf, or Google and Cloudflare public resolvers when that file is unavailable.static DnsTransportudp(List<InetSocketAddress> servers, Duration timeout) UDP to each server in turn, retrying over TCP when a response is truncated.
-
Method Details
-
exchange
Sends a wire-format DNS query and reads its response.- Parameters:
query- the wire-format DNS query message- Returns:
- the wire-format DNS response
- Throws:
IOException- if the query fails or no DNS response can be read
-
udp
UDP to each server in turn, retrying over TCP when a response is truncated.- Parameters:
servers- the recursive DNS server addressestimeout- the per-attempt UDP/TCP query timeout- Returns:
- the UDP transport with TCP fallback
-
https
DNS over HTTPS (RFC 8484) to a resolver such ashttps://cloudflare-dns.com/dns-queryorhttps://dns.google/dns-query. The connection uses the JVM's default proxy settings.- Parameters:
endpoint- the DNS-over-HTTPS endpointtimeout- the HTTP connection and query timeout- Returns:
- the DNS-over-HTTPS transport
-
failover
Each oftransportsin turn: a query that fails with anIOException(a resolver that cannot be reached, times out or answers with an HTTP error) is sent to the next, and only when every one has failed does the query fail, with the last failure and the earlier ones suppressed in it. Each query starts at the transport that answered last, so a resolver that is down costs its timeout once rather than on every query; one that answers again is used again once the others fail. Responses are validated locally either way, so mixing resolvers within a lookup is safe.- Parameters:
transports- the transports to try, in order; at least one- Returns:
- the failover transport
-
systemServers
Thenameservers of/etc/resolv.conf, or Google and Cloudflare public resolvers when that file is unavailable.- Returns:
- the
nameservers of/etc/resolv.conf, or Google and Cloudflare public resolvers when that file is unavailable
-