New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: net: customize dnsConfig #49096
Comments
Could you provide some detail about what you want to customize and how? A code example would be good. Thanks. |
net/lookup.go:119 add dnsConfig type Resolver struct {
// PreferGo controls whether Go's built-in DNS resolver is preferred
// on platforms where it's available. It is equivalent to setting
// GODEBUG=netdns=go, but scoped to just this resolver.
PreferGo bool
// StrictErrors controls the behavior of temporary errors
// (including timeout, socket errors, and SERVFAIL) when using
// Go's built-in resolver. For a query composed of multiple
// sub-queries (such as an A+AAAA address lookup, or walking the
// DNS search list), this option causes such errors to abort the
// whole query instead of returning a partial result. This is
// not enabled by default because it may affect compatibility
// with resolvers that process AAAA queries incorrectly.
StrictErrors bool
// Dial optionally specifies an alternate dialer for use by
// Go's built-in DNS resolver to make TCP and UDP connections
// to DNS services. The host in the address parameter will
// always be a literal IP address and not a host name, and the
// port in the address parameter will be a literal port number
// and not a service name.
// If the Conn returned is also a PacketConn, sent and received DNS
// messages must adhere to RFC 1035 section 4.2.1, "UDP usage".
// Otherwise, DNS messages transmitted over Conn must adhere
// to RFC 7766 section 5, "Transport Protocol Selection".
// If nil, the default dialer is used.
Dial func(ctx context.Context, network, address string) (Conn, error)
// lookupGroup merges LookupIPAddr calls together for lookups for the same
// host. The lookupGroup key is the LookupIPAddr.host argument.
// The return values are ([]IPAddr, error).
lookupGroup singleflight.Group
// TODO(bradfitz): optional interface impl override hook
// TODO(bradfitz): Timeout time.Duration?
// add dnsConfig
DnsConfig *dnsConfig
} net/dnsclient_unix.go:567 try to read dnsConfig of the resolver func (r *Resolver) goLookupIPCNAMEOrder(ctx context.Context, network, name string, order hostLookupOrder) (addrs []IPAddr, cname dnsmessage.Name, err error) {
if order == hostLookupFilesDNS || order == hostLookupFiles {
addrs = goLookupIPFiles(name)
if len(addrs) > 0 || order == hostLookupFiles {
return addrs, dnsmessage.Name{}, nil
}
}
if !isDomainName(name) {
// See comment in func lookup above about use of errNoSuchHost.
return nil, dnsmessage.Name{}, &DNSError{Err: errNoSuchHost.Error(), Name: name, IsNotFound: true}
}
// try to read dnsConfig of the resolver
var conf *dnsConfig
if r.DnsConfig != nil {
conf = r.DnsConfig
} else {
resolvConf.tryUpdate("/etc/resolv.conf")
resolvConf.mu.RLock()
conf = resolvConf.dnsConfig
resolvConf.mu.RUnlock()
}
...
} |
I guess you also need some API to set up the DnsConfig (as the type is unexported)? Changing to a proposal as this adds new API. |
Yes! Thank you very much! |
Note that the I think that in order to understand this proposal we need a complete description of all the API change involved. Simply adding a |
We clearly can't add a new exported field of an unexported, os-specific type. It seems like maybe using https://github.com/miekg/dns would be more appropriate in this case? |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely decline. |
No change in consensus, so declined. |
dnsConfig currently reflects the contents of /etc/resolv.conf, and reread regularly.
I hope can customize dnsConfig , and only once.
It should be helpful. Thanks very much!
The text was updated successfully, but these errors were encountered: