From 7adeb6905467448e57e7bf1f01561fc573248879 Mon Sep 17 00:00:00 2001 From: Sergey Matveev Date: Sat, 2 May 2015 12:38:43 +0300 Subject: [PATCH] Add Established statistics field to know when connection was established Signed-off-by: Sergey Matveev --- transport.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/transport.go b/transport.go index 7379d68..6065c5e 100644 --- a/transport.go +++ b/transport.go @@ -55,6 +55,7 @@ type Peer struct { NonceOur uint64 `json:"-"` NonceRecv uint64 `json:"-"` NonceCipher *xtea.Cipher `json:"-"` + Established time.Time LastPing time.Time LastSent time.Time willSentCycle time.Time @@ -211,9 +212,11 @@ func newNonceCipher(key *[KeySize]byte) *xtea.Cipher { } func newPeer(addr *net.UDPAddr, id PeerId, nonce int, key *[KeySize]byte) *Peer { + now := time.Now() peer := Peer{ Addr: addr, - LastPing: time.Now(), + Established: now, + LastPing: now, Id: id, NonceOur: uint64(Noncediff + nonce), NonceRecv: uint64(Noncediff + 0), -- 2.48.1