summaryrefslogtreecommitdiffhomepage
path: root/send.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 02:20:52 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2018-05-05 02:20:52 +0200
commit6db41d5a269c79bd04b18dbfa171cc241a6cdcc9 (patch)
tree7cfd9a8461b5c66dd971971e3706ada4c8b0484a /send.go
parent168ef61a638e4875b260edbc51551bae0dc34ac3 (diff)
Initial version of migration to new event model
- Begin move away from global timer state. - Made logging format more consistent
Diffstat (limited to 'send.go')
-rw-r--r--send.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/send.go b/send.go
index 5c6b350..646550a 100644
--- a/send.go
+++ b/send.go
@@ -45,7 +45,7 @@ type QueueOutboundElement struct {
peer *Peer // related peer
}
-func (peer *Peer) FlushNonceQueue() {
+func (peer *Peer) flushNonceQueue() {
elems := len(peer.queue.nonce)
for i := 0; i < elems; i++ {
select {
@@ -175,7 +175,7 @@ func (device *Device) RoutineReadFromTUN() {
// insert into nonce/pre-handshake queue
if peer.isRunning.Get() {
- peer.timer.handshakeDeadline.Reset(RekeyAttemptTime)
+ peer.event.handshakePushDeadline.Fire()
addToOutboundQueue(peer.queue.nonce, elem)
elem = device.NewOutboundElement()
}
@@ -196,11 +196,11 @@ func (peer *Peer) RoutineNonce() {
defer func() {
peer.routines.stopping.Done()
- logDebug.Println(peer.String() + ": Routine: nonce worker - stopped")
+ logDebug.Println(peer, ": Routine: nonce worker - stopped")
}()
peer.routines.starting.Done()
- logDebug.Println(peer.String() + ": Routine: nonce worker - started")
+ logDebug.Println(peer, ": Routine: nonce worker - started")
for {
NextPacket:
@@ -226,14 +226,12 @@ func (peer *Peer) RoutineNonce() {
peer.signal.handshakeBegin.Send()
- logDebug.Println(peer.String() + ": Awaiting key-pair")
+ logDebug.Println(peer, ": Awaiting key-pair")
select {
case <-peer.signal.newKeyPair.Wait():
- logDebug.Println(peer.String() + ": Obtained awaited key-pair")
- case <-peer.signal.flushNonceQueue.Wait():
- logDebug.Println(peer.String() + ": Flushing nonce queue")
- peer.FlushNonceQueue()
+ logDebug.Println(peer, ": Obtained awaited key-pair")
+ case <-peer.signal.flushNonceQueue:
goto NextPacket
case <-peer.routines.stop.Wait():
return
@@ -352,10 +350,10 @@ func (peer *Peer) RoutineSequentialSender() {
defer func() {
peer.routines.stopping.Done()
- logDebug.Println(peer.String() + ": Routine: sequential sender - stopped")
+ logDebug.Println(peer, ": Routine: sequential sender - stopped")
}()
- logDebug.Println(peer.String() + ": Routine: sequential sender - started")
+ logDebug.Println(peer, ": Routine: sequential sender - started")
peer.routines.starting.Done()
@@ -382,7 +380,7 @@ func (peer *Peer) RoutineSequentialSender() {
err := peer.SendBuffer(elem.packet)
device.PutMessageBuffer(elem.buffer)
if err != nil {
- logDebug.Println("Failed to send authenticated packet to peer", peer.String())
+ logDebug.Println("Failed to send authenticated packet to peer", peer)
continue
}
atomic.AddUint64(&peer.stats.txBytes, length)