Skip to content

Commit

Permalink
only resolve dnslinks once in the gateway
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Stebalien committed Apr 25, 2018
1 parent 6321f3b commit 81ffb14
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/corehttp/ipns_hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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
}
Expand Down

0 comments on commit 81ffb14

Please sign in to comment.