Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jurajhilje committed Dec 8, 2022
2 parents 15b1841 + 30b72e6 commit 675de27
Show file tree
Hide file tree
Showing 45 changed files with 449 additions and 396 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

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

## 2.7.1 - 2022-12-08

[IMPROVED] Support for Split View and Slide Over mode on iPadOS
[IMPROVED] Upgraded app diagnostic logs
[FIXED] Crash on app launch caused by Ping service
[FIXED] Montreal location not showing all available hosts
[FIXED] Minor bug fixes

## 2.7.0 - 2022-11-23

[NEW] Ability to connect to a specific host in a location
Expand Down
52 changes: 13 additions & 39 deletions IVPNClient.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion IVPNClient/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,10 @@ class AppDelegate: UIResponder {
}
})
case Config.urlTypeLogin:
if let _ = UIApplication.topViewController() as? LoginViewController {
return
}

if let topViewController = UIApplication.topViewController() {
topViewController.present(NavigationManager.getLoginViewController(), animated: true, completion: nil)
}
Expand Down Expand Up @@ -350,7 +354,7 @@ extension AppDelegate: UIApplicationDelegate {
}
}
default:
log(info: "No such user activity")
log(.info, message: "No such user activity")
}

return false
Expand Down
1 change: 1 addition & 0 deletions IVPNClient/Config/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ struct Config {

// Files and Directories
static let serversListCacheFileName = "servers_cache1.json"
static let appLogFile = "AppLogs.txt"
static let openVPNLogFile = "OpenVPNLogs.txt"
static let wireGuardLogFile = "WireGuardLogs.txt"

Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Config/servers.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion IVPNClient/IVPNClient-Bridging-Header.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#include "../WireGuardKitC/WireGuardKitC.h"
#include "../wireguard-tunnel-provider/WireGuard/Shared/Logging/ringlogger.h"
#include "Utilities/Logging/ringlogger.h"
8 changes: 4 additions & 4 deletions 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: "Fetching servers list...")
log(.info, message: "Load servers")

