Move OpenVPN timeouts out of Core

This commit is contained in:
Davide De Rosa 2019-05-19 12:39:20 +02:00
parent 5b81aa6a78
commit 930f05c984
5 changed files with 6 additions and 16 deletions

View File

@ -200,10 +200,6 @@ class NETCPLink: LinkInterface {
return maxPacketSize
}
let negotiationTimeout: TimeInterval = 60.0
let hardResetTimeout: TimeInterval = 20.0
func setReadHandler(queue: DispatchQueue, _ handler: @escaping ([Data]?, Error?) -> Void) {
loopReadPackets(queue, Data(), handler)
}

View File

@ -202,10 +202,6 @@ class NEUDPLink: LinkInterface {
return maxDatagrams
}
let negotiationTimeout: TimeInterval = 10.0
let hardResetTimeout: TimeInterval = 5.0
func setReadHandler(queue: DispatchQueue, _ handler: @escaping ([Data]?, Error?) -> Void) {
// WARNING: runs in Network.framework queue

View File

@ -50,10 +50,4 @@ public protocol LinkInterface: IOInterface {
/// The number of packets that this interface is able to bufferize.
var packetBufferSize: Int { get }
/// Timeout in seconds for negotiation start.
var negotiationTimeout: TimeInterval { get }
/// Timeout in seconds for HARD_RESET response.
var hardResetTimeout: TimeInterval { get }
}

View File

@ -44,7 +44,11 @@ extension CoreConfiguration {
// MARK: Session
static let usesReplayProtection = true
static let negotiationTimeout = 30.0
static let hardResetTimeout = 10.0
static let tickInterval = 0.2
static let pushRequestInterval = 2.0

View File

@ -85,12 +85,12 @@ extension SessionProxy {
// Ruby: Key.hard_reset_timeout
func didHardResetTimeOut(link: LinkInterface) -> Bool {
return ((state == .hardReset) && (-startTime.timeIntervalSinceNow > link.hardResetTimeout))
return ((state == .hardReset) && (-startTime.timeIntervalSinceNow > CoreConfiguration.OpenVPN.hardResetTimeout))
}
// Ruby: Key.negotiate_timeout
func didNegotiationTimeOut(link: LinkInterface) -> Bool {
let timeout = (softReset ? CoreConfiguration.OpenVPN.softNegotiationTimeout : link.negotiationTimeout)
let timeout = (softReset ? CoreConfiguration.OpenVPN.softNegotiationTimeout : CoreConfiguration.OpenVPN.negotiationTimeout)
return ((controlState != .connected) && (-startTime.timeIntervalSinceNow > timeout))
}