Skip to content

Commit

Permalink
Merge pull request #320 from ivpn/task/upgrade-tunnelkit
Browse files Browse the repository at this point in the history
Upgrade TunnelKit
  • Loading branch information
jurajhilje authored Feb 3, 2023
2 parents ff0899f + 7c20f85 commit 59f8a7c
Show file tree
Hide file tree
Showing 19 changed files with 89 additions and 138 deletions.
83 changes: 50 additions & 33 deletions IVPNClient.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions IVPNClient/Managers/VPNManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
import Foundation
import NetworkExtension
import UIKit
import TunnelKit
import TunnelKitCore
import TunnelKitOpenVPN

class VPNManager {

Expand Down Expand Up @@ -384,7 +385,7 @@ class VPNManager {
}

do {
try session.sendProviderMessage(OpenVPNTunnelProvider.Message.requestLog.data) { data in
try session.sendProviderMessage(OpenVPNProvider.Message.requestLog.data) { data in
guard let data = data, !data.isEmpty else {
completion(nil)
return
Expand Down
7 changes: 1 addition & 6 deletions IVPNClient/Scenes/MainScreen/Map/MapMarkerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,12 +157,7 @@ class MapMarkerView: UIView {

private func addObservers() {
NotificationCenter.default.addObserver(self, selector: #selector(hidePopup), name: Notification.Name.HideConnectionInfoPopup, object: nil)

if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIScene.didActivateNotification, object: nil)
} else {
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIApplication.didBecomeActiveNotification, object: nil)
}
NotificationCenter.default.addObserver(self, selector: #selector(appDidBecomeActive), name: UIScene.didActivateNotification, object: nil)
}

// MARK: - Private methods -
Expand Down
11 changes: 3 additions & 8 deletions IVPNClient/Scenes/MainScreen/View/ControlPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,8 @@ class ControlPanelView: UITableView {
// MARK: - Methods -

func setupView() {
if #available(iOS 13.0, *) {
connectSwitch.thumbTintColor = UIColor.init(named: Theme.ivpnGray17)
connectSwitch.onTintColor = UIColor.init(named: Theme.ivpnBlue)
}

connectSwitch.thumbTintColor = UIColor.init(named: Theme.ivpnGray17)
connectSwitch.onTintColor = UIColor.init(named: Theme.ivpnBlue)
updateConnectSwitch()
UIAccessibility.post(notification: UIAccessibility.Notification.layoutChanged, argument: protectionStatusTableCell)

Expand Down Expand Up @@ -149,9 +146,7 @@ class ControlPanelView: UITableView {
}

private func updateConnectSwitch() {
if #available(iOS 13.0, *) {
connectSwitch.subviews[0].subviews[0].backgroundColor = UIColor.init(named: Theme.ivpnRedOff)
}
connectSwitch.subviews[0].subviews[0].backgroundColor = UIColor.init(named: Theme.ivpnRedOff)
}

}
7 changes: 1 addition & 6 deletions IVPNClient/Scenes/SecureDNS/View/SecureDNSView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,7 @@ class SecureDNSView: UITableView {
// MARK: - Observers -

private func addObservers() {
if #available(iOS 13.0, *) {
NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIScene.didActivateNotification, object: nil)
} else {
NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIApplication.didBecomeActiveNotification, object: nil)
}

NotificationCenter.default.addObserver(self, selector: #selector(updateEnableSwitch), name: UIScene.didActivateNotification, object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(updateResolvedDNS), name: Notification.Name.UpdateResolvedDNS, object: nil)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ class CreateAccountViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

}
4 changes: 1 addition & 3 deletions IVPNClient/Scenes/Signup/LoginViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,7 @@ class LoginViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - Observers -
Expand Down
5 changes: 1 addition & 4 deletions IVPNClient/Scenes/Signup/Payment/PaymentViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,7 @@ class PaymentViewController: UITableViewController {
}

private func setupView() {
if #available(iOS 13.0, *) {
isModalInPresentation = true
}

isModalInPresentation = true
view.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)
payButton?.set(title: "Pay", subtitle: "")

Expand Down
4 changes: 1 addition & 3 deletions IVPNClient/Scenes/Signup/Scanner/ScannerViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,7 @@ class ScannerViewController: UIViewController, AVCaptureMetadataOutputObjectsDel

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()

evaluateCameraAccess()
startCaptureSession()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,7 @@ class SelectPlanViewController: UITableViewController {
super.viewWillAppear(animated)
// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

override func viewDidAppear(_ animated: Bool) {
Expand Down Expand Up @@ -179,10 +177,7 @@ class SelectPlanViewController: UITableViewController {
}

private func setupView() {
if #available(iOS 13.0, *) {
isModalInPresentation = true
}

isModalInPresentation = true
tableView.separatorStyle = .none
view.addSubview(spinner)
view.addSubview(retryButton)
Expand Down
25 changes: 9 additions & 16 deletions IVPNClient/Scenes/ViewControllers/NavigationController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,15 @@ class NavigationController: UINavigationController {
UINavigationBar.appearance().tintColor = UIColor.init(named: Theme.ivpnBlue)
navigationBar.prefersLargeTitles = true

if #available(iOS 13.0, *) {
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
appearance.shadowImage = nil
appearance.shadowColor = nil
navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
} else {
navigationBar.barTintColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)
navigationBar.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
navigationBar.shadowImage = UIImage()
navigationBar.barTintColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
}
let appearance = UINavigationBarAppearance()
appearance.configureWithOpaqueBackground()
appearance.titleTextAttributes = [NSAttributedString.Key.font: UIFont.systemFont(ofSize: 17, weight: .bold), NSAttributedString.Key.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.largeTitleTextAttributes = [.foregroundColor: UIColor.init(named: Theme.ivpnLabelPrimary)!]
appearance.backgroundColor = UIColor.init(named: Theme.ivpnBackgroundPrimary)!
appearance.shadowImage = nil
appearance.shadowColor = nil
navigationBar.standardAppearance = appearance
navigationBar.scrollEdgeAppearance = appearance
}

override func viewWillAppear(_ animated: Bool) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,7 @@ class TermsOfServiceViewController: UIViewController {
super.viewWillAppear(animated)
// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - Methods -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ class UpgradePlanViewController: UIViewController {

// iOS 13 UIKit bug: https://forums.developer.apple.com/thread/121861
// Remove when fixed in future releases
if #available(iOS 13.0, *) {
navigationController?.navigationBar.setNeedsLayout()
}
navigationController?.navigationBar.setNeedsLayout()
}

// MARK: - @IBActions -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@
import Foundation
import NetworkExtension
import Network
import TunnelKit
import TunnelKitCore
import TunnelKitManager
import TunnelKitOpenVPN
import WireGuardKit
import KeychainAccess

extension NETunnelProviderProtocol {

Expand Down Expand Up @@ -65,19 +68,19 @@ extension NETunnelProviderProtocol {
}
}

var builder = OpenVPNTunnelProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
var builder = OpenVPNProvider.ConfigurationBuilder(sessionConfiguration: sessionBuilder.build())
builder.shouldDebug = true
builder.debugLogFormat = "$Dyyyy-MM-dd HH:mm:ss$d $L $M"
builder.masksPrivateData = true

let configuration = builder.build()
let keychain = Keychain(group: Config.appGroup)
try? keychain.set(password: credentials.password, for: credentials.username, context: Config.openvpnTunnelProvider)
_ = try? keychain.set(password: credentials.password, for: credentials.username, context: Config.openvpnTunnelProvider)
let proto = try! configuration.generatedTunnelProtocol(
withBundleIdentifier: Config.openvpnTunnelProvider,
appGroup: Config.appGroup,
context: Config.openvpnTunnelProvider,
username: credentials.username
credentials: credentials
)
proto.disconnectOnSleep = !UserDefaults.shared.keepAlive
if #available(iOS 15.1, *) {
Expand Down
6 changes: 1 addition & 5 deletions IVPNClient/Utilities/Extensions/UIImageView+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ extension UIImageView {
func setFlagIconBorder() {
layer.cornerRadius = 2.0
layer.shadowRadius = 0.5
if #available(iOS 13.0, *) {
layer.shadowColor = UIColor.label.cgColor
} else {
layer.shadowColor = UIColor.black.cgColor
}
layer.shadowColor = UIColor.label.cgColor
layer.shadowOffset = CGSize(width: 0, height: 0)
layer.shadowOpacity = 0.3
backgroundColor = UIColor.clear
Expand Down
7 changes: 3 additions & 4 deletions IVPNClient/Utilities/Extensions/UIViewController+Ext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,10 @@ extension UIViewController {
// MARK: - @IBActions -

@IBAction func dismissViewController(_ sender: Any) {
if #available(iOS 13.0, *) {
if let presentationController = navigationController?.presentationController {
presentationController.delegate?.presentationControllerDidDismiss?(presentationController)
}
if let presentationController = navigationController?.presentationController {
presentationController.delegate?.presentationControllerDidDismiss?(presentationController)
}

navigationController?.dismiss(animated: true)
}

Expand Down
4 changes: 1 addition & 3 deletions Podfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
platform :ios, '12.0'
platform :ios, '13.0'
use_frameworks!

target 'IVPNClient' do
pod 'TunnelKit', '~> 3.5.0'
pod 'KeychainAccess', '~> 3.2.0'
pod 'SwiftyStoreKit', '~> 0.16.1'
pod 'JGProgressHUD', '~> 2.0.3'
Expand All @@ -13,7 +12,6 @@ target 'IVPNClient' do
end

target 'openvpn-tunnel-provider' do
pod 'TunnelKit', '~> 3.5.0'
pod 'KeychainAccess', '~> 3.2.0'
end

Expand Down
25 changes: 1 addition & 24 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,9 @@ PODS:
- FloatingPanel (1.7.4)
- JGProgressHUD (2.0.4)
- KeychainAccess (3.2.1)
- OpenSSL-Apple (1.1.1l.11)
- ReachabilitySwift (5.0.0)
- SnapKit (5.0.1)
- SwiftyBeaver (1.9.5)
- SwiftyStoreKit (0.16.1)
- TunnelKit (3.5.0):
- TunnelKit/Protocols/OpenVPN (= 3.5.0)
- TunnelKit/AppExtension (3.5.0):
- SwiftyBeaver
- TunnelKit/Core
- TunnelKit/Core (3.5.0):
- SwiftyBeaver
- TunnelKit/Manager (3.5.0):
- SwiftyBeaver
- TunnelKit/Core
- TunnelKit/Protocols/OpenVPN (3.5.0):
- OpenSSL-Apple (~> 1.1.1l.11)
- TunnelKit/AppExtension
- TunnelKit/Manager

DEPENDENCIES:
- ActiveLabel (~> 1.1.0)
Expand All @@ -31,33 +15,26 @@ DEPENDENCIES:
- ReachabilitySwift (~> 5.0.0)
- SnapKit (~> 5.0.1)
- SwiftyStoreKit (~> 0.16.1)
- TunnelKit (~> 3.5.0)

SPEC REPOS:
trunk:
- ActiveLabel
- FloatingPanel
- JGProgressHUD
- KeychainAccess
- OpenSSL-Apple
- ReachabilitySwift
- SnapKit
- SwiftyBeaver
- SwiftyStoreKit
- TunnelKit

SPEC CHECKSUMS:
ActiveLabel: 5e3f4de79a1952d4604b845a0610d4776e4b82b3
FloatingPanel: 3c9d0e30fe350e1613157557769d2ec97f76b96b
JGProgressHUD: 62658b14e72cccf179efc7a13bcb54d30b92fc22
KeychainAccess: d5470352939ced6d6f7fb51cb2e67aae51fc294f
OpenSSL-Apple: fb93d9a7ce4529054764ce19bb80947a38aee09b
ReachabilitySwift: 985039c6f7b23a1da463388634119492ff86c825
SnapKit: 97b92857e3df3a0c71833cce143274bf6ef8e5eb
SwiftyBeaver: 84069991dd5dca07d7069100985badaca7f0ce82
SwiftyStoreKit: 6b9c08810269f030586dac1fae8e75871a82e84a
TunnelKit: da385bd81f797728f86fcf0f2de2e4c4af415c40

PODFILE CHECKSUM: 2fb7364c00f6889da4384d1ffc35ed5ac3c93e5a
PODFILE CHECKSUM: 34bdc77c9be7333d62048531045a1936b58d739b

COCOAPODS: 1.11.3
2 changes: 1 addition & 1 deletion openvpn-tunnel-provider/PacketTunnelProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
// along with the IVPN iOS app. If not, see <https://www.gnu.org/licenses/>.
//

import TunnelKit
import TunnelKitOpenVPNAppExtension

class PacketTunnelProvider: OpenVPNTunnelProvider {}

0 comments on commit 59f8a7c

Please sign in to comment.