Skip to content

Commit

Permalink
Fix: dnslink domain resolving was broken; Add: no caching for those
Browse files Browse the repository at this point in the history
fixes ipfs#1234
fixes ipfs#1267
  • Loading branch information
Luzifer authored and rht committed May 26, 2015
1 parent dacdeb1 commit 0895966
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/corehttp/ipns_hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand All @@ -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)
})
Expand Down

0 comments on commit 0895966

Please sign in to comment.