summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJon Petersson <jon.petersson@kvadrat.se>2023-12-08 12:26:20 +0100
committerJon Petersson <jon.petersson@kvadrat.se>2023-12-08 15:39:51 +0100
commit3115ad04aff2c1e568fcac7051475967b6b34e65 (patch)
treeae8405acb69d4aa8f26143759055ea5b7691c87a
parent6f66168c57c0043e27b8176cf2ee82745cedec18 (diff)
downloadmullvadvpn-3115ad04aff2c1e568fcac7051475967b6b34e65.tar.xz
mullvadvpn-3115ad04aff2c1e568fcac7051475967b6b34e65.zip
Querying the outgoing connection IP should not affect the in IP
-rw-r--r--ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift2
-rw-r--r--ios/MullvadVPN/View controllers/Tunnel/OutgoingConnectionService.swift15
-rw-r--r--ios/MullvadVPN/View controllers/Tunnel/TunnelControlViewModel.swift68
3 files changed, 47 insertions, 38 deletions
diff --git a/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift b/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift
index 31804f74b3..7908906d3b 100644
--- a/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift
+++ b/ios/MullvadVPN/View controllers/Tunnel/ConnectionPanelView.swift
@@ -124,6 +124,8 @@ class ConnectionPanelView: UIView {
private func didChangeDataSource() {
inAddressRow.value = dataSource?.inAddress
+ inAddressRow.alpha = dataSource?.inAddress == nil ? 0 : 1.0
+
outAddressRow.value = dataSource?.outAddress
outAddressRow.alpha = dataSource?.outAddress == nil ? 0 : 1.0
}
diff --git a/ios/MullvadVPN/View controllers/Tunnel/OutgoingConnectionService.swift b/ios/MullvadVPN/View controllers/Tunnel/OutgoingConnectionService.swift
index 12ed55c472..b68b6d527c 100644
--- a/ios/MullvadVPN/View controllers/Tunnel/OutgoingConnectionService.swift
+++ b/ios/MullvadVPN/View controllers/Tunnel/OutgoingConnectionService.swift
@@ -23,7 +23,7 @@ final class OutgoingConnectionService: OutgoingConnectionServiceHandling {
func getOutgoingConnectionInfo() async throws -> OutgoingConnectionInfo {
let ipv4ConnectionInfo = try await outgoingConnectionProxy.getIPV4(retryStrategy: .default)
- let ipv6ConnectionInfo = try await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry)
+ let ipv6ConnectionInfo = try? await outgoingConnectionProxy.getIPV6(retryStrategy: .noRetry)
return OutgoingConnectionInfo(ipv4: ipv4ConnectionInfo, ipv6: ipv6ConnectionInfo)
}
}
@@ -33,12 +33,17 @@ struct OutgoingConnectionInfo {
let ipv4: IPV4ConnectionData
/// IPv6 exit connection.
- let ipv6: IPV6ConnectionData
+ let ipv6: IPV6ConnectionData?
var outAddress: String? {
- let v4 = ipv4.exitIP ? "\(ipv4.ip)" : nil
- let v6 = ipv6.exitIP ? "\(ipv6.ip)" : nil
- let outAddress = [v4, v6].compactMap { $0 }.joined(separator: "\n")
+ let ipv4String = ipv4.exitIP ? "\(ipv4.ip)" : nil
+
+ var ipv6String: String?
+ if let ipv6 = ipv6, ipv6.exitIP {
+ ipv6String = "\(ipv6.ip)"
+ }
+
+ let outAddress = [ipv4String, ipv6String].compactMap { $0 }.joined(separator: "\n")
return outAddress.isEmpty ? nil : outAddress
}
}
diff --git a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlViewModel.swift b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlViewModel.swift
index f1fb518efa..833583efd3 100644
--- a/ios/MullvadVPN/View controllers/Tunnel/TunnelControlViewModel.swift
+++ b/ios/MullvadVPN/View controllers/Tunnel/TunnelControlViewModel.swift
@@ -11,60 +11,62 @@ import Foundation
struct TunnelControlViewModel {
let tunnelStatus: TunnelStatus
let secureLabelText: String
- let connectionPanel: ConnectionPanelData
let enableButtons: Bool
let city: String
let country: String
let connectedRelayName: String
+ let outgoingConnectionInfo: OutgoingConnectionInfo?
+
+ var connectionPanel: ConnectionPanelData? {
+ guard let tunnelRelay = tunnelStatus.state.relay else {
+ return nil
+ }
+
+ var portAndTransport = ""
+ if let inPort = tunnelStatus.observedState.connectionState?.remotePort {
+ let protocolLayer = tunnelStatus.observedState.connectionState?.transportLayer == .tcp ? "TCP" : "UDP"
+ portAndTransport = ":\(inPort) \(protocolLayer)"
+ }
+
+ return ConnectionPanelData(
+ inAddress: "\(tunnelRelay.endpoint.ipv4Relay.ip)\(portAndTransport)",
+ outAddress: outgoingConnectionInfo?.outAddress
+ )
+ }
+
+ static var empty: Self {
+ TunnelControlViewModel(
+ tunnelStatus: TunnelStatus(),
+ secureLabelText: "",
+ enableButtons: true,
+ city: "",
+ country: "",
+ connectedRelayName: "",
+ outgoingConnectionInfo: nil
+ )
+ }
func update(status: TunnelStatus) -> TunnelControlViewModel {
TunnelControlViewModel(
tunnelStatus: status,
secureLabelText: secureLabelText,
- connectionPanel: connectionPanel,
enableButtons: enableButtons,
city: city,
country: country,
- connectedRelayName: connectedRelayName
+ connectedRelayName: connectedRelayName,
+ outgoingConnectionInfo: nil
)
}
func update(outgoingConnectionInfo: OutgoingConnectionInfo) -> TunnelControlViewModel {
- let inPort = tunnelStatus.observedState.connectionState?.remotePort ?? 0
-
- var connectionPanelData = ConnectionPanelData(inAddress: "")
- if let tunnelRelay = tunnelStatus.state.relay {
- var protocolLayer = ""
- if case let .connected(state) = tunnelStatus.observedState {
- protocolLayer = state.transportLayer == .tcp ? "TCP" : "UDP"
- }
-
- connectionPanelData = ConnectionPanelData(
- inAddress: "\(tunnelRelay.endpoint.ipv4Relay.ip):\(inPort) \(protocolLayer)",
- outAddress: outgoingConnectionInfo.outAddress
- )
- }
-
- return TunnelControlViewModel(
+ TunnelControlViewModel(
tunnelStatus: tunnelStatus,
secureLabelText: secureLabelText,
- connectionPanel: connectionPanelData,
enableButtons: enableButtons,
city: city,
country: country,
- connectedRelayName: connectedRelayName
- )
- }
-
- static var empty: Self {
- TunnelControlViewModel(
- tunnelStatus: TunnelStatus(),
- secureLabelText: "",
- connectionPanel: ConnectionPanelData(inAddress: ""),
- enableButtons: true,
- city: "",
- country: "",
- connectedRelayName: ""
+ connectedRelayName: connectedRelayName,
+ outgoingConnectionInfo: outgoingConnectionInfo
)
}
}