mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 03:17:43 +08:00
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>
This commit is contained in:
parent
e235d02188
commit
31bb974bb1
@ -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
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user