Add MTU to OpenVPN layer
This commit is contained in:
parent
e3ce38e47e
commit
6cb04da05d
|
@ -181,6 +181,8 @@ extension OpenVPNTunnelProvider {
|
|||
|
||||
static let usesPIAPatches = "UsesPIAPatches"
|
||||
|
||||
static let mtu = "MTU"
|
||||
|
||||
static let dnsServers = "DNSServers"
|
||||
|
||||
static let searchDomains = "SearchDomains"
|
||||
|
@ -407,7 +409,6 @@ extension OpenVPNTunnelProvider {
|
|||
log.info("App version: \(appVersion)")
|
||||
}
|
||||
sessionConfiguration.print()
|
||||
log.info("\tMTU: \(mtu)")
|
||||
log.info("\tDebug: \(shouldDebug)")
|
||||
log.info("\tMasks private data: \(masksPrivateData ?? true)")
|
||||
}
|
||||
|
@ -528,6 +529,9 @@ private extension OpenVPN.Configuration {
|
|||
if let usesPIAPatches = providerConfiguration[S.usesPIAPatches] as? Bool {
|
||||
builder.usesPIAPatches = usesPIAPatches
|
||||
}
|
||||
if let mtu = providerConfiguration[S.mtu] as? Int {
|
||||
builder.mtu = mtu
|
||||
}
|
||||
if let dnsServers = providerConfiguration[S.dnsServers] as? [String] {
|
||||
builder.dnsServers = dnsServers
|
||||
}
|
||||
|
@ -614,6 +618,9 @@ private extension OpenVPN.Configuration {
|
|||
if let usesPIAPatches = usesPIAPatches {
|
||||
dict[S.usesPIAPatches] = usesPIAPatches
|
||||
}
|
||||
if let mtu = mtu {
|
||||
dict[S.mtu] = mtu
|
||||
}
|
||||
if let dnsServers = dnsServers {
|
||||
dict[S.dnsServers] = dnsServers
|
||||
}
|
||||
|
@ -718,5 +725,6 @@ private extension OpenVPN.Configuration {
|
|||
if let proxyBypassDomains = proxyBypassDomains {
|
||||
log.info("\tProxy bypass domains: \(proxyBypassDomains.maskedDescription)")
|
||||
}
|
||||
log.info("\tMTU: \(fallbackMTU)")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,10 +451,10 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
|||
return
|
||||
}
|
||||
if session.canRebindLink() {
|
||||
session.rebindLink(producer.link(withMTU: cfg.mtu))
|
||||
session.rebindLink(producer.link(withMTU: cfg.sessionConfiguration.fallbackMTU))
|
||||
reasserting = false
|
||||
} else {
|
||||
session.setLink(producer.link(withMTU: cfg.mtu))
|
||||
session.setLink(producer.link(withMTU: cfg.sessionConfiguration.fallbackMTU))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,7 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
newSettings.ipv6Settings = ipv6Settings
|
||||
newSettings.dnsSettings = dnsSettings
|
||||
newSettings.proxySettings = proxySettings
|
||||
newSettings.mtu = NSNumber(value: cfg.mtu)
|
||||
newSettings.mtu = NSNumber(value: cfg.sessionConfiguration.fallbackMTU)
|
||||
|
||||
setTunnelNetworkSettings(newSettings, completionHandler: completionHandler)
|
||||
}
|
||||
|
|
|
@ -165,6 +165,8 @@ extension OpenVPN {
|
|||
static let digest: Digest = .sha1
|
||||
|
||||
static let compressionFraming: CompressionFraming = .disabled
|
||||
|
||||
static let mtu = 1250
|
||||
}
|
||||
|
||||
/// The way to create a `Configuration` object for a `OpenVPNSession`.
|
||||
|
@ -231,6 +233,9 @@ extension OpenVPN {
|
|||
/// Server is patched for the PIA VPN provider.
|
||||
public var usesPIAPatches: Bool?
|
||||
|
||||
/// The tunnel MTU.
|
||||
public var mtu: Int?
|
||||
|
||||
// MARK: Server
|
||||
|
||||
/// The auth-token returned by the server.
|
||||
|
@ -310,6 +315,7 @@ extension OpenVPN {
|
|||
sanHost: sanHost,
|
||||
randomizeEndpoint: randomizeEndpoint,
|
||||
usesPIAPatches: usesPIAPatches,
|
||||
mtu: mtu,
|
||||
authToken: authToken,
|
||||
peerId: peerId,
|
||||
ipv4: ipv4,
|
||||
|
@ -402,6 +408,9 @@ extension OpenVPN {
|
|||
/// - Seealso: `ConfigurationBuilder.usesPIAPatches`
|
||||
public let usesPIAPatches: Bool?
|
||||
|
||||
/// - Seealso: `ConfigurationBuilder.mtu`
|
||||
public let mtu: Int?
|
||||
|
||||
/// - Seealso: `ConfigurationBuilder.authToken`
|
||||
public let authToken: String?
|
||||
|
||||
|
@ -451,6 +460,11 @@ extension OpenVPN {
|
|||
public var fallbackCompressionFraming: CompressionFraming {
|
||||
return compressionFraming ?? Fallback.compressionFraming
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public var fallbackMTU: Int {
|
||||
return mtu ?? Fallback.mtu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -484,6 +498,7 @@ extension OpenVPN.Configuration {
|
|||
builder.sanHost = sanHost
|
||||
builder.randomizeEndpoint = randomizeEndpoint
|
||||
builder.usesPIAPatches = usesPIAPatches
|
||||
builder.mtu = mtu
|
||||
builder.authToken = authToken
|
||||
builder.peerId = peerId
|
||||
builder.ipv4 = ipv4
|
||||
|
|
Loading…
Reference in New Issue