()
| 18 | } |
| 19 | |
| 20 | func (peer *Peer) Status() PeerStatus { |
| 21 | endpoint := "" |
| 22 | peer.endpoints.Lock() |
| 23 | if len(peer.endpoints.val) > 0 { |
| 24 | endpoint = peer.endpoints.val[0].DstToString() |
| 25 | } |
| 26 | peer.endpoints.Unlock() |
| 27 | |
| 28 | peer.handshake.mutex.RLock() |
| 29 | publicKey := peer.handshake.remoteStatic |
| 30 | peer.handshake.mutex.RUnlock() |
| 31 | |
| 32 | return PeerStatus{ |
| 33 | PublicKey: publicKey, |
| 34 | Endpoint: endpoint, |
| 35 | LatestHandshakeUnixNano: peer.lastHandshakeNano.Load(), |
| 36 | TxBytes: peer.txBytes.Load(), |
| 37 | RxBytes: peer.rxBytes.Load(), |
| 38 | PersistentKeepaliveInterval: peer.persistentKeepaliveInterval.Load(), |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | func (s PeerStatus) LatestHandshakeTime() time.Time { |
| 43 | if s.LatestHandshakeUnixNano == 0 { |
no test coverage detected