mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-28 22:08:01 +08:00
allow ipfs name resolve to respect --local flag for local name resolution
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
parent
bea47c9b0a
commit
73cd3f6563
@ -7,6 +7,7 @@ import (
|
||||
|
||||
cmds "github.com/ipfs/go-ipfs/commands"
|
||||
namesys "github.com/ipfs/go-ipfs/namesys"
|
||||
offline "github.com/ipfs/go-ipfs/routing/offline"
|
||||
u "github.com/ipfs/go-ipfs/util"
|
||||
)
|
||||
|
||||
@ -61,6 +62,11 @@ Resolve the value of another name:
|
||||
}
|
||||
}
|
||||
|
||||
router := n.Routing
|
||||
if local, _, _ := req.Option("local").Bool(); local {
|
||||
router = offline.NewOfflineRouter(n.Repo.Datastore(), n.PrivateKey)
|
||||
}
|
||||
|
||||
var name string
|
||||
|
||||
if len(req.Arguments()) == 0 {
|
||||
@ -80,7 +86,7 @@ Resolve the value of another name:
|
||||
depth = namesys.DefaultDepthLimit
|
||||
}
|
||||
|
||||
resolver := namesys.NewRoutingResolver(n.Routing)
|
||||
resolver := namesys.NewRoutingResolver(router)
|
||||
output, err := resolver.ResolveN(req.Context(), name, depth)
|
||||
if err != nil {
|
||||
res.SetError(err, cmds.ErrNormal)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user