From 9e1293ba867fb8dc9cf5ebeb5fc5a1dcc9a1e9ec Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Wed, 11 Oct 2023 14:19:24 +0200 Subject: [PATCH 1/2] feat: update ConnectionSettings.swift --- IVPNClient/Enums/ConnectionSettings.swift | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/IVPNClient/Enums/ConnectionSettings.swift b/IVPNClient/Enums/ConnectionSettings.swift index 848b4c066..053e0591b 100644 --- a/IVPNClient/Enums/ConnectionSettings.swift +++ b/IVPNClient/Enums/ConnectionSettings.swift @@ -45,7 +45,7 @@ enum ConnectionSettings { return "OpenVPN, UDP \(port)" } case .wireguard(_, let port): - return "WireGuard, UDP \(port)" + return "WireGuard, \(wireguardProtocol()) \(port)" } } @@ -61,7 +61,7 @@ enum ConnectionSettings { return "OpenVPN, UDP" } case .wireguard: - return "WireGuard, UDP" + return "WireGuard, \(wireguardProtocol())" } } @@ -104,7 +104,7 @@ enum ConnectionSettings { return "UDP \(port)" } case .wireguard(_, let port): - return "UDP \(port)" + return "\(wireguardProtocol()) \(port)" } } @@ -227,10 +227,18 @@ enum ConnectionSettings { return "UDP" } case .wireguard: - return "UDP" + return wireguardProtocol() } } + func wireguardProtocol() -> String { + if UserDefaults.shared.isV2ray && UserDefaults.shared.v2rayProtocol == "tcp" { + return "TCP" + } + + return "UDP" + } + static func == (lhs: ConnectionSettings, rhs: ConnectionSettings) -> Bool { switch (lhs, rhs) { case (.ipsec, .ipsec): From 2ca3f27421291cb8488730c2c14a7a0ca38c3e1a Mon Sep 17 00:00:00 2001 From: Juraj Hilje Date: Wed, 11 Oct 2023 14:34:49 +0200 Subject: [PATCH 2/2] feat: update ConnectionSettings.swift --- IVPNClient/Enums/ConnectionSettings.swift | 26 ++++++++++++++++++- .../TableCells/ProtocolTableViewCell.swift | 2 +- .../ProtocolViewController.swift | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/IVPNClient/Enums/ConnectionSettings.swift b/IVPNClient/Enums/ConnectionSettings.swift index 053e0591b..9779a45bc 100644 --- a/IVPNClient/Enums/ConnectionSettings.swift +++ b/IVPNClient/Enums/ConnectionSettings.swift @@ -60,7 +60,11 @@ enum ConnectionSettings { case .udp: return "OpenVPN, UDP" } - case .wireguard: + case .wireguard(_, let port): + if UserDefaults.shared.isV2ray { + return "WireGuard, \(wireguardProtocol()) \(port)" + } + return "WireGuard, \(wireguardProtocol())" } } @@ -108,6 +112,26 @@ enum ConnectionSettings { } } + func formatProtocolMultiHop() -> String { + switch self { + case .ipsec: + return "IKEv2" + case .openvpn(let proto, _): + switch proto { + case .tcp: + return "TCP" + case .udp: + return "UDP" + } + case .wireguard(_, let port): + if UserDefaults.shared.isV2ray { + return "\(wireguardProtocol()) \(port)" + } + + return "\(wireguardProtocol())" + } + } + static func tunnelTypes(protocols: [ConnectionSettings]) -> [ConnectionSettings] { var filteredProtocols = [ConnectionSettings]() diff --git a/IVPNClient/Scenes/TableCells/ProtocolTableViewCell.swift b/IVPNClient/Scenes/TableCells/ProtocolTableViewCell.swift index 39b9e1684..9d09a37c0 100644 --- a/IVPNClient/Scenes/TableCells/ProtocolTableViewCell.swift +++ b/IVPNClient/Scenes/TableCells/ProtocolTableViewCell.swift @@ -94,7 +94,7 @@ class ProtocolTableViewCell: UITableViewCell { private func setupSelectAction(title: String) { protocolLabel.text = title - protocolSettingsLabel.text = UserDefaults.shared.isMultiHop ? Application.shared.settings.connectionProtocol.protocolType() : Application.shared.settings.connectionProtocol.formatProtocol() + protocolSettingsLabel.text = UserDefaults.shared.isMultiHop ? Application.shared.settings.connectionProtocol.formatProtocolMultiHop() : Application.shared.settings.connectionProtocol.formatProtocol() accessoryType = .disclosureIndicator isUserInteractionEnabled = true selectionStyle = .default diff --git a/IVPNClient/Scenes/ViewControllers/ProtocolViewController.swift b/IVPNClient/Scenes/ViewControllers/ProtocolViewController.swift index 57349e3c8..a3fa3166a 100644 --- a/IVPNClient/Scenes/ViewControllers/ProtocolViewController.swift +++ b/IVPNClient/Scenes/ViewControllers/ProtocolViewController.swift @@ -69,7 +69,7 @@ class ProtocolViewController: UITableViewController { collection.append(ConnectionSettings.tunnelTypes(protocols: Config.supportedProtocolTypes)) if connectionProtocol.tunnelType() == .wireguard { - if UserDefaults.shared.isMultiHop { + if UserDefaults.shared.isMultiHop && !UserDefaults.shared.isV2ray { collection.append([.wireguard(.udp, 1), .wireguard(.udp, 2)]) } else { collection.append([.wireguard(.udp, 0), .wireguard(.udp, 1), .wireguard(.udp, 2)])