Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow resolution of .eth names via .eth.link #6448

Merged
merged 2 commits into from
Aug 5, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions namesys/namesys.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,21 @@ func (ns *mpns) ResolveAsync(ctx context.Context, name string, options ...opts.R
return resolveAsync(ctx, ns, name, opts.ProcessOpts(options))
}

const ethTLD = ".eth"
const linkTLD = ".link"

// resolveOnce implements resolver.
func (ns *mpns) resolveOnceAsync(ctx context.Context, name string, options opts.ResolveOpts) <-chan onceResult {
out := make(chan onceResult, 1)

if !strings.HasPrefix(name, ipnsPrefix) {
name = ipnsPrefix + name
}
if strings.HasSuffix(name, ethTLD) {
// This is an ENS name. As we're resolving via an arbitrary DNS server
// that may not know about .eth we need to add our link domain suffix.
name = name + linkTLD
}
segments := strings.SplitN(name, "/", 4)
if len(segments) < 3 || segments[0] != "" {
log.Debugf("invalid name syntax for %s", name)
Expand Down