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,13 +479,22 @@ public class OpenVPNSession: Session {
// deferStop(.shutdown, e) // deferStop(.shutdown, e)
// return // return
} }
if (code == .hardResetServerV2) && (negotiationKey.controlState == .connected) { switch code {
case .hardResetServerV2:
guard negotiationKey.state == .hardReset else {
deferStop(.shutdown, OpenVPNError.staleSession) deferStop(.shutdown, OpenVPNError.staleSession)
return return
} else if (code == .softResetV1) && !negotiationKey.softReset { }
case .softResetV1:
if !negotiationKey.softReset {
softReset(isServerInitiated: true) softReset(isServerInitiated: true)
} }
default:
break
}
sendAck(for: controlPacket) sendAck(for: controlPacket)
let pendingInboundQueue = controlChannel.enqueueInboundPacket(packet: controlPacket) let pendingInboundQueue = controlChannel.enqueueInboundPacket(packet: controlPacket)