@cryptotaxi247 / kubo / commits / 373260d37

Fix: dnslink domain resolving was broken; Add: no caching for those

fixes #1234 fixes #1267

Knut Ahlers committed May 21, 2015 at 08:44 UTC 373260d373c4066fa89ae60209f80e1fac92800c
1 file changed +6 -2
core/corehttp/ipns_hostname.go
+6 -2
@@ -5,6 +5,7 @@ import (
5 "path"
6 "strings"
7
8 + isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain"
9 "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
10 "github.com/ipfs/go-ipfs/core"
11 )
@@ -20,8 +21,11 @@ func IPNSHostnameOption() ServeOption {
21 defer cancel()
22
23 host := strings.SplitN(r.Host, ":", 2)[0]
23 - if p, err := n.Namesys.Resolve(ctx, host); err == nil {
24 - r.URL.Path = path.Join(p.String(), r.URL.Path)
24 + if len(host) > 0 && isd.IsDomain(host) {
25 + name := "/ipns/" + host
26 + if _, err := n.Namesys.Resolve(ctx, name); err == nil {
27 + r.URL.Path = path.Join("/ipns/", host) + r.URL.Path
28 + }
29 }
30 childMux.ServeHTTP(w, r)
31 })