Only try upgrade socket on network error

This commit is contained in:
Davide De Rosa 2018-09-07 22:34:04 +02:00
parent 11419ed28a
commit de09d0b5da
1 changed files with 6 additions and 3 deletions

View File

@ -412,9 +412,6 @@ extension TunnelKitProvider: GenericSocketDelegate {
return
}
// upgrade available?
let upgradedSocket = socket.upgraded()
var shutdownError: Error?
if !failure {
shutdownError = proxy.stopError
@ -424,6 +421,12 @@ extension TunnelKitProvider: GenericSocketDelegate {
log.debug("Link failures so far: \(linkFailures) (max = \(maxLinkFailures))")
}
// only try upgrade on network errors
var upgradedSocket: GenericSocket? = nil
if shutdownError as? SessionError == nil {
upgradedSocket = socket.upgraded()
}
// treat negotiation timeout as socket timeout, UDP is connection-less
if proxy.stopError as? SessionError == SessionError.negotiationTimeout {
socketShouldChangeProtocol(socket)