Skip to content

Commit 8920ece

Browse files
authored
Merge pull request #6872 from ipfs/fix/id-addr-format
fix: fix id addr format
2 parents f27d04f + 26c5e38 commit 8920ece

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

core/commands/id.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
cmds "github.com/ipfs/go-ipfs-cmds"
1616
ic "github.com/libp2p/go-libp2p-core/crypto"
17+
"github.com/libp2p/go-libp2p-core/host"
1718
peer "github.com/libp2p/go-libp2p-core/peer"
1819
pstore "github.com/libp2p/go-libp2p-core/peerstore"
1920
kb "github.com/libp2p/go-libp2p-kbucket"
@@ -184,9 +185,12 @@ func printSelf(node *core.IpfsNode) (interface{}, error) {
184185
info.PublicKey = base64.StdEncoding.EncodeToString(pkb)
185186

186187
if node.PeerHost != nil {
187-
for _, a := range node.PeerHost.Addrs() {
188-
s := a.String() + "/ipfs/" + info.ID
189-
info.Addresses = append(info.Addresses, s)
188+
addrs, err := peer.AddrInfoToP2pAddrs(host.InfoFromHost(node.PeerHost))
189+
if err != nil {
190+
return nil, err
191+
}
192+
for _, a := range addrs {
193+
info.Addresses = append(info.Addresses, a.String())
190194
}
191195
}
192196
info.ProtocolVersion = identify.LibP2PVersion

core/commands/swarm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,11 @@ var swarmAddrsLocalCmd = &cmds.Command{
298298
}
299299

300300
var addrs []string
301+
p2pProtocolName := ma.ProtocolWithCode(ma.P_P2P).Name
301302
for _, addr := range maddrs {
302303
saddr := addr.String()
303304
if showid {
304-
saddr = path.Join(saddr, "ipfs", self.ID().Pretty())
305+
saddr = path.Join(saddr, p2pProtocolName, self.ID().Pretty())
305306
}
306307
addrs = append(addrs, saddr)
307308
}

0 commit comments

Comments
 (0)