APIClient().perform(request) { result in
switch result {
Expand All @@ -47,16 +47,16 @@ extension ApiService {
let serversList = VPNServerList(withJSONData: data, storeInCache: storeInCache)

if serversList.servers.count > 0 {
log(info: "Fetching servers list completed successfully")
log(.info, message: "Load servers success")
completion(.success(serversList))
return
}
}

log(info: "Error updating servers list (probably parsing error)")
log(.info, message: "Load servers error (probably parsing error)")
completion(.error)
case .failure:
log(info: "Error fetching servers list")
log(.info, message: "Load servers error")
completion(.error)
}
}
Expand Down
20 changes: 10 additions & 10 deletions IVPNClient/Managers/ApiService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ApiService {

UIApplication.shared.isNetworkActivityIndicatorVisible = true

log(info: "\(requestName) started")
log(.info, message: "\(requestName) started")

APIClient().perform(request) { result in
DispatchQueue.main.async {
Expand All @@ -64,23 +64,23 @@ class ApiService {
do {
let successResponse = try decoder.decode(T.self, from: data)
completion(.success(successResponse))
log(info: "\(requestName) success")
log(.info, message: "\(requestName) success")
return
} catch {}

do {
let errorResponse = try decoder.decode(ErrorResult.self, from: data)
let error = self.getServiceError(message: errorResponse.message, code: errorResponse.status)
completion(.failure(error))
log(info: "\(requestName) error response")
log(.info, message: "\(requestName) error response")
return
} catch {}
}

completion(.failure(nil))
log(info: "\(requestName) parse error")
log(.info, message: "\(requestName) parse error")
case .failure(let error):
log(info: "\(requestName) failure")
log(.info, message: "\(requestName) failure")
completion(.failure(error))
}
}
Expand All @@ -97,7 +97,7 @@ class ApiService {

UIApplication.shared.isNetworkActivityIndicatorVisible = true

log(info: "\(requestName) started")
log(.info, message: "\(requestName) started")

APIClient().perform(request) { result in
DispatchQueue.main.async {
Expand All @@ -112,22 +112,22 @@ class ApiService {
do {
let successResponse = try decoder.decode(T.self, from: data)
completion(.success(successResponse))
log(info: "\(requestName) success")
log(.info, message: "\(requestName) success")
return
} catch {}

do {
let errorResponse = try decoder.decode(E.self, from: data)
completion(.failure(errorResponse))
log(info: "\(requestName) error response")
log(.info, message: "\(requestName) error response")
return
} catch {}
}

completion(.failure(nil))
log(info: "\(requestName) parse error")
log(.info, message: "\(requestName) parse error")
case .failure:
log(info: "\(requestName) failure")
log(.info, message: "\(requestName) failure")
completion(.failure(nil))
}
}
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Managers/ConnectionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ class ConnectionManager {
return
}

log(info: "Evaluating VPN connection for Network Protection")
log(.info, message: "Evaluating VPN connection for Network Protection")

guard let networkTrust = Application.shared.network.trust else {
return
Expand Down
19 changes: 12 additions & 7 deletions IVPNClient/Managers/FileSystemManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ class FileSystemManager {
do {
try FileManager.default.removeItem(at: fileNameUrl)
} catch {
log(error: "There was an error deleting file URL \(fileNameUrl). Error: \(error)")
log(.error, message: "There was an error deleting file URL \(fileNameUrl). Error: \(error)")
}
}

static func loadDataFromResource(resourceName: String, resourceType: String, bundle: Bundle? = nil) -> Data? {
let bundle = bundle ?? Bundle.main
let bundle = bundle ?? Bundle.main
let resource = bundle.path(forResource: resourceName, ofType: resourceType)

guard resource != nil else {
log(error: "Cannot read defaults file")
log(.error, message: "Cannot read defaults file")
return nil
}

Expand All @@ -63,14 +63,15 @@ class FileSystemManager {
let data = try? Data(contentsOf: resource)

guard data != nil else {
log(error: "Cannot initialize data from the resource file: \(resource)")
log(.error, message: "Cannot initialize data from the resource file: \(resource)")
return nil
}

return data
}

static func clearSession() {
resetLogFile(name: Config.appLogFile)
resetLogFile(name: Config.openVPNLogFile)
resetLogFile(name: Config.wireGuardLogFile)
}
Expand All @@ -83,7 +84,7 @@ class FileSystemManager {
if !FileManager.default.fileExists(atPath: file) {
FileManager.default.createFile(atPath: file, contents: nil, attributes: nil)
} else {
log(error: "File is already created")
log(.error, message: "File is already created")
}
}

Expand Down Expand Up @@ -111,7 +112,7 @@ class FileSystemManager {
do {
try textToWrite.write(to: file, atomically: false, encoding: String.Encoding.utf8)
} catch let error {
log(error: "Something went wrong: \(error)")
log(.error, message: "Something went wrong: \(error)")
}
}

Expand All @@ -120,7 +121,7 @@ class FileSystemManager {
createSharedFile(name: name)
}

writeToSharedFile(text: "\(Date.logTime()) \(UIDevice.logInfo())\n", name: name)
writeToSharedFile(text: "\(UIDevice.logInfo())\n", name: name)
}

static func updateLogFile(newestLog: String?, name: String, isLoggedIn: Bool) {
Expand All @@ -136,6 +137,10 @@ class FileSystemManager {
}

static func createLogFiles() {
if fileExists(name: Config.appLogFile) {
resetLogFile(name: Config.appLogFile)
}

if fileExists(name: Config.openVPNLogFile) {
resetLogFile(name: Config.openVPNLogFile)
}
Expand Down
32 changes: 16 additions & 16 deletions IVPNClient/Managers/IAPManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ class IAPManager {
if !result.retrievedProducts.isEmpty {
self.products = Array(result.retrievedProducts)
completion(Array(result.retrievedProducts), nil)
log(info: "Products successfully fetched from App Store.")
log(.info, message: "Products successfully fetched from App Store.")
} else if !result.invalidProductIDs.isEmpty {
completion(nil, "Invalid product identifier")
log(info: "Invalid App Store product identifier.")
log(.info, message: "Invalid App Store product identifier.")
} else {
completion(nil, String(describing: result.error))
log(info: "There was an error with fetching products from App Store.")
log(.info, message: "There was an error with fetching products from App Store.")
}
}
}
Expand All @@ -70,7 +70,7 @@ class IAPManager {
switch result {
case .success(let purchase):
completion(purchase, nil)
log(info: "Product was successfully purchased.")
log(.info, message: "Product was successfully purchased.")
case .error(let error):
switch error.code {
case .unknown: completion(nil, "Unknown error. Please contact support")
Expand All @@ -84,7 +84,7 @@ class IAPManager {
case .cloudServiceRevoked: completion(nil, "User has revoked permission to use this cloud service")
default: completion(nil, (error as NSError).localizedDescription)
}
log(error: "There was an error with purchase.")
log(.error, message: "There was an error with purchase.")
}
}
}
Expand All @@ -103,24 +103,24 @@ class IAPManager {
if let restoreError = results.restoreFailedPurchases.first {
let error = ErrorResult(status: 500, message: restoreError.0.localizedDescription)
completion(nil, error)
log(error: restoreError.0.localizedDescription)
log(.error, message: restoreError.0.localizedDescription)
return
}

let error = ErrorResult(status: 500, message: "Unknown error")
completion(nil, error)
log(error: "Unknown error")
log(.error, message: "Unknown error")
} else if results.restoredPurchases.count > 0 {
var purchases = results.restoredPurchases
purchases.sort { $0.transaction.transactionDate! > $1.transaction.transactionDate! }
self.completeRestoredPurchase(purchase: purchases.first!) { account, error in
completion(account, error)
log(info: "Purchases are restored.")
log(.info, message: "Purchases are restored.")
}
} else {
let error = ErrorResult(status: 500, message: "There are no purchases to restore.")
completion(nil, error)
log(error: "There are no purchases to restore.")
log(.error, message: "There are no purchases to restore.")
}
}
}
Expand All @@ -138,18 +138,18 @@ class IAPManager {
}
Application.shared.serviceStatus = sessionStatus.serviceStatus
completion(sessionStatus.serviceStatus, nil)
log(info: "Purchase was successfully finished.")
log(.info, message: "Purchase was successfully finished.")
case .failure(let error):
let defaultErrorResult = ErrorResult(status: 500, message: "Purchase was completed but service cannot be activated. Restart application to retry.")
completion(nil, error ?? defaultErrorResult)
log(error: "There was an error with purchase completion: \(error?.message ?? "")")
log(.error, message: "There was an error with purchase completion: \(error?.message ?? "")")
}
}
}

func completePurchases(products: [Purchase], endpoint: String, completion: @escaping (ServiceStatus?, ErrorResult?) -> Void) {
if let product = products.last {
log(info: "Found incomplete purchase. Completing purchase...")
log(.info, message: "Found incomplete purchase. Completing purchase...")

switch product.transaction.transactionState {
case .purchased, .restored:
Expand All @@ -163,11 +163,11 @@ class IAPManager {
SwiftyStoreKit.finishTransaction(product.transaction)
Application.shared.serviceStatus = sessionStatus.serviceStatus
completion(sessionStatus.serviceStatus, nil)
log(info: "Purchase was successfully finished.")
log(.info, message: "Purchase was successfully finished.")
case .failure(let error):
let defaultErrorResult = ErrorResult(status: 500, message: "Purchase was completed but service cannot be activated. Restart application to retry.")
completion(nil, error ?? defaultErrorResult)
log(error: "There was an error with purchase completion: \(error?.message ?? "")")
log(.error, message: "There was an error with purchase completion: \(error?.message ?? "")")
}
}
}
Expand All @@ -191,11 +191,11 @@ class IAPManager {
}
KeyChain.username = account.accountId
completion(account, nil)
log(info: "Purchase was successfully finished.")
log(.info, message: "Purchase was successfully finished.")
case .failure(let error):
let defaultErrorResult = ErrorResult(status: 500, message: "Purchase was restored but service cannot be activated. Restart application to retry.")
completion(nil, error ?? defaultErrorResult)
log(error: "There was an error with purchase completion: \(error?.message ?? "")")
log(.error, message: "There was an error with purchase completion: \(error?.message ?? "")")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion IVPNClient/Managers/NetworkManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class NetworkManager {
do {
try reachability.startNotifier()
} catch {
log(info: "Unable to start reachability notifier")
log(.info, message: "Unable to start reachability notifier")
}

#warning("Remove network signal check after issue with VPN connections is resolved in Reachability.swift library")
Expand Down
Loading

0 comments on commit 675de27

Please sign in to comment.