Skip to content

Commit

Permalink
Merge branch 'develop' into feature/v2ray
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Nov 6, 2023
2 parents ca8a1af + 9307127 commit 5e2a71e
Show file tree
Hide file tree
Showing 15 changed files with 287 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ As a contributor, here are the guidelines we would like you to follow:
## Creating an Issue

* If you want to report a security problem **DO NOT CREATE AN ISSUE**, please read our [Security Policy](/.github/SECURITY.md) on how to submit a security vulnerability.
* When creating a new issue, chose a "Bug report" or "Feature request" template and fill the required information.
* When creating a new issue, choose a "Bug report" or "Feature request" template and fill the required information.
* Please describe the steps necessary to reproduce the issue you are running into.

<a name="pr"></a>
Expand Down
4 changes: 2 additions & 2 deletions IVPNClient.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 53;
objectVersion = 54;
objects = {

/* Begin PBXBuildFile section */
Expand Down Expand Up @@ -3512,7 +3512,7 @@
repositoryURL = "https://github.com/scenee/FloatingPanel";
requirement = {
kind = exactVersion;
version = 1.7.2;
version = 2.6.3;
};
};
82EC884529A12D510024CC40 /* XCRemoteSwiftPackageReference "SnapKit" */ = {
Expand Down
62 changes: 62 additions & 0 deletions IVPNClient/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,67 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSExceptionDomains</key>
<dict>
<key>198.50.177.220</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>149.56.162.156</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>198.50.177.222</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>149.56.162.159</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>198.50.177.223</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>2607:5300:203:1735::8888</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>2607:5300:203:1735::8</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
<key>2607:5300:203:1735:6580:7300:0:aaaa</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
<key>NSExceptionMinimumTLSVersion</key>
<string>TLSv1.2</string>
</dict>
</dict>
</dict>
</dict>
</plist>
10 changes: 9 additions & 1 deletion IVPNClient/Managers/APIClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,15 @@ class APIClient: NSObject {
private var hostName = UserDefaults.shared.apiHostName

private var baseURL: URL {
return URL(string: "https://\(hostName)")!
if let url = URL(string: "https://\(hostName)") {
return url
}

if let url = URL(string: "https://[\(hostName)]") {
return url
}

return URL(string: "https://\(Config.ApiHostName)")!
}

private var userAgent: String {
Expand Down
22 changes: 18 additions & 4 deletions IVPNClient/Managers/StorageManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,21 +300,35 @@ extension StorageManager {
return nil
}

private static func probeURL() -> URL? {
let isNetworkProtection = UserDefaults.shared.networkProtectionEnabled
let probeURL = URL(string: "https://\(Config.ApiHostName)\(Config.apiServersFile)")
return isNetworkProtection ? probeURL : nil
}

private static func getDefaultOnDemandRule(status: NEVPNStatus) -> NEOnDemandRule? {
let defaultTrust = getDefaultTrust()

if defaultTrust == NetworkTrust.Untrusted.rawValue {
return NEOnDemandRuleConnect()
let onDemandRule = NEOnDemandRuleConnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
}
if defaultTrust == NetworkTrust.Trusted.rawValue {
return NEOnDemandRuleDisconnect()
let onDemandRule = NEOnDemandRuleDisconnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
}

switch status {
case .connected:
return NEOnDemandRuleConnect()
let onDemandRule = NEOnDemandRuleConnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
case .disconnected, .invalid:
return NEOnDemandRuleDisconnect()
let onDemandRule = NEOnDemandRuleDisconnect()
onDemandRule.probeURL = probeURL()
return onDemandRule
default:
return nil
}
Expand Down
22 changes: 12 additions & 10 deletions IVPNClient/Managers/VPNManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,30 @@ class VPNManager {
func installOnDemandRules(settings: ConnectionSettings, accessDetails: AccessDetails) {
switch settings {
case .ipsec:
self.disable(tunnelType: .openvpn) { _ in
disable(tunnelType: .openvpn) { _ in
self.disable(tunnelType: .wireguard) { _ in
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in
self.disconnect(tunnelType: .ipsec)
}
}
}
case .openvpn:
self.disable(tunnelType: .ipsec) { _ in
disable(tunnelType: .ipsec) { _ in
self.disable(tunnelType: .wireguard) { _ in
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in
self.disconnect(tunnelType: .openvpn)
DispatchQueue.delay(1) {
self.openvpnManager?.connection.stopVPNTunnel()
}
}
}
}
case .wireguard:
self.disable(tunnelType: .ipsec) { _ in
disable(tunnelType: .ipsec) { _ in
self.disable(tunnelType: .openvpn) { _ in
self.setup(settings: settings, accessDetails: accessDetails, status: .disconnected) { _ in
self.disconnect(tunnelType: .wireguard)
DispatchQueue.delay(1) {
self.wireguardManager?.connection.stopVPNTunnel()
}
}
}
}
Expand All @@ -272,13 +276,11 @@ class VPNManager {
}

func disconnect(tunnelType: TunnelType, reconnectAutomatically: Bool = false) {
getManagerFor(tunnelType: tunnelType) { manager in
DispatchQueue.async {
manager.connection.stopVPNTunnel()
}
getManagerFor(tunnelType: tunnelType) { [self] manager in
manager.connection.stopVPNTunnel()

if !UserDefaults.shared.networkProtectionEnabled || reconnectAutomatically {
self.removeOnDemandRule(manager: manager)
removeOnDemandRule(manager: manager)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Models/ServiceStatus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct ServiceStatus: Codable {
func isLegacyAccount() -> Bool {
let accountId = KeyChain.username ?? ""

if accountId.hasPrefix("ivpn") && currentPlan.hasPrefix("IVPN Pro") && currentPlan != "IVPN Pro" {
if accountId.hasPrefix("ivpn") && currentPlan.contains("VPN Pro") && currentPlan != "IVPN Pro" {
return true
}

Expand Down
4 changes: 2 additions & 2 deletions IVPNClient/Scenes/AccountScreen/View/AccountView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class AccountView: UITableView {
@IBOutlet weak var subscriptionLabel: UILabel!
@IBOutlet weak var activeUntilLabel: UILabel!
@IBOutlet weak var logOutActionButton: UIButton!
@IBOutlet weak var addMoreTimeButton: UIButton!
@IBOutlet weak var activeUntilCell: UITableViewCell!

// MARK: - Properties -

Expand All @@ -47,7 +47,7 @@ class AccountView: UITableView {
statusLabel.backgroundColor = viewModel.statusColor
subscriptionLabel.text = viewModel.subscriptionText
activeUntilLabel.text = viewModel.activeUntilText
addMoreTimeButton.isHidden = Application.shared.serviceStatus.isLegacyAccount()
activeUntilCell.isHidden = Application.shared.serviceStatus.isLegacyAccount()
}

func initQRCode(viewModel: AccountViewModel) {
Expand Down
Loading

0 comments on commit 5e2a71e

Please sign in to comment.