diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-27 23:45:37 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-07-27 23:45:37 +0200 |
commit | fb3fa4f9158458654281129f44f354a65741aef3 (patch) | |
tree | 92bd2213f9b51f56bd2fe8178192d33180bb10be /src/peer.go | |
parent | 47f8a3d89ad0d1478246bf62140eb4fbfe83ac72 (diff) |
Improved timer code
Diffstat (limited to 'src/peer.go')
-rw-r--r-- | src/peer.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/peer.go b/src/peer.go index 8eea929..9136959 100644 --- a/src/peer.go +++ b/src/peer.go @@ -40,21 +40,22 @@ type Peer struct { stop chan struct{} // (size 0) : close to stop all goroutines for peer } timer struct { - /* Both keep-alive timers acts as one (see timers.go) - * They are kept seperate to simplify the implementation. - */ keepalivePersistent *time.Timer // set for persistent keepalives keepalivePassive *time.Timer // set upon recieving messages - zeroAllKeys *time.Timer // zero all key material after RejectAfterTime*3 + newHandshake *time.Timer // begin a new handshake (after Keepalive + RekeyTimeout) + zeroAllKeys *time.Timer // zero all key material (after RejectAfterTime*3) + + pendingKeepalivePassive bool + pendingNewHandshake bool + pendingZeroAllKeys bool + + needAnotherKeepalive bool } queue struct { nonce chan *QueueOutboundElement // nonce / pre-handshake queue outbound chan *QueueOutboundElement // sequential ordering of work inbound chan *QueueInboundElement // sequential ordering of work } - flags struct { - keepaliveWaiting int32 - } mac MACStatePeer } @@ -68,12 +69,11 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { peer.mac.Init(pk) peer.device = device - peer.timer.keepalivePassive = NewStoppedTimer() peer.timer.keepalivePersistent = NewStoppedTimer() + peer.timer.keepalivePassive = NewStoppedTimer() + peer.timer.newHandshake = NewStoppedTimer() peer.timer.zeroAllKeys = NewStoppedTimer() - peer.flags.keepaliveWaiting = AtomicFalse - // assign id for debugging device.mutex.Lock() |