Default to unspecified MTU
Hardcode control channel packets to 1000 bytes.
This commit is contained in:
parent
1966143fe9
commit
e923382c81
|
@ -30,8 +30,6 @@ public protocol LinkProducer {
|
|||
|
||||
/**
|
||||
Returns a `LinkInterface`.
|
||||
|
||||
- Parameter mtu: The MTU value.
|
||||
**/
|
||||
func link(withMTU mtu: Int) -> LinkInterface
|
||||
func link() -> LinkInterface
|
||||
}
|
||||
|
|
|
@ -45,9 +45,6 @@ public protocol LinkInterface: IOInterface {
|
|||
/// The literal address of the remote host.
|
||||
var remoteAddress: String? { get }
|
||||
|
||||
/// The maximum size of a packet.
|
||||
var mtu: Int { get }
|
||||
|
||||
/// The number of packets that this interface is able to bufferize.
|
||||
var packetBufferSize: Int { get }
|
||||
}
|
||||
|
|
|
@ -32,9 +32,8 @@ class NETCPLink: LinkInterface {
|
|||
|
||||
private let maxPacketSize: Int
|
||||
|
||||
init(impl: NWTCPConnection, mtu: Int, maxPacketSize: Int? = nil) {
|
||||
init(impl: NWTCPConnection, maxPacketSize: Int? = nil) {
|
||||
self.impl = impl
|
||||
self.mtu = mtu
|
||||
self.maxPacketSize = maxPacketSize ?? (512 * 1024)
|
||||
}
|
||||
|
||||
|
@ -46,8 +45,6 @@ class NETCPLink: LinkInterface {
|
|||
return (impl.remoteAddress as? NWHostEndpoint)?.hostname
|
||||
}
|
||||
|
||||
let mtu: Int
|
||||
|
||||
var packetBufferSize: Int {
|
||||
return maxPacketSize
|
||||
}
|
||||
|
@ -98,7 +95,7 @@ class NETCPLink: LinkInterface {
|
|||
|
||||
/// :nodoc:
|
||||
extension NETCPSocket: LinkProducer {
|
||||
public func link(withMTU mtu: Int) -> LinkInterface {
|
||||
return NETCPLink(impl: impl, mtu: mtu)
|
||||
public func link() -> LinkInterface {
|
||||
return NETCPLink(impl: impl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,8 @@ class NEUDPLink: LinkInterface {
|
|||
|
||||
private let maxDatagrams: Int
|
||||
|
||||
init(impl: NWUDPSession, mtu: Int, maxDatagrams: Int? = nil) {
|
||||
init(impl: NWUDPSession, maxDatagrams: Int? = nil) {
|
||||
self.impl = impl
|
||||
self.mtu = mtu
|
||||
self.maxDatagrams = maxDatagrams ?? 200
|
||||
}
|
||||
|
||||
|
@ -45,8 +44,6 @@ class NEUDPLink: LinkInterface {
|
|||
return (impl.resolvedEndpoint as? NWHostEndpoint)?.hostname
|
||||
}
|
||||
|
||||
let mtu: Int
|
||||
|
||||
var packetBufferSize: Int {
|
||||
return maxDatagrams
|
||||
}
|
||||
|
@ -79,7 +76,7 @@ class NEUDPLink: LinkInterface {
|
|||
|
||||
/// :nodoc:
|
||||
extension NEUDPSocket: LinkProducer {
|
||||
public func link(withMTU mtu: Int) -> LinkInterface {
|
||||
return NEUDPLink(impl: impl, mtu: mtu)
|
||||
public func link() -> LinkInterface {
|
||||
return NEUDPLink(impl: impl)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -725,6 +725,10 @@ private extension OpenVPN.Configuration {
|
|||
if let proxyBypassDomains = proxyBypassDomains {
|
||||
log.info("\tProxy bypass domains: \(proxyBypassDomains.maskedDescription)")
|
||||
}
|
||||
log.info("\tMTU: \(fallbackMTU)")
|
||||
if let mtu = mtu {
|
||||
log.info("\tMTU: \(mtu)")
|
||||
} else {
|
||||
log.info("\tMTU: default")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -451,10 +451,10 @@ extension OpenVPNTunnelProvider: GenericSocketDelegate {
|
|||
return
|
||||
}
|
||||
if session.canRebindLink() {
|
||||
session.rebindLink(producer.link(withMTU: cfg.sessionConfiguration.fallbackMTU))
|
||||
session.rebindLink(producer.link())
|
||||
reasserting = false
|
||||
} else {
|
||||
session.setLink(producer.link(withMTU: cfg.sessionConfiguration.fallbackMTU))
|
||||
session.setLink(producer.link())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -788,7 +788,9 @@ extension OpenVPNTunnelProvider: OpenVPNSessionDelegate {
|
|||
newSettings.ipv6Settings = ipv6Settings
|
||||
newSettings.dnsSettings = dnsSettings
|
||||
newSettings.proxySettings = proxySettings
|
||||
newSettings.mtu = NSNumber(value: cfg.sessionConfiguration.fallbackMTU)
|
||||
if let mtu = cfg.sessionConfiguration.mtu {
|
||||
newSettings.mtu = NSNumber(value: mtu)
|
||||
}
|
||||
|
||||
setTunnelNetworkSettings(newSettings, completionHandler: completionHandler)
|
||||
}
|
||||
|
|
|
@ -165,8 +165,6 @@ 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`.
|
||||
|
@ -460,11 +458,6 @@ extension OpenVPN {
|
|||
public var fallbackCompressionFraming: CompressionFraming {
|
||||
return compressionFraming ?? Fallback.compressionFraming
|
||||
}
|
||||
|
||||
/// :nodoc:
|
||||
public var fallbackMTU: Int {
|
||||
return mtu ?? Fallback.mtu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1015,12 +1015,12 @@ public class OpenVPNSession: Session {
|
|||
|
||||
// Ruby: q_ctrl
|
||||
private func enqueueControlPackets(code: PacketCode, key: UInt8, payload: Data) {
|
||||
guard let link = link else {
|
||||
guard let _ = link else {
|
||||
log.warning("Not writing to LINK, interface is down")
|
||||
return
|
||||
}
|
||||
|
||||
controlChannel.enqueueOutboundPackets(withCode: code, key: key, payload: payload, maxPacketSize: link.mtu)
|
||||
controlChannel.enqueueOutboundPackets(withCode: code, key: key, payload: payload, maxPacketSize: 1000)
|
||||
flushControlQueue()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue