diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-10-17 16:50:23 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-10-17 16:50:23 +0200 |
commit | fd6f2e1f554cb545c7c554b56e2ac77308822680 (patch) | |
tree | 9e382c6f549510a42f1fb9a0e8551fb96f54e7ed /src/timers.go | |
parent | e86d03dca23e5adcbd1c7bd30157bc7d19a932d7 (diff) |
Fixed timer issue when failing to send handshake
+ Identified send4 issue
Diffstat (limited to 'src/timers.go')
-rw-r--r-- | src/timers.go | 27 |
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 {
|