Commit dd47364e authored by Steven Allen's avatar Steven Allen Committed by Adin Schmahmann

feat: add protocol list to ipfs id

parent dd1093f4
......@@ -36,6 +36,7 @@ type IdOutput struct {
Addresses []string
AgentVersion string
ProtocolVersion string
Protocols []string
}
const (
......@@ -123,6 +124,7 @@ EXAMPLE:
output = strings.Replace(output, "<pver>", out.ProtocolVersion, -1)
output = strings.Replace(output, "<pubkey>", out.PublicKey, -1)
output = strings.Replace(output, "<addrs>", strings.Join(out.Addresses, "\n"), -1)
output = strings.Replace(output, "<protocols>", strings.Join(out.Protocols, "\n"), -1)
output = strings.Replace(output, "\\n", "\n", -1)
output = strings.Replace(output, "\\t", "\t", -1)
fmt.Fprint(w, output)
......@@ -166,6 +168,11 @@ func printPeer(ps pstore.Peerstore, p peer.ID) (interface{}, error) {
info.Addresses = append(info.Addresses, a.String())
}
protocols, _ := ps.GetProtocols(p) // don't care about errors here.
for _, p := range protocols {
info.Protocols = append(info.Protocols, string(p))
}
if v, err := ps.Get(p, "ProtocolVersion"); err == nil {
if vs, ok := v.(string); ok {
info.ProtocolVersion = vs
......@@ -200,6 +207,7 @@ func printSelf(node *core.IpfsNode) (interface{}, error) {
for _, a := range addrs {
info.Addresses = append(info.Addresses, a.String())
}
info.Protocols = node.PeerHost.Mux().Protocols()
}
info.ProtocolVersion = identify.LibP2PVersion
info.AgentVersion = version.UserAgent
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment