aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2019-01-24 00:00:46 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2019-01-24 01:37:57 +0100
commit22625e8cc4792a71174af5fc69f0f63ba4b808d8 (patch)
tree2907ae3cde1b5d61acc831374058e9c4bde4b9f0 /WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
parentwireguard-go-bridge: allow querying internal settings (diff)
downloadwireguard-apple-22625e8cc4792a71174af5fc69f0f63ba4b808d8.tar.xz
wireguard-apple-22625e8cc4792a71174af5fc69f0f63ba4b808d8.zip
Tunnel: support getting runtime configuration
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Diffstat (limited to '')
-rw-r--r--WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift18
1 files changed, 18 insertions, 0 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
index 7c84491a..5ac6b282 100644
--- a/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
+++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelProvider.swift
@@ -97,6 +97,24 @@ class PacketTunnelProvider: NEPacketTunnelProvider {
completionHandler()
}
+ override func handleAppMessage(_ messageData: Data, completionHandler: ((Data?) -> Void)? = nil) {
+ guard let completionHandler = completionHandler else { return }
+ guard let handle = handle else {
+ completionHandler(nil)
+ return
+ }
+ if messageData.count == 1 && messageData[0] == 0 {
+ guard let settings = wgGetConfig(handle) else {
+ completionHandler(nil)
+ return
+ }
+ completionHandler(String(cString: settings).data(using: .utf8)!)
+ free(settings)
+ } else {
+ completionHandler(nil)
+ }
+ }
+
private func configureLogger() {
Logger.configureGlobal(withFilePath: FileManager.networkExtensionLogFileURL?.path)
wgSetLogger { level, msgC in