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>
This commit is contained in:
Roopesh Chander
2018-12-21 17:32:44 +05:30
parent 28ce4d5164
commit f818cdd963
2 changed files with 27 additions and 4 deletions
@@ -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")