mirror of
https://github.com/ipfs/kubo.git
synced 2025-07-01 02:30:39 +08:00
Fix: dnslink domain resolving was broken; Add: no caching for those
fixes #1234 fixes #1267
This commit is contained in:
@ -5,6 +5,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain"
|
||||||
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
"github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
|
||||||
"github.com/ipfs/go-ipfs/core"
|
"github.com/ipfs/go-ipfs/core"
|
||||||
)
|
)
|
||||||
@ -20,8 +21,11 @@ func IPNSHostnameOption() ServeOption {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
host := strings.SplitN(r.Host, ":", 2)[0]
|
host := strings.SplitN(r.Host, ":", 2)[0]
|
||||||
if p, err := n.Namesys.Resolve(ctx, host); err == nil {
|
if len(host) > 0 && isd.IsDomain(host) {
|
||||||
r.URL.Path = path.Join(p.String(), r.URL.Path)
|
name := "/ipns/" + host
|
||||||
|
if _, err := n.Namesys.Resolve(ctx, name); err == nil {
|
||||||
|
r.URL.Path = path.Join("/ipns/", host) + r.URL.Path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
childMux.ServeHTTP(w, r)
|
childMux.ServeHTTP(w, r)
|
||||||
})
|
})
|
||||||
|
Reference in New Issue
Block a user