提交 775caf16 作者: Daniel Aleksandersen

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: 's avatarDaniel Aleksandersen <code@daniel.priv.no>
上级 ca77ecc7
......@@ -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]
......@@ -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 {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论