Skip to content

Commit

Permalink
Merge branch 'feature/v2ray' into staging-2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Oct 11, 2023
2 parents 034bb8f + 2ca3f27 commit eb0b2ab
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
42 changes: 37 additions & 5 deletions IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ enum ConnectionSettings {
return "OpenVPN, UDP \(port)"
}
case .wireguard(_, let port):
return "WireGuard, UDP \(port)"
return "WireGuard, \(wireguardProtocol()) \(port)"
}
}

Expand All @@ -60,8 +60,12 @@ enum ConnectionSettings {
case .udp:
return "OpenVPN, UDP"
}
case .wireguard:
return "WireGuard, UDP"
case .wireguard(_, let port):
if UserDefaults.shared.isV2ray {
return "WireGuard, \(wireguardProtocol()) \(port)"
}

return "WireGuard, \(wireguardProtocol())"
}
}

Expand Down Expand Up @@ -104,7 +108,27 @@ enum ConnectionSettings {
return "UDP \(port)"
}
case .wireguard(_, let port):
return "UDP \(port)"
return "\(wireguardProtocol()) \(port)"
}
}

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())"
}
}

Expand Down Expand Up @@ -227,8 +251,16 @@ 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 {
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 eb0b2ab

Please sign in to comment.