Only perform DNSLink lookups on fully qualified domain names (FQDN)
This change halves the number of DNS queries requires to lookup DNSLink information for "example.com" by forcing the use of a FQDN. * example.com * example.com.local (removed) * _dnslink.example.com * _dnslink.example.com.local (removed) Where .local is the local system's organization/domain name. License: MIT Signed-off-by: Daniel Aleksandersen <code@daniel.priv.no>
Daniel Aleksandersen committed
Jan 28, 2019 at 07:28 UTC
775caf16cf74c692138f5c2451b2cdc89f9c1fd6
1 file changed
+9
-2
namesys/dns.go
+9
-2
@@ -45,6 +45,7 @@ type lookupRes struct {
45
// TXT records for a given domain name should contain a b58
46
// encoded multihash.
47
func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
48
+ var fqdn string
49
out := make(chan onceResult, 1)
50
segments := strings.SplitN(name, "/", 2)
51
domain := segments[0]
@@ -56,11 +57,17 @@ func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options
57
}
58
log.Debugf("DNSResolver resolving %s", domain)
59
60
+ if strings.HasSuffix(domain, ".") {
61
+ fqdn = domain
62
+ } else {
63
+ fqdn = domain + "."
64
+ }
65
+
66
rootChan := make(chan lookupRes, 1)
60
- go workDomain(r, domain, rootChan)
67
+ go workDomain(r, fqdn, rootChan)
68
69
subChan := make(chan lookupRes, 1)
63
- go workDomain(r, "_dnslink."+domain, subChan)
70
+ go workDomain(r, "_dnslink."+fqdn, subChan)
71
72
appendPath := func(p path.Path) (path.Path, error) {
73
if len(segments) > 1 {