Skip to content

Commit

Permalink
feat: update ConnectionSettings.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Oct 11, 2023
1 parent 9e1293b commit 2ca3f27
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
26 changes: 25 additions & 1 deletion IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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())"
}
}
Expand Down Expand Up @@ -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]()

Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Scenes/TableCells/ProtocolTableViewCell.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)])
Expand Down

0 comments on commit 2ca3f27

Please sign in to comment.