aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/WireGuardNetworkExtension
diff options
context:
space:
mode:
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension')
-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