mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
Measure RTT, report in getPeers
(#1143)
Co-authored-by: Neil Alexander <neilalexander@users.noreply.github.com>
This commit is contained in:
parent
fcefb20993
commit
f788a18bef
5 changed files with 14 additions and 5 deletions
|
@ -27,6 +27,7 @@ type PeerEntry struct {
|
|||
RXBytes DataUnit `json:"bytes_recvd,omitempty"`
|
||||
TXBytes DataUnit `json:"bytes_sent,omitempty"`
|
||||
Uptime float64 `json:"uptime,omitempty"`
|
||||
Latency time.Duration `json:"latency_ms,omitempty"`
|
||||
LastErrorTime time.Duration `json:"last_error_time,omitempty"`
|
||||
LastError string `json:"last_error,omitempty"`
|
||||
}
|
||||
|
@ -45,6 +46,9 @@ func (a *AdminSocket) getPeersHandler(req *GetPeersRequest, res *GetPeersRespons
|
|||
TXBytes: DataUnit(p.TXBytes),
|
||||
Uptime: p.Uptime.Seconds(),
|
||||
}
|
||||
if p.Latency > 0 {
|
||||
peer.Latency = p.Latency
|
||||
}
|
||||
if addr := address.AddrForKey(p.Key); addr != nil {
|
||||
peer.PublicKey = hex.EncodeToString(p.Key)
|
||||
peer.IPAddress = net.IP(addr[:]).String()
|
||||
|
|
|
@ -33,6 +33,7 @@ type PeerInfo struct {
|
|||
RXBytes uint64
|
||||
TXBytes uint64
|
||||
Uptime time.Duration
|
||||
Latency time.Duration
|
||||
}
|
||||
|
||||
type TreeEntryInfo struct {
|
||||
|
@ -92,6 +93,7 @@ func (c *Core) GetPeers() []PeerInfo {
|
|||
peerinfo.Root = p.Root
|
||||
peerinfo.Port = p.Port
|
||||
peerinfo.Priority = p.Priority
|
||||
peerinfo.Latency = p.Latency
|
||||
}
|
||||
peers = append(peers, peerinfo)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue