Commit 4e71ce3c authored by Juan Batiz-Benet's avatar Juan Batiz-Benet

Merge pull request #1272 from Luzifer/fix/dnslink

Fix: dnslink domain resolving was broken; Add: no caching for those
parents dacdeb10 8df8737f
......@@ -2,9 +2,9 @@ package corehttp
import (
"net/http"
"path"
"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/core"
)
......@@ -20,8 +20,11 @@ func IPNSHostnameOption() ServeOption {
defer cancel()
host := strings.SplitN(r.Host, ":", 2)[0]
if p, err := n.Namesys.Resolve(ctx, host); err == nil {
r.URL.Path = path.Join(p.String(), r.URL.Path)
if len(host) > 0 && isd.IsDomain(host) {
name := "/ipns/" + host
if _, err := n.Namesys.Resolve(ctx, name); err == nil {
r.URL.Path = name + r.URL.Path
}
}
childMux.ServeHTTP(w, r)
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment