Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Jan 30, 2023
2 parents 9a34d46 + ff0899f commit b00f63a
Show file tree
Hide file tree
Showing 39 changed files with 775 additions and 432 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- "develop"
pull_request:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- "develop"
pull_request:

jobs:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
- "develop"
pull_request:
paths:
- '.github/workflows/swiftlint.yml'
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

All notable changes to this project will be documented in this file.

## 2.8.0 - 2023-01-30

[NEW] Favorite servers
[IMPROVED] Option to search and sort in the fastest server configuration list

## 2.7.1 - 2022-12-08

[IMPROVED] Support for Split View and Slide Over mode on iPadOS
Expand Down
182 changes: 103 additions & 79 deletions IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,15 @@ class AppDelegate: UIResponder {
private func showSecurityScreen() {
var showWindow = false

if let _ = UIApplication.topViewController() as? AccountViewController {
if UIApplication.topViewController() as? AccountViewController != nil {
showWindow = true
}

if let _ = UIApplication.topViewController() as? LoginViewController {
if UIApplication.topViewController() as? LoginViewController != nil {
showWindow = true
}

if let _ = UIApplication.topViewController() as? CreateAccountViewController {
if UIApplication.topViewController() as? CreateAccountViewController != nil {
showWindow = true
}

Expand Down Expand Up @@ -166,7 +166,7 @@ class AppDelegate: UIResponder {
}
})
case Config.urlTypeLogin:
if let _ = UIApplication.topViewController() as? LoginViewController {
if UIApplication.topViewController() as? LoginViewController != nil {
return
}

Expand All @@ -177,6 +177,99 @@ class AppDelegate: UIResponder {
break
}
}

private func userActivityConnect() {
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndConnectShortcut(closeApp: true, actionType: .connect)
return
}
Application.shared.connectionManager.connectShortcut(closeApp: true, actionType: .connect)
}
}

private func userActivityDisconnect() {
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndDisconnectShortcut(closeApp: true, actionType: .disconnect)
return
}
Application.shared.connectionManager.disconnectShortcut(closeApp: true, actionType: .disconnect)
}
}

private func userActivityAntiTrackerEnable() {
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec {
viewController.showAlert(title: "IKEv2 not supported", message: "AntiTracker is supported only for OpenVPN and WireGuard protocols.") { _ in
}
return
}

UserDefaults.shared.set(true, forKey: UserDefaults.Key.isAntiTracker)
NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil)
if UIApplication.topViewController() as? MainViewController != nil {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
}

private func userActivityAntiTrackerDisable() {
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isAntiTracker)
NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil)
if UIApplication.topViewController() as? MainViewController != nil {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
}

private func userActivityCustomDNSEnable() {
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec {
viewController.showAlert(title: "IKEv2 not supported", message: "Custom DNS is supported only for OpenVPN and WireGuard protocols.") { _ in
}
return
}

guard !UserDefaults.shared.customDNS.isEmpty else {
viewController.showAlert(title: "", message: "Please enter DNS server info")
return
}

UserDefaults.shared.set(true, forKey: UserDefaults.Key.isCustomDNS)
NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil)
if UIApplication.topViewController() as? MainViewController != nil {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
}

private func userActivityCustomDNSDisable() {
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isCustomDNS)
NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil)
if UIApplication.topViewController() as? MainViewController != nil {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
}

}

Expand Down Expand Up @@ -273,86 +366,17 @@ extension AppDelegate: UIApplicationDelegate {

switch userActivity.activityType {
case UserActivityType.Connect:
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndConnectShortcut(closeApp: true, actionType: .connect)
return
}
Application.shared.connectionManager.connectShortcut(closeApp: true, actionType: .connect)
}
userActivityConnect()
case UserActivityType.Disconnect:
DispatchQueue.delay(0.75) {
if UserDefaults.shared.networkProtectionEnabled {
Application.shared.connectionManager.resetRulesAndDisconnectShortcut(closeApp: true, actionType: .disconnect)
return
}
Application.shared.connectionManager.disconnectShortcut(closeApp: true, actionType: .disconnect)
}
userActivityDisconnect()
case UserActivityType.AntiTrackerEnable:
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec {
viewController.showAlert(title: "IKEv2 not supported", message: "AntiTracker is supported only for OpenVPN and WireGuard protocols.") { _ in
}
return
}

