don't hardcode ipfs protocol name in multiaddr display
License: MIT Signed-off-by: vyzo <vyzo@hackzen.org>
vyzo committed
Aug 1, 2017 at 23:06 UTC
a1306598009c44238b046c33285e28a3d664b3f4
1 file changed
+4
-2
core/commands/swarm.go
+4
-2
@@ -128,11 +128,13 @@ var swarmPeersCmd = &cmds.Command{
128
}
129
130
buf := new(bytes.Buffer)
131
+ pipfs := ma.ProtocolWithCode(ma.P_IPFS)
132
for _, info := range ci.Peers {
132
- if strings.HasSuffix(info.Addr, fmt.Sprintf("/ipfs/%s", info.Peer)) {
133
+ ids := fmt.Sprintf("/%s/%s", pipfs.Name, info.Peer)
134
+ if strings.HasSuffix(info.Addr, ids) {
135
fmt.Fprintf(buf, "%s", info.Addr)
136
} else {
135
- fmt.Fprintf(buf, "%s/ipfs/%s", info.Addr, info.Peer)
137
+ fmt.Fprintf(buf, "%s%s", info.Addr, ids)
138
}
139
if info.Latency != "" {
140
fmt.Fprintf(buf, " %s", info.Latency)