提交 31bb974b 作者: Steven Allen

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: 's avatarSteven Allen <steven@stebalien.com>
上级 e235d021
...@@ -6,7 +6,8 @@ import ( ...@@ -6,7 +6,8 @@ import (
"net/http" "net/http"
"strings" "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" isd "gx/ipfs/QmZmmuAXgX73UQmX1jRKjTGmjzq24Jinqkq8vzkBtno4uX/go-is-domain"
) )
...@@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption { ...@@ -24,7 +25,7 @@ func IPNSHostnameOption() ServeOption {
host := strings.SplitN(r.Host, ":", 2)[0] host := strings.SplitN(r.Host, ":", 2)[0]
if len(host) > 0 && isd.IsDomain(host) { if len(host) > 0 && isd.IsDomain(host) {
name := "/ipns/" + 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.Header["X-Ipns-Original-Path"] = []string{r.URL.Path}
r.URL.Path = name + r.URL.Path r.URL.Path = name + r.URL.Path
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论