Always shut down on known tunnel error

Not recoverable by default (e.g algorithm mismatch).
This commit is contained in:
Davide De Rosa 2018-09-07 23:18:28 +02:00
parent 891c72caa1
commit 01f65b2a7e

View File

@ -42,6 +42,11 @@ import __TunnelKitNative
private let log = SwiftyBeaver.self
private extension Error {
func isTunnelError() -> Bool {
let te = self as NSError
return te.domain == TunnelKitErrorDomain
}
func isDataPathOverflow() -> Bool {
let te = self as NSError
return te.domain == TunnelKitErrorDomain && te.code == TunnelKitErrorCode.dataPathOverflow.rawValue
@ -1080,7 +1085,7 @@ public class SessionProxy {
tunnel?.writePackets(decryptedPackets, completionHandler: nil)
} catch let e {
guard !e.isDataPathOverflow() else {
guard !e.isTunnelError() else {
deferStop(.shutdown, e)
return
}
@ -1115,7 +1120,7 @@ public class SessionProxy {
// log.verbose("Data: \(encryptedPackets.count) packets successfully written to LINK")
}
} catch let e {
guard !e.isDataPathOverflow() else {
guard !e.isTunnelError() else {
deferStop(.shutdown, e)
return
}