Shut down when no IPv4/6 routing available

Would fake-connect without VPN icon otherwise.
This commit is contained in:
Davide De Rosa 2019-04-19 09:44:54 +02:00
parent c565e32dcd
commit 9b8be02c2a
4 changed files with 14 additions and 0 deletions

View File

@ -129,6 +129,9 @@ extension TunnelKitProvider {
/// An error occurred at the link level.
case linkError
/// Network routing information is missing or incomplete.
case routing
/// The current network changed (e.g. switched from WiFi to data connection).
case networkChanged

View File

@ -696,6 +696,9 @@ extension TunnelKitProvider {
case .failedLinkWrite:
return .linkError
case .noRouting:
return .routing
default:
return .unexpectedReply

View File

@ -76,6 +76,9 @@ public enum SessionError: String, Error {
/// Server uses compression.
case serverCompression
/// Missing routing information.
case noRouting
}
extension Error {

View File

@ -957,6 +957,11 @@ public class SessionProxy {
}
pushReply = reply
guard reply.options.ipv4 != nil || reply.options.ipv6 != nil else {
deferStop(.shutdown, SessionError.noRouting)
return
}
completeConnection()
guard let remoteAddress = link?.remoteAddress else {