Skip to content
This repository has been archived by the owner on Sep 29, 2024. It is now read-only.

Commit

Permalink
Assume stale session if server sends HARD_RESET
Browse files Browse the repository at this point in the history
When unsolicited.
  • Loading branch information
keeshux committed Jul 9, 2019
1 parent 1dcf4d7 commit 0f2234f
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions TunnelKit/Sources/Protocols/OpenVPN/OpenVPNSession.swift
Original file line number Diff line number Diff line change
Expand Up @@ -479,11 +479,20 @@ public class OpenVPNSession: Session {
// deferStop(.shutdown, e)
// return
}
if (code == .hardResetServerV2) && (negotiationKey.controlState == .connected) {
deferStop(.shutdown, OpenVPNError.staleSession)
return
} else if (code == .softResetV1) && !negotiationKey.softReset {
softReset(isServerInitiated: true)
switch code {
case .hardResetServerV2:
guard negotiationKey.state == .hardReset else {
deferStop(.shutdown, OpenVPNError.staleSession)
return
}

case .softResetV1:
if !negotiationKey.softReset {
softReset(isServerInitiated: true)
}

default:
break
}

sendAck(for: controlPacket)
Expand Down

0 comments on commit 0f2234f

Please sign in to comment.