Skip to content

Commit dd47364

Browse files
Stebalienaschmahmann
authored andcommitted
feat: add protocol list to ipfs id
1 parent dd1093f commit dd47364

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/commands/id.go

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type IdOutput struct {
3636
Addresses []string
3737
AgentVersion string
3838
ProtocolVersion string
39+
Protocols []string
3940
}
4041

4142
const (
@@ -123,6 +124,7 @@ EXAMPLE:
123124
output = strings.Replace(output, "<pver>", out.ProtocolVersion, -1)
124125
output = strings.Replace(output, "<pubkey>", out.PublicKey, -1)
125126
output = strings.Replace(output, "<addrs>", strings.Join(out.Addresses, "\n"), -1)
127+
output = strings.Replace(output, "<protocols>", strings.Join(out.Protocols, "\n"), -1)
126128
output = strings.Replace(output, "\\n", "\n", -1)
127129
output = strings.Replace(output, "\\t", "\t", -1)
128130
fmt.Fprint(w, output)
@@ -166,6 +168,11 @@ func printPeer(ps pstore.Peerstore, p peer.ID) (interface{}, error) {
166168
info.Addresses = append(info.Addresses, a.String())
167169
}
168170

171+
protocols, _ := ps.GetProtocols(p) // don't care about errors here.
172+
for _, p := range protocols {
173+
info.Protocols = append(info.Protocols, string(p))
174+
}
175+
169176
if v, err := ps.Get(p, "ProtocolVersion"); err == nil {
170177
if vs, ok := v.(string); ok {
171178
info.ProtocolVersion = vs
@@ -200,6 +207,7 @@ func printSelf(node *core.IpfsNode) (interface{}, error) {
200207
for _, a := range addrs {
201208
info.Addresses = append(info.Addresses, a.String())
202209
}
210+
info.Protocols = node.PeerHost.Mux().Protocols()
203211
}
204212
info.ProtocolVersion = identify.LibP2PVersion
205213
info.AgentVersion = version.UserAgent

0 commit comments

Comments
 (0)