summaryrefslogtreecommitdiffhomepage
path: root/src/timers.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-10-17 16:50:23 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-10-17 16:50:23 +0200
commitfd6f2e1f554cb545c7c554b56e2ac77308822680 (patch)
tree9e382c6f549510a42f1fb9a0e8551fb96f54e7ed /src/timers.go
parente86d03dca23e5adcbd1c7bd30157bc7d19a932d7 (diff)
Fixed timer issue when failing to send handshake
+ Identified send4 issue
Diffstat (limited to 'src/timers.go')
-rw-r--r--src/timers.go27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/timers.go b/src/timers.go
index 2a94005..31165a3 100644
--- a/src/timers.go
+++ b/src/timers.go
@@ -279,34 +279,31 @@ func (peer *Peer) RoutineHandshakeInitiator() {
break AttemptHandshakes
}
- jitter := time.Millisecond * time.Duration(rand.Uint32()%334)
-
- // marshal and send
+ // marshal handshake message
writer := bytes.NewBuffer(temp[:0])
binary.Write(writer, binary.LittleEndian, msg)
packet := writer.Bytes()
peer.mac.AddMacs(packet)
+ // send to endpoint
+
err = peer.SendBuffer(packet)
- if err != nil {
+ jitter := time.Millisecond * time.Duration(rand.Uint32()%334)
+ timeout := time.NewTimer(RekeyTimeout + jitter)
+ if err == nil {
+ peer.TimerAnyAuthenticatedPacketTraversal()
+ logDebug.Println(
+ "Handshake initiation attempt",
+ attempts, "sent to", peer.String(),
+ )
+ } else {
logError.Println(
"Failed to send handshake initiation message to",
peer.String(), ":", err,
)
- continue
}
- peer.TimerAnyAuthenticatedPacketTraversal()
-
- // set handshake timeout
-
- timeout := time.NewTimer(RekeyTimeout + jitter)
- logDebug.Println(
- "Handshake initiation attempt",
- attempts, "sent to", peer.String(),
- )
-
// wait for handshake or timeout
select {