diff options
author | Roopesh Chander <roop@roopc.net> | 2018-12-21 17:32:44 +0530 |
---|---|---|
committer | Roopesh Chander <roop@roopc.net> | 2018-12-21 17:32:44 +0530 |
commit | f818cdd9631cdbe5b433aadb3af8ceab22f58c50 (patch) | |
tree | ac9f568d6221d9b67a9a54ecd01cd09977fade78 /WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift | |
parent | NE: Change handling of bad domain names and Activate On Demand (diff) | |
download | wireguard-apple-f818cdd9631cdbe5b433aadb3af8ceab22f58c50.tar.xz wireguard-apple-f818cdd9631cdbe5b433aadb3af8ceab22f58c50.zip |
NE: Update listen port only when first interface changes
When handling network path changes, change the listen port
only when the first interface has changed.
Signed-off-by: Roopesh Chander <roop@roopc.net>
Diffstat (limited to 'WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift')
-rw-r--r-- | WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift index 7ee0acc..888769d 100644 --- a/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift +++ b/WireGuard/WireGuardNetworkExtension/PacketTunnelSettingsGenerator.swift @@ -15,8 +15,16 @@ class PacketTunnelSettingsGenerator { self.resolvedEndpoints = resolvedEndpoints } - func endpointUapiConfiguration(currentListenPort: UInt16) -> String { - var wgSettings = "listen_port=\(tunnelConfiguration.interface.listenPort ?? currentListenPort)\n" + func endpointUapiConfiguration(shouldIncludeListenPort: Bool, currentListenPort: UInt16?) -> String { + var wgSettings = "" + + if shouldIncludeListenPort { + if let tunnelListenPort = tunnelConfiguration.interface.listenPort { + wgSettings.append("listen_port=\(tunnelListenPort)\n") + } else if let currentListenPort = currentListenPort { + wgSettings.append("listen_port=\(currentListenPort)\n") + } + } for (index, peer) in tunnelConfiguration.peers.enumerated() { wgSettings.append("public_key=\(peer.publicKey.hexEncodedString())\n") |