UserDefaults.shared.set(true, forKey: UserDefaults.Key.isAntiTracker)
NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil)
if let _ = UIApplication.topViewController() as? MainViewController {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
userActivityAntiTrackerEnable()
case UserActivityType.AntiTrackerDisable:
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isAntiTracker)
NotificationCenter.default.post(name: Notification.Name.AntiTrackerUpdated, object: nil)
if let _ = UIApplication.topViewController() as? MainViewController {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
userActivityAntiTrackerDisable()
case UserActivityType.CustomDNSEnable:
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
if Application.shared.settings.connectionProtocol.tunnelType() == .ipsec {
viewController.showAlert(title: "IKEv2 not supported", message: "Custom DNS is supported only for OpenVPN and WireGuard protocols.") { _ in
}
return
}

guard !UserDefaults.shared.customDNS.isEmpty else {
viewController.showAlert(title: "", message: "Please enter DNS server info")
return
}

UserDefaults.shared.set(true, forKey: UserDefaults.Key.isCustomDNS)
NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil)
if let _ = UIApplication.topViewController() as? MainViewController {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
userActivityCustomDNSEnable()
case UserActivityType.CustomDNSDisable:
DispatchQueue.async {
if let viewController = UIApplication.topViewController() {
UserDefaults.shared.set(false, forKey: UserDefaults.Key.isCustomDNS)
NotificationCenter.default.post(name: Notification.Name.CustomDNSUpdated, object: nil)
if let _ = UIApplication.topViewController() as? MainViewController {
NotificationCenter.default.post(name: Notification.Name.EvaluateReconnect, object: nil)
} else {
viewController.evaluateReconnect(sender: viewController.view)
}
}
}
userActivityCustomDNSDisable()
default:
log(.info, message: "No such user activity")
}
Expand Down
22 changes: 22 additions & 0 deletions IVPNClient/Assets.xcassets/favorite-server.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"images" : [
{
"filename" : "favourite-server-light.pdf",
"idiom" : "universal"
},
{
"appearances" : [
{
"appearance" : "luminosity",
"value" : "dark"
}
],
"filename" : "favourite-server-dark.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
Binary file not shown.
12 changes: 12 additions & 0 deletions IVPNClient/Assets.xcassets/icon-star-off.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "star-off.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
12 changes: 12 additions & 0 deletions IVPNClient/Assets.xcassets/icon-star-on.imageset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"images" : [
{
"filename" : "star-on.pdf",
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Binary file not shown.
2 changes: 1 addition & 1 deletion IVPNClient/Config/servers.json

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions IVPNClient/Enums/ConnectionSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ enum ConnectionSettings {
for protocolObj in protocols {
var containsProtocol = false

for filteredProtocol in filteredProtocols {
if filteredProtocol.tunnelType() == protocolObj.tunnelType() {
containsProtocol = true
}
for filteredProtocol in filteredProtocols where filteredProtocol.tunnelType() == protocolObj.tunnelType() {
containsProtocol = true
}

if !containsProtocol {
Expand All @@ -131,10 +129,8 @@ enum ConnectionSettings {
func supportedProtocols(protocols: [ConnectionSettings]) -> [ConnectionSettings] {
var filteredProtocols = [ConnectionSettings]()

for protocolObj in protocols {
if protocolObj.tunnelType() == self.tunnelType() {
filteredProtocols.append(protocolObj)
}
for protocolObj in protocols where protocolObj.tunnelType() == self.tunnelType() {
filteredProtocols.append(protocolObj)
}

return filteredProtocols
Expand Down
7 changes: 7 additions & 0 deletions IVPNClient/Enums/ServersSort.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@
import Foundation

enum ServersSort: String, CaseIterable {

case city
case country
case latency
case proximity

static func actions() -> [String] {
let actions = allCases.map { $0.rawValue }
return actions.map { $0.camelCaseToCapitalized() ?? "" }
}

}
2 changes: 1 addition & 1 deletion IVPNClient/Managers/ApiService+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ extension ApiService {

UIApplication.shared.isNetworkActivityIndicatorVisible = true

log(.info, message: "Load servers")
log(.info, message: "Load servers")

APIClient().perform(request) { result in
switch result {
Expand Down
Loading

0 comments on commit b00f63a

Please sign in to comment.