aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-12-22 01:36:33 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-12-22 01:36:42 +0100
commitaede9f6e450d25a0a9cbeeea604e08ba76246869 (patch)
treebdbb3619adbf0daa6db1d7f31dee5820a4259ac5 /WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
parentFixes mock tunnels (diff)
downloadwireguard-apple-aede9f6e450d25a0a9cbeeea604e08ba76246869.tar.xz
wireguard-apple-aede9f6e450d25a0a9cbeeea604e08ba76246869.zip
Move model helpers to model directory
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/Shared/NETunnelProviderProtocol+Extension.swift')
-rw-r--r--WireGuard/Shared/NETunnelProviderProtocol+Extension.swift40
1 files changed, 0 insertions, 40 deletions
diff --git a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift b/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
deleted file mode 100644
index 258c968..0000000
--- a/WireGuard/Shared/NETunnelProviderProtocol+Extension.swift
+++ /dev/null
@@ -1,40 +0,0 @@
-// SPDX-License-Identifier: MIT
-// Copyright © 2018 WireGuard LLC. All Rights Reserved.
-
-import NetworkExtension
-
-private var tunnelNameKey: Void?
-
-extension NETunnelProviderProtocol {
-
- enum Keys: String {
- case wgQuickConfig = "WgQuickConfig"
- }
-
- convenience init?(tunnelConfiguration: TunnelConfiguration) {
- self.init()
-
- let appId = Bundle.main.bundleIdentifier!
- providerBundleIdentifier = "\(appId).network-extension"
- providerConfiguration = [Keys.wgQuickConfig.rawValue: tunnelConfiguration.asWgQuickConfig()]
-
- let endpoints = tunnelConfiguration.peers.compactMap { $0.endpoint }
- if endpoints.count == 1 {
- serverAddress = endpoints[0].stringRepresentation
- } else if endpoints.isEmpty {
- serverAddress = "Unspecified"
- } else {
- serverAddress = "Multiple endpoints"
- }
-
- //TODO(roopc): Why are we doing this? Just for kicks? Is it useful? Seems needless.
- username = tunnelConfiguration.name
- }
-
- func asTunnelConfiguration(called name: String? = nil) -> TunnelConfiguration? {
- migrateConfigurationIfNeeded()
- guard let serializedConfig = providerConfiguration?[Keys.wgQuickConfig.rawValue] as? String else { return nil }
- return try? TunnelConfiguration(fromWgQuickConfig: serializedConfig, called: name)
- }
-
-}