Use MTU configuration for the link instead

Raise default link MTU from 1000 to 1250. Keep default for
tunnel MTU.
This commit is contained in:
Davide De Rosa 2018-08-24 12:33:52 +02:00
parent 6208fe8e21
commit 54cc811e47
3 changed files with 7 additions and 8 deletions

View File

@ -125,8 +125,8 @@ extension TunnelKitProvider {
/// The optional CA certificate to validate server against. Set to `nil` to disable CA validation (default).
public var ca: Certificate?
/// The MTU of the tunnel.
public var mtu: NSNumber
/// The MTU of the link.
public var mtu: Int
/// Enables LZO framing (deprecated).
// @available(*, deprecated)
@ -214,7 +214,7 @@ extension TunnelKitProvider {
self.cipher = cipher
self.digest = digest
self.ca = ca
mtu = providerConfiguration[S.mtu] as? NSNumber ?? 1500
mtu = providerConfiguration[S.mtu] as? Int ?? 1250
LZOFraming = providerConfiguration[S.LZOFraming] as? Bool ?? false
renegotiatesAfterSeconds = providerConfiguration[S.renegotiatesAfter] as? Int
@ -310,7 +310,7 @@ extension TunnelKitProvider {
public let ca: Certificate?
/// - Seealso: `TunnelKitProvider.ConfigurationBuilder.mtu`
public let mtu: NSNumber
public let mtu: Int
/// - Seealso: `TunnelKitProvider.ConfigurationBuilder.LZOFraming`
public let LZOFraming: Bool

View File

@ -335,10 +335,10 @@ extension TunnelKitProvider: GenericSocketDelegate {
return
}
if proxy.canRebindLink() {
proxy.rebindLink(socket.link(withMTU: 1000))
proxy.rebindLink(socket.link(withMTU: cfg.mtu))
reasserting = false
} else {
proxy.setLink(socket.link(withMTU: 1000))
proxy.setLink(socket.link(withMTU: cfg.mtu))
}
}
@ -446,7 +446,6 @@ extension TunnelKitProvider: SessionProxyDelegate {
let newSettings = NEPacketTunnelNetworkSettings(tunnelRemoteAddress: tunnel)
newSettings.ipv4Settings = ipv4Settings
newSettings.dnsSettings = dnsSettings
newSettings.mtu = cfg.mtu
setTunnelNetworkSettings(newSettings, completionHandler: completionHandler)
}

View File

@ -59,7 +59,7 @@ class AppExtensionTests: XCTestCase {
XCTAssertEqual(proto?.providerConfiguration?[K.cipherAlgorithm] as? String, cfg.cipher.rawValue)
XCTAssertEqual(proto?.providerConfiguration?[K.digestAlgorithm] as? String, cfg.digest.rawValue)
XCTAssertEqual(proto?.providerConfiguration?[K.ca] as? String, cfg.ca?.pem)
XCTAssertEqual(proto?.providerConfiguration?[K.mtu] as? NSNumber, cfg.mtu)
XCTAssertEqual(proto?.providerConfiguration?[K.mtu] as? Int, cfg.mtu)
XCTAssertEqual(proto?.providerConfiguration?[K.renegotiatesAfter] as? Int, cfg.renegotiatesAfterSeconds)
XCTAssertEqual(proto?.providerConfiguration?[K.debug] as? Bool, cfg.shouldDebug)
XCTAssertEqual(proto?.providerConfiguration?[K.debugLogKey] as? String, cfg.debugLogKey)