From 373260d373c4066fa89ae60209f80e1fac92800c Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 21 May 2015 08:44:17 +0200 Subject: [PATCH 1/2] Fix: dnslink domain resolving was broken; Add: no caching for those fixes #1234 fixes #1267 --- core/corehttp/ipns_hostname.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go index f651cc60f..a7631c5a4 100644 --- a/core/corehttp/ipns_hostname.go +++ b/core/corehttp/ipns_hostname.go @@ -5,6 +5,7 @@ import ( "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 +21,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 = path.Join("/ipns/", host) + r.URL.Path + } } childMux.ServeHTTP(w, r) }) From 8df8737f6aea0d407db13b30a3b108549a356462 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Thu, 21 May 2015 08:51:18 +0200 Subject: [PATCH 2/2] removed requirement of path package --- core/corehttp/ipns_hostname.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/core/corehttp/ipns_hostname.go b/core/corehttp/ipns_hostname.go index a7631c5a4..6f31e5268 100644 --- a/core/corehttp/ipns_hostname.go +++ b/core/corehttp/ipns_hostname.go @@ -2,7 +2,6 @@ package corehttp import ( "net/http" - "path" "strings" isd "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-is-domain" @@ -24,7 +23,7 @@ func IPNSHostnameOption() ServeOption { if len(host) > 0 && isd.IsDomain(host) { name := "/ipns/" + host if _, err := n.Namesys.Resolve(ctx, name); err == nil { - r.URL.Path = path.Join("/ipns/", host) + r.URL.Path + r.URL.Path = name + r.URL.Path } } childMux.ServeHTTP(w, r)