Expose LZO framing option
This commit is contained in:
parent
8836d2b175
commit
9f54e624ee
|
@ -128,6 +128,10 @@ extension TunnelKitProvider {
|
|||
/// The MTU of the tunnel.
|
||||
public var mtu: NSNumber
|
||||
|
||||
/// Enables LZO framing (deprecated).
|
||||
@available(*, deprecated)
|
||||
public var LZOFraming: Bool
|
||||
|
||||
/// The number of seconds after which a renegotiation is started. Set to `nil` to disable renegotiation (default).
|
||||
public var renegotiatesAfterSeconds: Int?
|
||||
|
||||
|
@ -158,6 +162,7 @@ extension TunnelKitProvider {
|
|||
digest = .sha1
|
||||
ca = nil
|
||||
mtu = 1500
|
||||
LZOFraming = false
|
||||
renegotiatesAfterSeconds = nil
|
||||
shouldDebug = false
|
||||
debugLogKey = nil
|
||||
|
@ -210,6 +215,7 @@ extension TunnelKitProvider {
|
|||
self.digest = digest
|
||||
self.ca = ca
|
||||
mtu = providerConfiguration[S.mtu] as? NSNumber ?? 1500
|
||||
LZOFraming = providerConfiguration[S.LZOFraming] as? Bool ?? false
|
||||
renegotiatesAfterSeconds = providerConfiguration[S.renegotiatesAfter] as? Int
|
||||
|
||||
shouldDebug = providerConfiguration[S.debug] as? Bool ?? false
|
||||
|
@ -243,6 +249,7 @@ extension TunnelKitProvider {
|
|||
digest: digest,
|
||||
ca: ca,
|
||||
mtu: mtu,
|
||||
LZOFraming: LZOFraming,
|
||||
renegotiatesAfterSeconds: renegotiatesAfterSeconds,
|
||||
shouldDebug: shouldDebug,
|
||||
debugLogKey: shouldDebug ? debugLogKey : nil,
|
||||
|
@ -270,6 +277,8 @@ extension TunnelKitProvider {
|
|||
|
||||
static let mtu = "MTU"
|
||||
|
||||
static let LZOFraming = "LZOFraming"
|
||||
|
||||
static let renegotiatesAfter = "RenegotiatesAfter"
|
||||
|
||||
static let debug = "Debug"
|
||||
|
@ -303,6 +312,9 @@ extension TunnelKitProvider {
|
|||
/// - Seealso: `TunnelKitProvider.ConfigurationBuilder.mtu`
|
||||
public let mtu: NSNumber
|
||||
|
||||
/// - Seealso: `TunnelKitProvider.ConfigurationBuilder.LZOFraming`
|
||||
public let LZOFraming: Bool
|
||||
|
||||
/// - Seealso: `TunnelKitProvider.ConfigurationBuilder.renegotiatesAfterSeconds`
|
||||
public let renegotiatesAfterSeconds: Int?
|
||||
|
||||
|
@ -367,6 +379,9 @@ extension TunnelKitProvider {
|
|||
if let resolvedAddresses = resolvedAddresses {
|
||||
dict[S.resolvedAddresses] = resolvedAddresses
|
||||
}
|
||||
if LZOFraming {
|
||||
dict[S.LZOFraming] = LZOFraming
|
||||
}
|
||||
if let renegotiatesAfterSeconds = renegotiatesAfterSeconds {
|
||||
dict[S.renegotiatesAfter] = renegotiatesAfterSeconds
|
||||
}
|
||||
|
@ -421,6 +436,7 @@ extension TunnelKitProvider {
|
|||
log.info("CA verification: disabled")
|
||||
}
|
||||
log.info("MTU: \(mtu)")
|
||||
log.info("LZO framing: \(LZOFraming ? "enabled" : "disabled")")
|
||||
if let renegotiatesAfterSeconds = renegotiatesAfterSeconds {
|
||||
log.info("Renegotiation: \(renegotiatesAfterSeconds) seconds")
|
||||
} else {
|
||||
|
@ -461,6 +477,7 @@ extension TunnelKitProvider.Configuration: Equatable {
|
|||
(lhs.digest == rhs.digest) &&
|
||||
(lhs.ca == rhs.ca) &&
|
||||
(lhs.mtu == rhs.mtu) &&
|
||||
(lhs.LZOFraming == rhs.LZOFraming) &&
|
||||
(lhs.renegotiatesAfterSeconds == rhs.renegotiatesAfterSeconds)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -159,6 +159,7 @@ open class TunnelKitProvider: NEPacketTunnelProvider {
|
|||
sessionConfiguration.cipher = cfg.cipher
|
||||
sessionConfiguration.digest = cfg.digest
|
||||
sessionConfiguration.caPath = caPath
|
||||
sessionConfiguration.LZOFraming = cfg.LZOFraming
|
||||
if let renegotiatesAfterSeconds = cfg.renegotiatesAfterSeconds {
|
||||
sessionConfiguration.renegotiatesAfter = Double(renegotiatesAfterSeconds)
|
||||
}
|
||||
|
|
|
@ -58,6 +58,10 @@ extension SessionProxy {
|
|||
/// The path to the optional CA for TLS negotiation (PEM format).
|
||||
public var caPath: String?
|
||||
|
||||
/// Enables LZO compression framing (deprecated in OpenVPN 2.4).
|
||||
@available(*, deprecated)
|
||||
public var LZOFraming: Bool
|
||||
|
||||
/// Sends periodical keep-alive packets if set.
|
||||
public var keepAliveInterval: TimeInterval?
|
||||
|
||||
|
@ -71,6 +75,7 @@ extension SessionProxy {
|
|||
cipher = .aes128cbc
|
||||
digest = .sha1
|
||||
caPath = nil
|
||||
LZOFraming = false
|
||||
keepAliveInterval = nil
|
||||
renegotiatesAfter = nil
|
||||
}
|
||||
|
@ -87,6 +92,7 @@ extension SessionProxy {
|
|||
cipher: cipher,
|
||||
digest: digest,
|
||||
caPath: caPath,
|
||||
LZOFraming: LZOFraming,
|
||||
keepAliveInterval: keepAliveInterval,
|
||||
renegotiatesAfter: renegotiatesAfter
|
||||
)
|
||||
|
@ -111,6 +117,9 @@ extension SessionProxy {
|
|||
/// - Seealso: `SessionProxy.ConfigurationBuilder.caPath`
|
||||
public let caPath: String?
|
||||
|
||||
/// - Seealso: `SessionProxy.ConfigurationBuilder.LZOFraming`
|
||||
public let LZOFraming: Bool
|
||||
|
||||
/// - Seealso: `SessionProxy.ConfigurationBuilder.keepAliveInterval`
|
||||
public let keepAliveInterval: TimeInterval?
|
||||
|
||||
|
|
|
@ -80,8 +80,9 @@ extension SessionProxy {
|
|||
return isTLSConnected
|
||||
}
|
||||
|
||||
func startHandlingPackets(withPeerId peerId: UInt32? = nil) {
|
||||
func startHandlingPackets(withPeerId peerId: UInt32? = nil, LZOFraming: Bool = false) {
|
||||
dataPath?.setPeerId(peerId ?? PacketPeerIdDisabled)
|
||||
dataPath?.setLZOFraming(LZOFraming)
|
||||
canHandlePackets = true
|
||||
}
|
||||
|
||||
|
|
|
@ -861,7 +861,10 @@ public class SessionProxy {
|
|||
}
|
||||
|
||||
authenticator = nil
|
||||
negotiationKey.startHandlingPackets(withPeerId: peerId)
|
||||
negotiationKey.startHandlingPackets(
|
||||
withPeerId: peerId,
|
||||
LZOFraming: configuration.LZOFraming
|
||||
)
|
||||
negotiationKey.controlState = .connected
|
||||
connectedDate = Date()
|
||||
transitionKeys()
|
||||
|
|
|
@ -52,8 +52,8 @@ class DataPathEncryptionTests: XCTestCase {
|
|||
XCTAssertEqual(enc.peerId(), peerId & 0xffffff)
|
||||
XCTAssertEqual(dec.peerId(), peerId & 0xffffff)
|
||||
}
|
||||
// enc.setDeprecatedLZOFraming(true)
|
||||
// dec.setDeprecatedLZOFraming(true)
|
||||
// enc.setLZOFraming(true)
|
||||
// dec.setLZOFraming(true)
|
||||
|
||||
let payload = Data(hex: "00112233445566778899")
|
||||
let packetId: UInt32 = 0x56341200
|
||||
|
|
Loading…
Reference in New Issue