From 81ffb1441341be62fd24f4f8909b41f767a1b7e9 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Wed, 25 Apr 2018 00:00:37 -0700 Subject: [PATCH] only resolve dnslinks once in the gateway If the domain has a DNS-Link, we want to use it even if it points to, e.g., an IPNS address that doesn't resolve. fixes #4973 License: MIT Signed-off-by: Steven Allen --- core/corehttp/ipns_hostname.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go index 6a36bd8c474b..8e6d5693f0bb 100644 --- a/core/corehttp/ipns_hostname.go +++ b/core/corehttp/ipns_hostname.go @@ -7,6 +7,7 @@ import ( "strings" "github.com/ipfs/go-ipfs/core" + opts "github.com/ipfs/go-ipfs/namesys/opts" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain" ) @@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption { host := strings.SplitN(r.Host, ":", 2)[0] if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host - if _, err := n.Namesys.Resolve(ctx, name); err == nil { + if _, err := n.Namesys.Resolve(ctx, name, opts.Depth(1)); err == nil { r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path }