Skip to content

Commit

Permalink
Merge pull request ipfs/kubo#1208 from wking/dns-resolver
Browse files Browse the repository at this point in the history
Rework mutable namespace resolution to handle recursion

This commit was moved from ipfs/kubo@01e1e71
  • Loading branch information
jbenet committed May 20, 2015
2 parents cd09dad + 67ad08e commit e6246bd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions gateway/core/corehttp/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,17 @@ import (
type mockNamesys map[string]path.Path

func (m mockNamesys) Resolve(ctx context.Context, name string) (value path.Path, err error) {
return m.ResolveN(ctx, name, namesys.DefaultDepthLimit)
}

func (m mockNamesys) ResolveN(ctx context.Context, name string, depth int) (value path.Path, err error) {
p, ok := m[name]
if !ok {
return "", namesys.ErrResolveFailed
}
return p, nil
}

func (m mockNamesys) CanResolve(name string) bool {
_, ok := m[name]
return ok
}

func (m mockNamesys) Publish(ctx context.Context, name ci.PrivKey, value path.Path) error {
return errors.New("not implemented for mockNamesys")
}
Expand Down
2 changes: 1 addition & 1 deletion gateway/core/corehttp/ipns_hostname.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func IPNSHostnameOption() ServeOption {

host := strings.SplitN(r.Host, ":", 2)[0]
if p, err := n.Namesys.Resolve(ctx, host); err == nil {
r.URL.Path = "/ipfs/" + p.String() + r.URL.Path
r.URL.Path = p.String() + r.URL.Path
}
childMux.ServeHTTP(w, r)
})
Expand Down

0 comments on commit e6246bd

Please sign in to comment.