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. /// An error occurred at the link level.
case linkError case linkError
/// Network routing information is missing or incomplete.
case routing
/// The current network changed (e.g. switched from WiFi to data connection). /// The current network changed (e.g. switched from WiFi to data connection).
case networkChanged case networkChanged

View File

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

View File

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

View File

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