Assume stale session if server sends HARD_RESET

When unsolicited.
This commit is contained in:
Davide De Rosa 2019-07-09 11:42:12 +02:00
parent 1dcf4d7745
commit 0f2234f1d1
1 changed files with 14 additions and 5 deletions

View File

@ -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)