feat(netxlite): implement DNSTransport wrapping (#776)
Acknowledge that transports MAY be used in isolation (i.e., outside of a Resolver) and add support for wrapping. Ensure that every factory that creates an unwrapped type is named accordingly to hopefully ensure there are no surprises. Implement DNSTransport wrapping and use a technique similar to the one used by Dialer to customize the DNSTransport while constructing more complex data types (e.g., a specific resolver). Ensure that the stdlib resolver's own "getaddrinfo" transport (1) is wrapped and (2) could be extended during construction. This work is part of my ongoing effort to bring to this repository websteps-illustrated changes relative to netxlite. Ref issue: https://github.com/ooni/probe/issues/2096
This commit is contained in:
parent
923d81cdee
commit
8f7e3803eb
20 changed files with 369 additions and 91 deletions
|
|
@ -31,25 +31,27 @@ type DNSOverTCPTransport struct {
|
|||
requiresPadding bool
|
||||
}
|
||||
|
||||
// NewDNSOverTCPTransport creates a new DNSOverTCPTransport.
|
||||
// NewUnwrappedDNSOverTCPTransport creates a new DNSOverTCPTransport
|
||||
// that has not been wrapped yet.
|
||||
//
|
||||
// Arguments:
|
||||
//
|
||||
// - dial is a function with the net.Dialer.DialContext's signature;
|
||||
//
|
||||
// - address is the endpoint address (e.g., 8.8.8.8:53).
|
||||
func NewDNSOverTCPTransport(dial DialContextFunc, address string) *DNSOverTCPTransport {
|
||||
func NewUnwrappedDNSOverTCPTransport(dial DialContextFunc, address string) *DNSOverTCPTransport {
|
||||
return newDNSOverTCPOrTLSTransport(dial, "tcp", address, false)
|
||||
}
|
||||
|
||||
// NewDNSOverTLSTransport creates a new DNSOverTLS transport.
|
||||
// NewUnwrappedDNSOverTLSTransport creates a new DNSOverTLS transport
|
||||
// that has not been wrapped yet.
|
||||
//
|
||||
// Arguments:
|
||||
//
|
||||
// - dial is a function with the net.Dialer.DialContext's signature;
|
||||
//
|
||||
// - address is the endpoint address (e.g., 8.8.8.8:853).
|
||||
func NewDNSOverTLSTransport(dial DialContextFunc, address string) *DNSOverTCPTransport {
|
||||
func NewUnwrappedDNSOverTLSTransport(dial DialContextFunc, address string) *DNSOverTCPTransport {
|
||||
return newDNSOverTCPOrTLSTransport(dial, "dot", address, true)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue