mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
feat: add protocol list to ipfs id
This commit is contained in:
parent
dd1093f438
commit
dd47364e24
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user