mirror of
https://github.com/ipfs/kubo.git
synced 2025-09-12 07:55:07 +08:00
allow ipfs id to work on self
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -62,7 +62,18 @@ ipfs id supports the format option for output with the following keys:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(req.Arguments()) == 0 {
|
var id peer.ID
|
||||||
|
if len(req.Arguments()) > 0 {
|
||||||
|
id = peer.ID(b58.Decode(req.Arguments()[0]))
|
||||||
|
if len(id) == 0 {
|
||||||
|
res.SetError(cmds.ClientError("Invalid peer id"), cmds.ErrClient)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id = node.Identity
|
||||||
|
}
|
||||||
|
|
||||||
|
if id == node.Identity {
|
||||||
output, err := printSelf(node)
|
output, err := printSelf(node)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmds.ErrNormal)
|
||||||
@ -72,14 +83,6 @@ ipfs id supports the format option for output with the following keys:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pid := req.Arguments()[0]
|
|
||||||
|
|
||||||
id := peer.ID(b58.Decode(pid))
|
|
||||||
if len(id) == 0 {
|
|
||||||
res.SetError(cmds.ClientError("Invalid peer id"), cmds.ErrClient)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO handle offline mode with polymorphism instead of conditionals
|
// TODO handle offline mode with polymorphism instead of conditionals
|
||||||
if !node.OnlineMode() {
|
if !node.OnlineMode() {
|
||||||
res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient)
|
res.SetError(errors.New(offlineIdErrorMessage), cmds.ErrClient)
|
||||||
|
Reference in New Issue
Block a user