device.peers.empty.Set(false)
// start peer
+ peer.timersInit()
if peer.device.isUp() {
peer.Start()
}
}
peer.device.queue.encryption.wg.Add(1) // keep encryption queue open for our writes
- peer.timersInit()
+ peer.timersStart()
go peer.RoutineSequentialSender()
go peer.RoutineSequentialReceiver()
"time"
)
-/* This Timer structure and related functions should roughly copy the interface of
- * the Linux kernel's struct timer_list.
- */
-
+// A Timer manages time-based aspects of the WireGuard protocol.
+// Timer roughly copies the interface of the Linux kernel's struct timer_list.
type Timer struct {
*time.Timer
modifyingLock sync.RWMutex
peer.timers.newHandshake = peer.NewTimer(expiredNewHandshake)
peer.timers.zeroKeyMaterial = peer.NewTimer(expiredZeroKeyMaterial)
peer.timers.persistentKeepalive = peer.NewTimer(expiredPersistentKeepalive)
+}
+
+func (peer *Peer) timersStart() {
atomic.StoreUint32(&peer.timers.handshakeAttempts, 0)
peer.timers.sentLastMinuteHandshake.Set(false)
peer.timers.needAnotherKeepalive.Set(false)