Fix function length warning.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jeroen Leenarts 2018-09-26 11:22:54 +02:00
parent cc4bd254a2
commit bd9d676c8f
1 changed files with 14 additions and 6 deletions

View File

@ -14,8 +14,20 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
// MARK: Properties
var wgHandle: Int32?
var wgContext: WireGuardContext?
private var wgHandle: Int32?
private var wgContext: WireGuardContext?
private var config: NETunnelProviderProtocol {
return self.protocolConfiguration as! NETunnelProviderProtocol // swiftlint:disable:this force_cast
}
private var interfaceName: String {
return config.providerConfiguration![PCKeys.title.rawValue]! as! String // swiftlint:disable:this force_cast
}
private var settings: String {
return config.providerConfiguration![PCKeys.settings.rawValue]! as! String // swiftlint:disable:this force_cast
}
// MARK: NEPacketTunnelProvider
@ -23,10 +35,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
override func startTunnel(options: [String: NSObject]?, completionHandler startTunnelCompletionHandler: @escaping (Error?) -> Void) {
os_log("Starting tunnel", log: Log.general, type: .info)
let config = self.protocolConfiguration as! NETunnelProviderProtocol // swiftlint:disable:this force_cast
let interfaceName = config.providerConfiguration![PCKeys.title.rawValue]! as! String // swiftlint:disable:this force_cast
let settings = config.providerConfiguration![PCKeys.settings.rawValue]! as! String // swiftlint:disable:this force_cast
let validatedEndpoints = (config.providerConfiguration?[PCKeys.endpoints.rawValue] as? String ?? "").commaSeparatedToArray().compactMap { try? Endpoint(endpointString: String($0)) }.compactMap {$0}
let validatedAddresses = (config.providerConfiguration?[PCKeys.addresses.rawValue] as? String ?? "").commaSeparatedToArray().compactMap { try? CIDRAddress(stringRepresentation: String($0)) }.compactMap { $0 }