aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorAndrej Mihajlov <and@mullvad.net>2020-02-07 12:31:42 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2020-02-07 22:35:57 +0100
commit30406dec6d095db27631cdf86d8041fc7ea89624 (patch)
tree703938da0b130ceaffe13e7a89be64920066aa7e /WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
parentVersion bump (diff)
downloadwireguard-apple-30406dec6d095db27631cdf86d8041fc7ea89624.tar.xz
wireguard-apple-30406dec6d095db27631cdf86d8041fc7ea89624.zip
wireguard-go-bridge: use C string instead of gostring_t
Signed-off-by: Andrej Mihajlov <and@mullvad.net> Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift15
1 files changed, 4 insertions, 11 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index f8d87d7..fc93630 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -70,7 +70,8 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
}
ifnamePtr.deallocate()
wg_log(.info, message: "Tunnel interface is \(self.ifname ?? "unknown")")
- let handle = self.packetTunnelSettingsGenerator!.uapiConfiguration().withGoString { return wgTurnOn($0, fileDescriptor) }
+ let handle = self.packetTunnelSettingsGenerator!.uapiConfiguration()
+ .withCString { return wgTurnOn($0, fileDescriptor) }
if handle < 0 {
wg_log(.error, message: "Starting tunnel failed with wgTurnOn returning \(handle)")
errorNotifier.notify(PacketTunnelProviderError.couldNotStartBackend)
@@ -146,18 +147,10 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
#if os(iOS)
if let packetTunnelSettingsGenerator = packetTunnelSettingsGenerator {
- _ = packetTunnelSettingsGenerator.endpointUapiConfiguration().withGoString { return wgSetConfig(handle, $0) }
+ _ = packetTunnelSettingsGenerator.endpointUapiConfiguration()
+ .withCString { return wgSetConfig(handle, $0) }
}
#endif
wgBumpSockets(handle)
}
}
-
-extension String {
- func withGoString<R>(_ call: (gostring_t) -> R) -> R {
- func helper(_ pointer: UnsafePointer<Int8>?, _ call: (gostring_t) -> R) -> R {
- return call(gostring_t(p: pointer, n: utf8.count))
- }
- return helper(self, call)
- }
-}