1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-03 20:32:14 +08:00

don't hardcode ipfs protocol name in multiaddr display

License: MIT
Signed-off-by: vyzo <vyzo@hackzen.org>
This commit is contained in:
vyzo
2017-08-01 23:06:40 +03:00
parent 1141705e9a
commit a130659800

View File

@ -128,11 +128,13 @@ var swarmPeersCmd = &cmds.Command{
}
buf := new(bytes.Buffer)
pipfs := ma.ProtocolWithCode(ma.P_IPFS)
for _, info := range ci.Peers {
if strings.HasSuffix(info.Addr, fmt.Sprintf("/ipfs/%s", info.Peer)) {
ids := fmt.Sprintf("/%s/%s", pipfs.Name, info.Peer)
if strings.HasSuffix(info.Addr, ids) {
fmt.Fprintf(buf, "%s", info.Addr)
} else {
fmt.Fprintf(buf, "%s/ipfs/%s", info.Addr, info.Peer)
fmt.Fprintf(buf, "%s%s", info.Addr, ids)
}
if info.Latency != "" {
fmt.Fprintf(buf, " %s", info.Latency)