Compare commits

..

1 Commits

Author SHA1 Message Date
Andrej Mihajlov 977ec25e79 Kit: implement Codable for IPAddressRange
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
2022-09-26 16:43:17 +02:00
132 changed files with 330 additions and 903 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in
+3 -3
View File
@@ -1,4 +1,4 @@
// swift-tools-version:5.9 // swift-tools-version:5.3
// The swift-tools-version declares the minimum version of Swift required to build this package. // The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription import PackageDescription
@@ -6,8 +6,8 @@ import PackageDescription
let package = Package( let package = Package(
name: "WireGuardKit", name: "WireGuardKit",
platforms: [ platforms: [
.macOS(.v12), .macOS(.v10_14),
.iOS(.v15) .iOS(.v12)
], ],
products: [ products: [
.library(name: "WireGuardKit", targets: ["WireGuardKit"]) .library(name: "WireGuardKit", targets: ["WireGuardKit"])
+1 -1
View File
@@ -18,7 +18,7 @@ $ cp Sources/WireGuardApp/Config/Developer.xcconfig.template Sources/WireGuardAp
$ vim Sources/WireGuardApp/Config/Developer.xcconfig $ vim Sources/WireGuardApp/Config/Developer.xcconfig
``` ```
- Install swiftlint and go 1.19: - Install swiftlint and go 1.15:
``` ```
$ brew install swiftlint go $ brew install swiftlint go
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import os.log import os.log
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import Security import Security
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import os.log import os.log
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT /* SPDX-License-Identifier: MIT
* *
* Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. * Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
*/ */
#include <string.h> #include <string.h>
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT /* SPDX-License-Identifier: MIT
* *
* Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. * Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
*/ */
#ifndef RINGLOGGER_H #ifndef RINGLOGGER_H
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import NetworkExtension import NetworkExtension
@@ -82,22 +82,24 @@ extension NETunnelProviderProtocol {
return true return true
} }
#elseif os(iOS) #elseif os(iOS)
/* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one. if #available(iOS 15, *) {
* The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so /* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
* that we can have fast set exclusion in deleteReferences safely. */ * The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
if passwordReference != nil && passwordReference!.count == 12 { * that we can have fast set exclusion in deleteReferences safely. */
var result: CFTypeRef? if passwordReference != nil && passwordReference!.count == 12 {
let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!, var result: CFTypeRef?
kSecReturnPersistentRef: true] as CFDictionary, let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
&result) kSecReturnPersistentRef: true] as CFDictionary,
if ret != errSecSuccess || result == nil { &result)
return false if ret != errSecSuccess || result == nil {
} return false
guard let newReference = result as? Data else { return false } }
if !newReference.elementsEqual(passwordReference!) { guard let newReference = result as? Data else { return false }
wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'") if !newReference.elementsEqual(passwordReference!) {
passwordReference = newReference wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
return true passwordReference = newReference
return true
}
} }
} }
#endif #endif
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// iOS permission prompts // iOS permission prompts
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
+2 -2
View File
@@ -1,2 +1,2 @@
VERSION_NAME = 1.0.16 VERSION_NAME = 1.0.15
VERSION_ID = 27 VERSION_ID = 26
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import NetworkExtension import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import NetworkExtension import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import NetworkExtension import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import NetworkExtension import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import NetworkExtension import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
protocol ErrorPresenterProtocol { protocol ErrorPresenterProtocol {
static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?, onDismissal: (() -> Void)?) static func showErrorAlert(title: String, message: String, from sourceVC: AnyObject?, onPresented: (() -> Void)?, onDismissal: (() -> Void)?)
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
import LocalAuthentication import LocalAuthentication
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
import os.log import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
import os.log import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -9,7 +9,11 @@ class KeyValueCell: UITableViewCell {
let keyLabel = UILabel() let keyLabel = UILabel()
keyLabel.font = UIFont.preferredFont(forTextStyle: .body) keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
keyLabel.adjustsFontForContentSizeCategory = true keyLabel.adjustsFontForContentSizeCategory = true
keyLabel.textColor = .label if #available(iOS 13.0, *) {
keyLabel.textColor = .label
} else {
keyLabel.textColor = .black
}
keyLabel.textAlignment = .left keyLabel.textAlignment = .left
return keyLabel return keyLabel
}() }()
@@ -31,7 +35,11 @@ class KeyValueCell: UITableViewCell {
valueTextField.autocapitalizationType = .none valueTextField.autocapitalizationType = .none
valueTextField.autocorrectionType = .no valueTextField.autocorrectionType = .no
valueTextField.spellCheckingType = .no valueTextField.spellCheckingType = .no
valueTextField.textColor = .secondaryLabel if #available(iOS 13.0, *) {
valueTextField.textColor = .secondaryLabel
} else {
valueTextField.textColor = .gray
}
return valueTextField return valueTextField
}() }()
@@ -56,10 +64,18 @@ class KeyValueCell: UITableViewCell {
var isValueValid = true { var isValueValid = true {
didSet { didSet {
if isValueValid { if #available(iOS 13.0, *) {
keyLabel.textColor = .label if isValueValid {
keyLabel.textColor = .label
} else {
keyLabel.textColor = .systemRed
}
} else { } else {
keyLabel.textColor = .systemRed if isValueValid {
keyLabel.textColor = .black
} else {
keyLabel.textColor = .red
}
} }
} }
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -16,7 +16,11 @@ class SwitchCell: UITableViewCell {
get { return switchView.isEnabled } get { return switchView.isEnabled }
set(value) { set(value) {
switchView.isEnabled = value switchView.isEnabled = value
textLabel?.textColor = value ? .label : .secondaryLabel if #available(iOS 13.0, *) {
textLabel?.textColor = value ? .label : .secondaryLabel
} else {
textLabel?.textColor = value ? .black : .gray
}
} }
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -28,7 +28,11 @@ class TextCell: UITableViewCell {
override func prepareForReuse() { override func prepareForReuse() {
super.prepareForReuse() super.prepareForReuse()
message = "" message = ""
setTextColor(.label) if #available(iOS 13.0, *) {
setTextColor(.label)
} else {
setTextColor(.black)
}
setTextAlignment(.left) setTextAlignment(.left)
} }
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -30,7 +30,11 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
super.init(style: style, reuseIdentifier: reuseIdentifier) super.init(style: style, reuseIdentifier: reuseIdentifier)
copyableGesture = false copyableGesture = false
valueTextField.textColor = .label if #available(iOS 13.0, *) {
valueTextField.textColor = .label
} else {
valueTextField.textColor = .black
}
valueTextField.isEnabled = true valueTextField.isEnabled = true
valueLabelScrollView.isScrollEnabled = false valueLabelScrollView.isScrollEnabled = false
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -41,13 +41,21 @@ class TunnelListCell: UITableViewCell {
label.font = UIFont.preferredFont(forTextStyle: .caption2) label.font = UIFont.preferredFont(forTextStyle: .caption2)
label.adjustsFontForContentSizeCategory = true label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 1 label.numberOfLines = 1
label.textColor = .secondaryLabel if #available(iOS 13.0, *) {
label.textColor = .secondaryLabel
} else {
label.textColor = .gray
}
return label return label
}() }()
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView let busyIndicator: UIActivityIndicatorView
busyIndicator = UIActivityIndicatorView(style: .medium) if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator.hidesWhenStopped = true busyIndicator.hidesWhenStopped = true
return busyIndicator return busyIndicator
}() }()
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -15,9 +15,15 @@ class LogViewController: UIViewController {
}() }()
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
let busyIndicator = UIActivityIndicatorView(style: .medium) if #available(iOS 13.0, *) {
busyIndicator.hidesWhenStopped = true let busyIndicator = UIActivityIndicatorView(style: .medium)
return busyIndicator busyIndicator.hidesWhenStopped = true
return busyIndicator
} else {
let busyIndicator = UIActivityIndicatorView(style: .gray)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}
}() }()
let paragraphStyle: NSParagraphStyle = { let paragraphStyle: NSParagraphStyle = {
@@ -35,7 +41,12 @@ class LogViewController: UIViewController {
override func loadView() { override func loadView() {
view = UIView() view = UIView()
view.backgroundColor = .systemBackground if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.addSubview(textView) view.addSubview(textView)
textView.translatesAutoresizingMaskIntoConstraints = false textView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([ NSLayoutConstraint.activate([
@@ -81,8 +92,15 @@ class LogViewController: UIViewController {
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body) let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1) let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
for logEntry in fetchedLogEntries { for logEntry in fetchedLogEntries {
let bgColor: UIColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground var bgColor: UIColor
let fgColor: UIColor = .label var fgColor: UIColor
if #available(iOS 13.0, *) {
bgColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
fgColor = .label
} else {
bgColor = self.isNextLineHighlighted ? UIColor(white: 0.88, alpha: 1.0) : UIColor.white
fgColor = .black
}
let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle]) let timestampText = NSAttributedString(string: logEntry.timestamp + "\n", attributes: [.font: captionFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle]) let messageText = NSAttributedString(string: logEntry.message + "\n", attributes: [.font: bodyFont, .backgroundColor: bgColor, .foregroundColor: fgColor, .paragraphStyle: self.paragraphStyle])
richText.append(timestampText) richText.append(timestampText)
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -11,7 +11,11 @@ class MainViewController: UISplitViewController {
init() { init() {
let detailVC = UIViewController() let detailVC = UIViewController()
detailVC.view.backgroundColor = .systemBackground if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
let detailNC = UINavigationController(rootViewController: detailVC) let detailNC = UINavigationController(rootViewController: detailVC)
let masterVC = TunnelsListTableViewController() let masterVC = TunnelsListTableViewController()
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import AVFoundation import AVFoundation
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
import SystemConfiguration.CaptiveNetwork import SystemConfiguration.CaptiveNetwork
@@ -185,7 +185,11 @@ extension SSIDOptionEditTableViewController {
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell { private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath) let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = tr("tunnelOnDemandNoSSIDs") cell.message = tr("tunnelOnDemandNoSSIDs")
cell.setTextColor(.secondaryLabel) if #available(iOS 13.0, *) {
cell.setTextColor(.secondaryLabel)
} else {
cell.setTextColor(.gray)
}
cell.setTextAlignment(.center) cell.setTextAlignment(.center)
return cell return cell
} }
@@ -264,8 +268,23 @@ extension SSIDOptionEditTableViewController {
#if targetEnvironment(simulator) #if targetEnvironment(simulator)
completionHandler("Simulator Wi-Fi") completionHandler("Simulator Wi-Fi")
#else #else
NEHotspotNetwork.fetchCurrent { hotspotNetwork in if #available(iOS 14, *) {
completionHandler(hotspotNetwork?.ssid) NEHotspotNetwork.fetchCurrent { hotspotNetwork in
completionHandler(hotspotNetwork?.ssid)
}
} else {
if let supportedInterfaces = CNCopySupportedInterfaces() as? [CFString] {
for interface in supportedInterfaces {
if let networkInfo = CNCopyCurrentNetworkInfo(interface) {
if let ssid = (networkInfo as NSDictionary)[kCNNetworkInfoKeySSID as String] as? String {
completionHandler(!ssid.isEmpty ? ssid : nil)
return
}
}
}
}
completionHandler(nil)
} }
#endif #endif
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
import os.log import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import UIKit import UIKit
import MobileCoreServices import MobileCoreServices
@@ -33,7 +33,11 @@ class TunnelsListTableViewController: UIViewController {
let busyIndicator: UIActivityIndicatorView = { let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView let busyIndicator: UIActivityIndicatorView
busyIndicator = UIActivityIndicatorView(style: .medium) if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator.hidesWhenStopped = true busyIndicator.hidesWhenStopped = true
return busyIndicator return busyIndicator
}() }()
@@ -47,7 +51,11 @@ class TunnelsListTableViewController: UIViewController {
override func loadView() { override func loadView() {
view = UIView() view = UIView()
view.backgroundColor = .systemBackground if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
tableView.dataSource = self tableView.dataSource = self
tableView.delegate = self tableView.delegate = self
@@ -398,7 +406,11 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false) (splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
} else { } else {
let detailVC = UIViewController() let detailVC = UIViewController()
detailVC.view.backgroundColor = .systemBackground if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
let detailNC = UINavigationController(rootViewController: detailVC) let detailNC = UINavigationController(rootViewController: detailVC)
splitViewController.showDetailViewController(detailNC, sender: self) splitViewController.showDetailViewController(detailNC, sender: self)
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
import ServiceManagement import ServiceManagement
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
+1 -1
View File
@@ -29,7 +29,7 @@
<key>LSUIElement</key> <key>LSUIElement</key>
<true/> <true/>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.</string> <string>Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>WireGuard.Application</string> <string>WireGuard.Application</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -25,7 +25,7 @@
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string> <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key> <key>NSHumanReadableCopyright</key>
<string>Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.</string> <string>Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.</string>
<key>NSPrincipalClass</key> <key>NSPrincipalClass</key>
<string>NSApplication</string> <string>NSApplication</string>
<key>LSBackgroundOnly</key> <key>LSBackgroundOnly</key>
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@@ -14,19 +14,23 @@ int main(int argc, char *argv[])
return 2; return 2;
uint64_t now = clock_gettime_nsec_np(CLOCK_UPTIME_RAW); uint64_t now = clock_gettime_nsec_np(CLOCK_UPTIME_RAW);
if (![[NSData dataWithBytes:&now length:sizeof(now)] writeToURL:[containerUrl URLByAppendingPathComponent:@"login-helper-timestamp.bin"] atomically:YES]) if (![[NSData dataWithBytes:&now length:sizeof(now)] writeToURL:[containerUrl URLByAppendingPathComponent:@"login-helper-timestamp.bin"] atomically:YES])
return 3; return 3;
if (@available(macOS 10.15, *)) {
NSCondition *condition = [[NSCondition alloc] init]; NSCondition *condition = [[NSCondition alloc] init];
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId]; NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
if (!appURL) if (!appURL)
return 4; return 4;
NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration]; NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
openConfiguration.activates = NO; openConfiguration.activates = NO;
openConfiguration.addsToRecentItems = NO; openConfiguration.addsToRecentItems = NO;
openConfiguration.hides = YES; openConfiguration.hides = YES;
[NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) { [NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
[condition signal]; [condition signal];
}]; }];
[condition wait]; [condition wait];
} else {
[NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:NULL launchIdentifier:NULL];
}
return 0; return 0;
} }
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import AppKit import AppKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
import CoreWLAN import CoreWLAN
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: GPL-2.0
/* /*
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. * Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/ */
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: MIT */ /* SPDX-License-Identifier: GPL-2.0 */
/* /*
* Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved. * Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/ */
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Cocoa import Cocoa
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
protocol WireGuardAppError: Error { protocol WireGuardAppError: Error {
typealias AlertText = (title: String, message: String) typealias AlertText = (title: String, message: String)
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
enum WireGuardResult<T> { enum WireGuardResult<T> {
case success(_ value: T) case success(_ value: T)
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
import Foundation import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved. // Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Generic alert action names // Generic alert action names

Some files were not shown because too many files have changed in this diff Show More