2019-06-20 21:01:34 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
type Peer struct {
|
|
|
|
Enode string `json:"enode"`
|
2019-06-20 21:06:37 +00:00
|
|
|
Id peerId `json:"id"`
|
2019-06-20 21:01:34 +00:00
|
|
|
Name string `json:"na"`
|
|
|
|
Caps []string `json:"caps"`
|
|
|
|
Network NetworkInfo `json:"netrowkr"`
|
|
|
|
Protocols map[string]string `json:"protocols"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (p Peer) String() string {
|
|
|
|
return fmt.Sprintf("Peer(id=%s)", p.Id)
|
|
|
|
}
|
|
|
|
|
2019-06-20 21:06:37 +00:00
|
|
|
type peerId string
|
|
|
|
|
2019-06-20 21:14:50 +00:00
|
|
|
func (p Peer) AsTable() string {
|
|
|
|
return fmt.Sprintf("%15s | what", p.Id)
|
|
|
|
}
|
|
|
|
|
2019-06-20 21:06:37 +00:00
|
|
|
// the ID is too long to display in full in most places
|
|
|
|
func (id peerId) String() string {
|
|
|
|
return fmt.Sprintf("%s...%s",
|
|
|
|
string(id[:6]),
|
|
|
|
string(id[len(id)-6:]))
|
|
|
|
}
|
|
|
|
|
2019-06-20 21:01:34 +00:00
|
|
|
type NetworkInfo struct {
|
|
|
|
LocalAddress string `json:"localAddress"`
|
|
|
|
RemoteAddress string `json:"remoteAddress"`
|
|
|
|
Inbound bool `json:"inbound"`
|
|
|
|
Trusted bool `json:"trusted"`
|
|
|
|
Static bool `json:"static"`
|
|
|
|
}
|