From: Sergey Matveev Date: Sat, 2 May 2015 09:38:43 +0000 (+0300) Subject: Add Established statistics field to know when connection was established X-Git-Tag: 3.0^2~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=7adeb6905467448e57e7bf1f01561fc573248879;p=govpn.git Add Established statistics field to know when connection was established Signed-off-by: Sergey Matveev --- 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),