From 681d59b36f7c1c6fe308114f8a8aa596961bb4aa 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 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go index 6a36bd8c474..265feef804a 100644 --- a/core/corehttp/ipns_hostname.go +++ b/core/corehttp/ipns_hostname.go @@ -6,7 +6,8 @@ import ( "net/http" "strings" - "github.com/ipfs/go-ipfs/core" + core "github.com/ipfs/go-ipfs/core" + nsopts "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, nsopts.Depth(1)); err == nil { r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path} r.URL.Path = name + r.URL.Path }