Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
581c4e55
提交
581c4e55
authored
2月 03, 2015
作者:
Juan Batiz-Benet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cmds/id: show self addrs
上级
d4257f95
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
7 行删除
+38
-7
id.go
core/commands/id.go
+32
-1
core.go
core/core.go
+6
-6
没有找到文件。
core/commands/id.go
浏览文件 @
581c4e55
...
@@ -14,8 +14,10 @@ import (
...
@@ -14,8 +14,10 @@ import (
b58
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
b58
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-base58"
cmds
"github.com/jbenet/go-ipfs/commands"
cmds
"github.com/jbenet/go-ipfs/commands"
core
"github.com/jbenet/go-ipfs/core"
ic
"github.com/jbenet/go-ipfs/p2p/crypto"
ic
"github.com/jbenet/go-ipfs/p2p/crypto"
"github.com/jbenet/go-ipfs/p2p/peer"
"github.com/jbenet/go-ipfs/p2p/peer"
identify
"github.com/jbenet/go-ipfs/p2p/protocol/identify"
kb
"github.com/jbenet/go-ipfs/routing/kbucket"
kb
"github.com/jbenet/go-ipfs/routing/kbucket"
u
"github.com/jbenet/go-ipfs/util"
u
"github.com/jbenet/go-ipfs/util"
)
)
...
@@ -63,7 +65,7 @@ ipfs id supports the format option for output with the following keys:
...
@@ -63,7 +65,7 @@ ipfs id supports the format option for output with the following keys:
}
}
if
len
(
req
.
Arguments
())
==
0
{
if
len
(
req
.
Arguments
())
==
0
{
output
,
err
:=
print
Peer
(
node
.
Peerstore
,
node
.
Identity
)
output
,
err
:=
print
Self
(
node
)
if
err
!=
nil
{
if
err
!=
nil
{
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
res
.
SetError
(
err
,
cmds
.
ErrNormal
)
return
return
...
@@ -168,3 +170,32 @@ func printPeer(ps peer.Peerstore, p peer.ID) (interface{}, error) {
...
@@ -168,3 +170,32 @@ func printPeer(ps peer.Peerstore, p peer.ID) (interface{}, error) {
return
info
,
nil
return
info
,
nil
}
}
// printing self is special cased as we get values differently.
func
printSelf
(
node
*
core
.
IpfsNode
)
(
interface
{},
error
)
{
info
:=
new
(
IdOutput
)
info
.
ID
=
node
.
Identity
.
Pretty
()
if
node
.
PrivateKey
==
nil
{
if
err
:=
node
.
LoadPrivateKey
();
err
!=
nil
{
return
nil
,
err
}
}
pk
:=
node
.
PrivateKey
.
GetPublic
()
pkb
,
err
:=
ic
.
MarshalPublicKey
(
pk
)
if
err
!=
nil
{
return
nil
,
err
}
info
.
PublicKey
=
base64
.
StdEncoding
.
EncodeToString
(
pkb
)
if
node
.
PeerHost
!=
nil
{
for
_
,
a
:=
range
node
.
PeerHost
.
Addrs
()
{
s
:=
a
.
String
()
+
"/ipfs/"
+
info
.
ID
info
.
Addresses
=
append
(
info
.
Addresses
,
s
)
}
}
info
.
ProtocolVersion
=
identify
.
IpfsVersion
info
.
AgentVersion
=
identify
.
ClientVersion
return
info
,
nil
}
core/core.go
浏览文件 @
581c4e55
...
@@ -67,8 +67,9 @@ type IpfsNode struct {
...
@@ -67,8 +67,9 @@ type IpfsNode struct {
Repo
repo
.
Repo
Repo
repo
.
Repo
// Local node
// Local node
Pinning
pin
.
Pinner
// the pinning manager
Pinning
pin
.
Pinner
// the pinning manager
Mounts
Mounts
// current mount state, if any.
Mounts
Mounts
// current mount state, if any.
PrivateKey
ic
.
PrivKey
// the local node's private Key
// Services
// Services
Peerstore
peer
.
Peerstore
// storage for other Peer instances
Peerstore
peer
.
Peerstore
// storage for other Peer instances
...
@@ -78,7 +79,6 @@ type IpfsNode struct {
...
@@ -78,7 +79,6 @@ type IpfsNode struct {
Resolver
*
path
.
Resolver
// the path resolution system
Resolver
*
path
.
Resolver
// the path resolution system
// Online
// Online
PrivateKey
ic
.
PrivKey
// the local node's private Key
PeerHost
p2phost
.
Host
// the network host (server+client)
PeerHost
p2phost
.
Host
// the network host (server+client)
Bootstrapper
io
.
Closer
// the periodic bootstrapper
Bootstrapper
io
.
Closer
// the periodic bootstrapper
Routing
routing
.
IpfsRouting
// the routing system. recommend ipfs-dht
Routing
routing
.
IpfsRouting
// the routing system. recommend ipfs-dht
...
@@ -222,7 +222,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, maybeRouter routing.
...
@@ -222,7 +222,7 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, maybeRouter routing.
}
}
// load private key
// load private key
if
err
:=
n
.
l
oadPrivateKey
();
err
!=
nil
{
if
err
:=
n
.
L
oadPrivateKey
();
err
!=
nil
{
return
err
return
err
}
}
...
@@ -368,7 +368,7 @@ func (n *IpfsNode) loadID() error {
...
@@ -368,7 +368,7 @@ func (n *IpfsNode) loadID() error {
return
nil
return
nil
}
}
func
(
n
*
IpfsNode
)
l
oadPrivateKey
()
error
{
func
(
n
*
IpfsNode
)
L
oadPrivateKey
()
error
{
if
n
.
Identity
==
""
||
n
.
Peerstore
==
nil
{
if
n
.
Identity
==
""
||
n
.
Peerstore
==
nil
{
return
debugerror
.
New
(
"loaded private key out of order."
)
return
debugerror
.
New
(
"loaded private key out of order."
)
}
}
...
@@ -400,7 +400,7 @@ func (n *IpfsNode) loadBootstrapPeers() ([]peer.PeerInfo, error) {
...
@@ -400,7 +400,7 @@ func (n *IpfsNode) loadBootstrapPeers() ([]peer.PeerInfo, error) {
// uses it to instantiate a routing system in offline mode.
// uses it to instantiate a routing system in offline mode.
// This is primarily used for offline ipns modifications.
// This is primarily used for offline ipns modifications.
func
(
n
*
IpfsNode
)
SetupOfflineRouting
()
error
{
func
(
n
*
IpfsNode
)
SetupOfflineRouting
()
error
{
err
:=
n
.
l
oadPrivateKey
()
err
:=
n
.
L
oadPrivateKey
()
if
err
!=
nil
{
if
err
!=
nil
{
return
err
return
err
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论