Skip to content
This repository was archived by the owner on Jul 3, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
`dnscore` is a Go library designed for performing DNS measurements. Its high-level
API, `*dnscore.Resolver`, is compatible with `*net.Resolver`. Its low-level API,
`*dnscore.Transport`, provides granular control over performing DNS queries using
specific protocols (including UDP, TCP, TLS, and HTTPS).
specific protocols (including UDP, TCP, TLS, HTTPS, and QUIC).

## Features

- High-level `*Resolver` API compatible with `*net.Resolver` for easy integration.
- Low-level `*Transport` API allowing granular control over DNS requests and responses.
- Support for multiple DNS protocols, including UDP, TCP, DoT, and DoH.
- Support for multiple DNS protocols, including UDP, TCP, DoT, DoH, and DoQ.
- Utilities for creating and validating DNS messages.
- Optional logging for structured diagnostic events through `log/slog`.
- Handling of duplicate responses for DNS over UDP to measure censorship.
Expand Down Expand Up @@ -52,11 +52,12 @@ The `*dnscore.Transport` API provides granular control over DNS queries and resp
See

- [example_https_test.go](example_https_test.go)
- [example_quic_test.go](example_quic_test.go)
- [example_tcp_test.go](example_tcp_test.go)
- [example_tls_test.go](example_tls_test.go)
- [example_udp_test.go](example_udp_test.go)

for complete examples using DNS over HTTPS, TCP, TLS, and UDP respectively.
for complete examples using DNS over HTTPS, QUIC, TCP, TLS, and UDP respectively.

See also [internal/cmd/transport/main.go](internal/cmd/transport/main.go) for
a simple command line tool that demonstrates how to use the `*dnscore.Transport` API
Expand Down
2 changes: 1 addition & 1 deletion doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ DNS messages.

- Low-level [*Transport] API allowing granular control over DNS requests and responses.

- Support for multiple DNS protocols, including UDP, TCP, DoT, and DoH.
- Support for multiple DNS protocols, including UDP, TCP, DoT, DoH, and DoQ.

- Utilities for creating and validating DNS messages.

Expand Down
8 changes: 6 additions & 2 deletions resolverconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ type AddServerOption func(*resolverConfigServer)
// ServerOptionQueryOptions sets the query options to use for constructing queries
// to this specific server.If this option is not used, we use the default query options
// suitable for the protocol used by the server. Specifically, we enable DNSSEC
// validation and block-length padding for DNS-over-HTTPS and DNS-over-TLS servers.
// validation and block-length padding for DoT, DoH, and DoQ.
func ServerOptionQueryOptions(queryOptions ...QueryOption) AddServerOption {
return func(s *resolverConfigServer) {
s.queryOptions = queryOptions
Expand Down Expand Up @@ -103,7 +103,7 @@ func newResolverConfigServer(address *ServerAddr, options ...AddServerOption) re

// apply the default query options suitable for the protocol used by the server
switch address.Protocol {
case ProtocolDoH, ProtocolDoT:
case ProtocolDoH, ProtocolDoT, ProtocolDoQ:
server.queryOptions = append(server.queryOptions, QueryOptionEDNS0(
EDNS0SuggestedMaxResponseSizeOtherwise,
EDNS0FlagDO|EDNS0FlagBlockLengthPadding))
Expand Down Expand Up @@ -143,6 +143,10 @@ func (c *ResolverConfig) servers() []resolverConfigServer {
if len(list) == 0 {
defaultAddrs := []string{"8.8.8.8", "8.8.4.4"}
for _, addr := range defaultAddrs {
// TODO(bassosimone): double check whether this is causing
// us to always use the max UDP response size also for
// encrypted transports. I think this may be the case just
// by reading the current code.
list = append(list, newResolverConfigServer(
NewServerAddr(ProtocolUDP, net.JoinHostPort(addr, "53")),
ServerOptionQueryOptions(QueryOptionEDNS0(
Expand Down
Loading