Skip to content

Commit 681d59b

Browse files
committed
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 <[email protected]>
1 parent 6321f3b commit 681d59b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

core/corehttp/ipns_hostname.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ import (
66
"net/http"
77
"strings"
88

9-
"github.com/ipfs/go-ipfs/core"
9+
core "github.com/ipfs/go-ipfs/core"
10+
nsopts "github.com/ipfs/go-ipfs/namesys/opts"
1011

1112
isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
1213
)
@@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption {
2425
host := strings.SplitN(r.Host, ":", 2)[0]
2526
if len(host) > 0 && isd.IsDomain(host) {
2627
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 {
2829
r.Header["X-Ipns-Original-Path"] = []string{r.URL.Path}
2930
r.URL.Path = name + r.URL.Path
3031
}

0 commit comments

Comments
 (0)