@cryptotaxi247 / kubo / commits / 31bb974bb

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 <steven@stebalien.com>

Steven Allen committed Apr 25, 2018 at 00:00 UTC 31bb974bb1f2292fa69dc11a4bb3cfd1e2a0a61c
1 file changed +3 -2
core/corehttp/ipns_hostname.go
+3 -2
@@ -6,7 +6,8 @@ import (
6 "net/http"
7 "strings"
8
9 - "github.com/ipfs/go-ipfs/core"
9 + core "github.com/ipfs/go-ipfs/core"
10 + nsopts "github.com/ipfs/go-ipfs/namesys/opts"
11
12 isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
13 )
@@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption {
25 host := strings.SplitN(r.Host, ":", 2)[0]
26 if len(host) > 0 && isd.IsDomain(host) {
27 name := "/ipns/" + host
27 - if _, err := n.Namesys.Resolve(ctx, name); err == nil {
28 + if _, err := n.Namesys.Resolve(ctx, name, nsopts.Depth(1)); err == nil {
29 r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path}
30 r.URL.Path = name + r.URL.Path
31 }