Skip to content

Commit

Permalink
feat: update ProtocolViewController.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Sep 26, 2023
1 parent 0e3a7a5 commit 31e8336
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions IVPNClient/Scenes/ViewControllers/ProtocolViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,14 @@ class ProtocolViewController: UITableViewController {
return true
}

func validateV2ray(connectionProtocol: ConnectionSettings) -> Bool {
if UserDefaults.shared.isV2ray && connectionProtocol.tunnelType() != .wireguard {
return false
}

return true
}

func reloadTable(connectionProtocol: ConnectionSettings, indexPath: IndexPath) {
Application.shared.settings.connectionProtocol = connectionProtocol
Application.shared.serverList = VPNServerList()
Expand Down Expand Up @@ -394,6 +402,23 @@ extension ProtocolViewController {
return
}

guard validateV2ray(connectionProtocol: connectionProtocol) else {
if let cell = tableView.cellForRow(at: indexPath) {
showActionSheet(title: "To use OpenVPN or IKEv2 protocols you must turn V2Ray off", actions: ["Turn off"], sourceView: cell as UIView) { index in
switch index {
case 0:
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isV2ray)
tableView.reloadData()
default:
break
}
}
tableView.deselectRow(at: indexPath, animated: true)
}

return
}

if connectionProtocol.tunnelType() != Application.shared.settings.connectionProtocol.tunnelType() && connectionProtocol.tunnelType() == .wireguard {
if KeyChain.wgPublicKey == nil || AppKeyManager.needToRegenerate() {
keyManager.setNewKey { _, _, _ in }
Expand Down

0 comments on commit 31e8336

Please sign in to comment.