Skip to content

Commit

Permalink
feat: support non-ICANN DNSLink names
Browse files Browse the repository at this point in the history
ipfs/kubo#8060


This commit was moved from ipfs/go-namesys@1f2af4e
  • Loading branch information
lidel authored and vyzo committed Apr 23, 2021
1 parent 246dfc7 commit a5c21d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions namesys/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (

path "github.com/ipfs/go-path"
opts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
isd "github.com/jbenet/go-is-domain"
dns "github.com/miekg/dns"
)

// LookupTXTFunc is a generic type for a function that lookups TXT record values.
Expand Down Expand Up @@ -52,7 +52,7 @@ func (r *DNSResolver) resolveOnceAsync(ctx context.Context, name string, options
segments := strings.SplitN(name, "/", 2)
domain := segments[0]

if !isd.IsDomain(domain) {
if _, ok := dns.IsDomainName(domain); !ok {
out <- onceResult{err: fmt.Errorf("not a valid domain name: %s", domain)}
close(out)
return out
Expand Down
12 changes: 8 additions & 4 deletions namesys/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
// DHT).
//
// Additionally, the /ipns/ namespace can also be used with domain names that
// use DNSLink (/ipns/my.domain.example, see https://dnslink.io) and proquint
// strings.
// use DNSLink (/ipns/<dnslink_name>, https://docs.ipfs.io/concepts/dnslink/)
// and proquint strings.
//
// The package provides implementations for all three resolvers.
package namesys
Expand All @@ -26,10 +26,10 @@ import (
dssync "github.com/ipfs/go-datastore/sync"
path "github.com/ipfs/go-path"
opts "github.com/ipfs/interface-go-ipfs-core/options/namesys"
isd "github.com/jbenet/go-is-domain"
ci "github.com/libp2p/go-libp2p-core/crypto"
peer "github.com/libp2p/go-libp2p-core/peer"
routing "github.com/libp2p/go-libp2p-core/routing"
dns "github.com/miekg/dns"
madns "github.com/multiformats/go-multiaddr-dns"
)

Expand Down Expand Up @@ -225,9 +225,13 @@ func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.

if err == nil {
res = ns.ipnsResolver
} else if isd.IsDomain(key) {
} else if _, ok := dns.IsDomainName(key); ok {
res = ns.dnsResolver
} else {
// TODO: remove proquint?
// dns.IsDomainName(key) will return true for proquint strings,
// so this block is a dead code.
// (alternative is to move this before DNS check)
res = ns.proquintResolver
}

Expand Down

0 comments on commit a5c21d5

Please sign in to comment.