diff --git a/ios/PacketTunnel/PacketTunnelProvider.swift b/ios/PacketTunnel/PacketTunnelProvider.swift index e132952ee36a..910c8b2befa2 100644 --- a/ios/PacketTunnel/PacketTunnelProvider.swift +++ b/ios/PacketTunnel/PacketTunnelProvider.swift @@ -208,6 +208,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider { let selectorResult = tunnelConfiguration.selectorResult self.selectorResult = selectorResult self.providerLogger.debug("Set tunnel relay to \(selectorResult.relay.hostname).") + self.logIfDeviceHasSameIP(than: tunnelConfiguration.wgTunnelConfig.interface.addresses) // Start tunnel. self.adapter.start(tunnelConfiguration: tunnelConfiguration.wgTunnelConfig) { error in @@ -238,6 +239,16 @@ class PacketTunnelProvider: NEPacketTunnelProvider { } } + private func logIfDeviceHasSameIP(than addresses: [IPAddressRange]) { + let hasIPv4SameAddress = addresses.compactMap { $0.address as? IPv4Address } + .contains { $0 == ApplicationConfiguration.sameIPv4 } + let hasIPv6SameAddress = addresses.compactMap { $0.address as? IPv6Address } + .contains { $0 == ApplicationConfiguration.sameIPv6 } + + let isUsingSameIP = (hasIPv4SameAddress || hasIPv6SameAddress) ? "" : "NOT " + providerLogger.debug("Same IP is \(isUsingSameIP)being used") + } + override func stopTunnel(with reason: NEProviderStopReason, completionHandler: @escaping () -> Void) { dispatchQueue.async { self.providerLogger.debug("Stop the tunnel: \(reason)") diff --git a/ios/Shared/ApplicationConfiguration.swift b/ios/Shared/ApplicationConfiguration.swift index b6198b2749ce..a3af1eef75f9 100644 --- a/ios/Shared/ApplicationConfiguration.swift +++ b/ios/Shared/ApplicationConfiguration.swift @@ -7,7 +7,7 @@ // import Foundation -import struct Network.IPv4Address +import Network enum ApplicationConfiguration { /// Shared container security group identifier. @@ -37,4 +37,10 @@ enum ApplicationConfiguration { /// Maximum number of devices per account. static let maxAllowedDevices = 5 + + // FIXME: Used for debugging purposes during the migration to same IP. Remove when the migration is over. + // swiftlint disable:force_cast + static let sameIPv4 = IPv4Address("10.127.255.254")! + static let sameIPv6 = IPv6Address("fc00:bbbb:bbbb:bb01:ffff:ffff:ffff:ffff")! + // swiftlint enable:force_cast }