mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Restore uptime
, bytes_sent
and bytes_recvd
to getPeers
(#888)
* Restore `uptime`, `bytes_sent` and `bytes_recvd` to the admin API for peers * Wrap conn in Yggdrasil instead, so not necessary to do so in Ironwood * Shuffle struct for alignment
This commit is contained in:
parent
9f5cc0eecb
commit
2d2ad4692b
3 changed files with 51 additions and 7 deletions
|
@ -2,12 +2,16 @@ package core
|
|||
|
||||
import (
|
||||
"crypto/ed25519"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
//"encoding/hex"
|
||||
"encoding/json"
|
||||
//"errors"
|
||||
//"fmt"
|
||||
"net"
|
||||
"net/url"
|
||||
|
||||
//"sort"
|
||||
//"time"
|
||||
|
||||
|
@ -24,11 +28,14 @@ type Self struct {
|
|||
}
|
||||
|
||||
type Peer struct {
|
||||
Key ed25519.PublicKey
|
||||
Root ed25519.PublicKey
|
||||
Coords []uint64
|
||||
Port uint64
|
||||
Remote string
|
||||
Key ed25519.PublicKey
|
||||
Root ed25519.PublicKey
|
||||
Coords []uint64
|
||||
Port uint64
|
||||
Remote string
|
||||
RXBytes uint64
|
||||
TXBytes uint64
|
||||
Uptime time.Duration
|
||||
}
|
||||
|
||||
type DHTEntry struct {
|
||||
|
@ -74,6 +81,11 @@ func (c *Core) GetPeers() []Peer {
|
|||
if name := names[p.Conn]; name != "" {
|
||||
info.Remote = name
|
||||
}
|
||||
if linkconn, ok := p.Conn.(*linkConn); ok {
|
||||
info.RXBytes = atomic.LoadUint64(&linkconn.rx)
|
||||
info.TXBytes = atomic.LoadUint64(&linkconn.tx)
|
||||
info.Uptime = time.Since(linkconn.up)
|
||||
}
|
||||
peers = append(peers, info)
|
||||
}
|
||||
return peers
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue