diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-19 13:19:07 +0100 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-11-19 13:19:07 +0100 |
commit | b5ae42349c4fd88022a63006060d72b03aa83b16 (patch) | |
tree | 18fecbdba6437003f574c15eddeb75bbed9980b3 /src/timers.go | |
parent | 5705a5e2efdcbbaffa5da00555b1afb3b4f9d2af (diff) | |
parent | 9ebab57c417d4fd19db6cf69f920a3adb1a1e092 (diff) |
Merge branch 'source-caching'
Diffstat (limited to 'src/timers.go')
-rw-r--r-- | src/timers.go | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/timers.go b/src/timers.go index 99695ba..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)
- _, err = peer.SendBuffer(packet)
- if err != nil {
+ // send to endpoint
+
+ err = peer.SendBuffer(packet)
+ 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 {
|