Skip to content

Commit

Permalink
feat: update PortViewController.swift
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Nov 2, 2023
1 parent fe1aaad commit 9d9d58c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 26 deletions.
24 changes: 1 addition & 23 deletions IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,7 @@ enum ConnectionSettings {
var filteredProtocols = [ConnectionSettings]()

for protocolObj in protocols where protocolObj.tunnelType() == self.tunnelType() {
if UserDefaults.shared.isV2ray && tunnelType() == .wireguard && UserDefaults.shared.v2rayProtocol == protocolObj.storedProtocolType().lowercased() {
if UserDefaults.shared.v2rayProtocol == protocolObj.storedProtocolType().lowercased() {
filteredProtocols.append(protocolObj)
}
} else {
filteredProtocols.append(protocolObj)
}
filteredProtocols.append(protocolObj)
}

return filteredProtocols
Expand Down Expand Up @@ -261,22 +255,6 @@ enum ConnectionSettings {
}
}

func storedProtocolType() -> String {
switch self {
case .ipsec:
return "IKEv2"
case .openvpn(let proto, _):
switch proto {
case .tcp:
return "TCP"
case .udp:
return "UDP"
}
case .wireguard:
return "UDP"
}
}

func wireguardProtocol() -> String {
if UserDefaults.shared.isV2ray && UserDefaults.shared.v2rayProtocol == "tcp" {
return "TCP"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class AdvancedViewController: UITableViewController {
// MARK: - Properties -

var protocolType: String {
return v2rayProtocolControl.selectedSegmentIndex == 1 ? "tcp" : "quic"
return v2rayProtocolControl.selectedSegmentIndex == 1 ? "tcp" : "udp"
}

// MARK: - @IBActions -
Expand Down Expand Up @@ -73,7 +73,7 @@ class AdvancedViewController: UITableViewController {
}

@IBAction func selectV2rayProtocol(_ sender: UISegmentedControl) {
let v2rayProtocol = sender.selectedSegmentIndex == 1 ? "tcp" : "quic"
let v2rayProtocol = sender.selectedSegmentIndex == 1 ? "tcp" : "udp"
UserDefaults.shared.set(v2rayProtocol, forKey: UserDefaults.Key.v2rayProtocol)

if UserDefaults.shared.isV2ray {
Expand Down
4 changes: 4 additions & 0 deletions IVPNClient/Scenes/ViewControllers/PortViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ class PortViewController: UITableViewController {
var ports = [ConnectionSettings]()
if let storedCustomPorts = StorageManager.fetchCustomPorts(vpnProtocol: selectedPort.formatTitle().lowercased()) {
for customPort in storedCustomPorts {
if UserDefaults.shared.isV2ray && Application.shared.settings.connectionProtocol.tunnelType() == .wireguard && UserDefaults.shared.v2rayProtocol != customPort.type {
continue
}

let string = "\(customPort.vpnProtocol ?? "")-\(customPort.type ?? "")-\(customPort.port)"
ports.append(ConnectionSettings.getFrom(portString: string))
}
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Utilities/Extensions/UserDefaults+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ extension UserDefaults {
}

@objc dynamic var v2rayProtocol: String {
return string(forKey: Key.v2rayProtocol) ?? "quic"
return string(forKey: Key.v2rayProtocol) ?? "udp"
}

@objc dynamic var isV2ray: Bool {
Expand Down

0 comments on commit 9d9d58c

Please sign in to comment.