Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
fff95d6f
Commit
fff95d6f
authored
Oct 27, 2015
by
Juan Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1856 from ipfs/fix/id-self
allow ipfs id to work on self
parents
2963d2e1
71288160
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
9 deletions
+22
-9
core/commands/id.go
core/commands/id.go
+12
-9
test/sharness/t0140-swarm.sh
test/sharness/t0140-swarm.sh
+10
-0
No files found.
core/commands/id.go
View file @
fff95d6f
...
@@ -62,7 +62,18 @@ ipfs id supports the format option for output with the following keys:
...
@@ -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:
...
@@ -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
)
...
...
test/sharness/t0140-swarm.sh
View file @
fff95d6f
...
@@ -28,6 +28,16 @@ test_expect_success 'disconnected: addrs local matches ipfs id' '
...
@@ -28,6 +28,16 @@ test_expect_success 'disconnected: addrs local matches ipfs id' '
test_cmp expected actual
test_cmp expected actual
'
'
test_expect_success
"ipfs id self works"
'
myid=$(ipfs id -f="<id>") &&
ipfs id --timeout=1s $myid > output
'
test_expect_success
"output looks good"
'
grep $myid output &&
grep PublicKey output
'
test_kill_ipfs_daemon
test_kill_ipfs_daemon
test_done
test_done
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment