mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-05-21 01:15:07 +03:00
Expose download/upload rate per peer (#1206)
This commit is contained in:
parent
c22a746a1d
commit
9398cae230
5 changed files with 61 additions and 12 deletions
|
@ -33,6 +33,8 @@ type PeerInfo struct {
|
|||
Cost uint64
|
||||
RXBytes uint64
|
||||
TXBytes uint64
|
||||
RXRate uint64
|
||||
TXRate uint64
|
||||
Uptime time.Duration
|
||||
Latency time.Duration
|
||||
}
|
||||
|
@ -87,6 +89,8 @@ func (c *Core) GetPeers() []PeerInfo {
|
|||
peerinfo.Inbound = state.linkType == linkTypeIncoming
|
||||
peerinfo.RXBytes = atomic.LoadUint64(&c.rx)
|
||||
peerinfo.TXBytes = atomic.LoadUint64(&c.tx)
|
||||
peerinfo.RXRate = atomic.LoadUint64(&c.rxrate)
|
||||
peerinfo.TXRate = atomic.LoadUint64(&c.txrate)
|
||||
peerinfo.Uptime = time.Since(c.up)
|
||||
}
|
||||
if p, ok := conns[conn]; ok {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue