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.
  • Loading branch information
da2x committed Jan 28, 2019
1 parent ca77ecc commit cd8a7b5
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

1 comment on commit cd8a7b5

@GitCop
Copy link

@GitCop GitCop commented on cd8a7b5 Jan 28, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.