diff --git a/CHANGELOG.md b/CHANGELOG.md index 63303fc..223fbdc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Parse `--tun-mtu` option. + ### Changed - Update API to access current Wi-Fi SSID. diff --git a/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift b/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift index 08bcca9..6a15ae7 100644 --- a/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift +++ b/TunnelKit/Sources/Protocols/OpenVPN/ConfigurationParser.swift @@ -72,6 +72,8 @@ extension OpenVPN { static let remoteRandom = NSRegularExpression("^remote-random") + static let mtu = NSRegularExpression("^tun-mtu +\\d+") + // MARK: Server static let authToken = NSRegularExpression("^auth-token +[a-zA-Z0-9/=+]+") @@ -216,6 +218,7 @@ extension OpenVPN { var optRemotes: [(String, UInt16?, SocketType?)] = [] // address, port, socket var optChecksEKU: Bool? var optRandomizeEndpoint: Bool? + var optMTU: Int? // var optAuthToken: String? var optPeerId: UInt32? @@ -468,6 +471,13 @@ extension OpenVPN { isHandled = true optRandomizeEndpoint = true } + Regex.mtu.enumerateArguments(in: line) { + isHandled = true + guard let str = $0.first else { + return + } + optMTU = Int(str) + } // MARK: Server @@ -677,6 +687,7 @@ extension OpenVPN { sessionBuilder.checksEKU = optChecksEKU sessionBuilder.randomizeEndpoint = optRandomizeEndpoint + sessionBuilder.mtu = optMTU // MARK: Server