Skip to content

Commit

Permalink
Only perform DNSLink lookups on fully qualified domain names (FQDN)
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
da2x committed Jan 28, 2019
1 parent ca77ecc commit 775caf1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions namesys/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ type lookupRes struct {
// TXT records for a given domain name should contain a b58
// encoded multihash.
func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
var fqdn string
out := make(chan onceResult, 1)
segments := strings.SplitN(name, "/", 2)
domain := segments[0]
Expand All @@ -56,11 +57,17 @@ func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options
}
log.Debugf("DNSResolver resolving %s", domain)

if strings.HasSuffix(domain, ".") {
fqdn = domain
} else {
fqdn = domain + "."
}

rootChan := make(chan lookupRes, 1)
go workDomain(r, domain, rootChan)
go workDomain(r, fqdn, rootChan)

subChan := make(chan lookupRes, 1)
go workDomain(r, "_dnslink."+domain, subChan)
go workDomain(r, "_dnslink."+fqdn, subChan)

appendPath := func(p path.Path) (path.Path, error) {
if len(segments) > 1 {
Expand Down

0 comments on commit 775caf1

Please sign in to comment.