Documentation ¶
Index ¶
- Constants
- func IsBogon(address string) bool
- type AddressResolver
- type BogonResolver
- type CacheResolver
- type ChainResolver
- type DNSOverHTTPS
- type DNSOverTCP
- type DNSOverUDP
- type Decoder
- type DialContextFunc
- type Dialer
- type EmitterResolver
- type EmitterTransport
- type Encoder
- type ErrorWrapperResolver
- type IDNAResolver
- type Logger
- type LoggingResolver
- type MiekgDecoder
- type MiekgEncoder
- type Resolver
- type RoundTripper
- type SaverDNSTransport
- type SaverResolver
- type SerialResolver
- type SystemResolver
Constants ¶
const ( // PaddingDesiredBlockSize is the size that the padded query should be multiple of PaddingDesiredBlockSize = 128 // EDNS0MaxResponseSize is the maximum response size for EDNS0 EDNS0MaxResponseSize = 4096 // DNSSECEnabled turns on support for DNSSEC when using EDNS0 DNSSECEnabled = true )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AddressResolver ¶
type AddressResolver struct {
Resolver
}
AddressResolver is a resolver that knows how to correctly resolve IP addresses to themselves.
func (AddressResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
type BogonResolver ¶
type BogonResolver struct {
Resolver
}
BogonResolver is a bogon aware resolver. When a bogon is encountered in a reply, this resolver will return an error.
func (BogonResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
type CacheResolver ¶
CacheResolver is a resolver that caches successful replies.
func (*CacheResolver) Get ¶
func (r *CacheResolver) Get(domain string) []string
Get gets the currently configured entry for domain, or nil
func (*CacheResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
func (*CacheResolver) Set ¶
func (r *CacheResolver) Set(domain string, addresses []string)
Set allows to pre-populate the cache
type ChainResolver ¶
ChainResolver is a chain resolver. The primary resolver is used first and, if that fails, we then attempt with the secondary resolver.
func (ChainResolver) Address ¶
func (c ChainResolver) Address() string
Address implements Resolver.Address
func (ChainResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
func (ChainResolver) Network ¶
func (c ChainResolver) Network() string
Network implements Resolver.Network
type DNSOverHTTPS ¶
type DNSOverHTTPS struct { Do func(req *http.Request) (*http.Response, error) URL string HostOverride string }
DNSOverHTTPS is a DNS over HTTPS RoundTripper. Requests are submitted over an HTTP/HTTPS channel provided by URL using the Do function.
func NewDNSOverHTTPS ¶
func NewDNSOverHTTPS(client *http.Client, URL string) DNSOverHTTPS
NewDNSOverHTTPS creates a new DNSOverHTTP instance from the specified http.Client and URL, as a convenience.
func NewDNSOverHTTPSWithHostOverride ¶
func NewDNSOverHTTPSWithHostOverride(client *http.Client, URL, hostOverride string) DNSOverHTTPS
NewDNSOverHTTPSWithHostOverride is like NewDNSOverHTTPS except that it's creating a resolver where we use the specified host.
func (DNSOverHTTPS) Address ¶
func (t DNSOverHTTPS) Address() string
Address returns the upstream server address.
func (DNSOverHTTPS) Network ¶
func (t DNSOverHTTPS) Network() string
Network returns the transport network (e.g., doh, dot)
func (DNSOverHTTPS) RequiresPadding ¶
func (t DNSOverHTTPS) RequiresPadding() bool
RequiresPadding returns true for DoH according to RFC8467
type DNSOverTCP ¶
type DNSOverTCP struct {
// contains filtered or unexported fields
}
DNSOverTCP is a DNS over TCP/TLS RoundTripper. Use NewDNSOverTCP and NewDNSOverTLS to create specific instances that use plaintext queries or encrypted queries over TLS.
As a known bug, this implementation always creates a new connection for each incoming query, thus increasing the response delay.
func NewDNSOverTCP ¶
func NewDNSOverTCP(dial DialContextFunc, address string) DNSOverTCP
NewDNSOverTCP creates a new DNSOverTCP transport.
func NewDNSOverTLS ¶
func NewDNSOverTLS(dial DialContextFunc, address string) DNSOverTCP
NewDNSOverTLS creates a new DNSOverTLS transport.
func (DNSOverTCP) Address ¶
func (t DNSOverTCP) Address() string
Address returns the upstream server address.
func (DNSOverTCP) Network ¶
func (t DNSOverTCP) Network() string
Network returns the transport network (e.g., doh, dot)
func (DNSOverTCP) RequiresPadding ¶
func (t DNSOverTCP) RequiresPadding() bool
RequiresPadding returns true for DoT and false for TCP according to RFC8467.
type DNSOverUDP ¶
type DNSOverUDP struct {
// contains filtered or unexported fields
}
DNSOverUDP is a DNS over UDP RoundTripper.
func NewDNSOverUDP ¶
func NewDNSOverUDP(dialer Dialer, address string) DNSOverUDP
NewDNSOverUDP creates a DNSOverUDP instance.
func (DNSOverUDP) Address ¶
func (t DNSOverUDP) Address() string
Address returns the upstream server address.
func (DNSOverUDP) Network ¶
func (t DNSOverUDP) Network() string
Network returns the transport network (e.g., doh, dot)
func (DNSOverUDP) RequiresPadding ¶
func (t DNSOverUDP) RequiresPadding() bool
RequiresPadding returns false for UDP according to RFC8467
type Decoder ¶
The Decoder decodes a DNS reply into A or AAAA entries. It will use the provided qtype and only look for mathing entries. It will return error if there are no entries for the requested qtype inside the reply.
type DialContextFunc ¶
DialContextFunc is a generic function for dialing a connection.
type Dialer ¶
type Dialer interface {
DialContext(ctx context.Context, network, address string) (net.Conn, error)
}
Dialer is the network dialer interface assumed by this package.
type EmitterResolver ¶
type EmitterResolver struct {
Resolver
}
EmitterResolver is a resolver that emits events
func (EmitterResolver) LookupHost ¶
LookupHost returns the IP addresses of a host
type EmitterTransport ¶
type EmitterTransport struct {
RoundTripper
}
EmitterTransport is a RoundTripper that emits events when they occur.
type ErrorWrapperResolver ¶
type ErrorWrapperResolver struct {
Resolver
}
ErrorWrapperResolver is a Resolver that knows about wrapping errors.
func (ErrorWrapperResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
type IDNAResolver ¶
type IDNAResolver struct {
Resolver
}
IDNAResolver is to support resolving Internationalized Domain Names. See RFC3492 for more information.
func (IDNAResolver) Address ¶
func (r IDNAResolver) Address() string
Address implements Resolver.Address.
func (IDNAResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
func (IDNAResolver) Network ¶
func (r IDNAResolver) Network() string
Network implements Resolver.Network.
type LoggingResolver ¶
LoggingResolver is a resolver that emits events
func (LoggingResolver) LookupHost ¶
LookupHost returns the IP addresses of a host
type MiekgDecoder ¶
type MiekgDecoder struct{}
MiekgDecoder uses github.com/miekg/dns to implement the Decoder.
type MiekgEncoder ¶
type MiekgEncoder struct{}
MiekgEncoder uses github.com/miekg/dns to implement the Encoder.
type Resolver ¶
type Resolver interface { // LookupHost resolves a hostname to a list of IP addresses. LookupHost(ctx context.Context, hostname string) (addrs []string, err error) // Network returns the network being used by the resolver Network() string // Address returns the address being used by the resolver Address() string }
Resolver is a DNS resolver. The *net.Resolver used by Go implements this interface, but other implementations are possible.
type RoundTripper ¶
type RoundTripper interface { // RoundTrip sends a DNS query and receives the reply. RoundTrip(ctx context.Context, query []byte) (reply []byte, err error) // RequiresPadding return true for DoH and DoT according to RFC8467 RequiresPadding() bool // Network is the network of the round tripper (e.g. "dot") Network() string // Address is the address of the round tripper (e.g. "1.1.1.1:853") Address() string }
RoundTripper represents an abstract DNS transport.
type SaverDNSTransport ¶
type SaverDNSTransport struct { RoundTripper Saver *trace.Saver }
SaverDNSTransport is a DNS transport that saves events
type SaverResolver ¶
SaverResolver is a resolver that saves events
func (SaverResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost
type SerialResolver ¶
type SerialResolver struct { Encoder Encoder Decoder Decoder NumTimeouts *atomicx.Int64 Txp RoundTripper }
SerialResolver is a resolver that first issues an A query and then issues an AAAA query for the requested domain.
func NewSerialResolver ¶
func NewSerialResolver(t RoundTripper) SerialResolver
NewSerialResolver creates a new OONI Resolver instance.
func (SerialResolver) Address ¶
func (r SerialResolver) Address() string
Address implements Resolver.Address
func (SerialResolver) LookupHost ¶
LookupHost implements Resolver.LookupHost.
func (SerialResolver) Network ¶
func (r SerialResolver) Network() string
Network implements Resolver.Network
func (SerialResolver) Transport ¶
func (r SerialResolver) Transport() RoundTripper
Transport returns the transport being used.
type SystemResolver ¶
type SystemResolver = selfcensor.SystemResolver
SystemResolver is the system resolver. It is implemented using selfcensor.SystemResolver so that we can perform integration testing by forcing the code to return specific responses.