Compare commits

...

15 Commits

Author SHA1 Message Date
Andrej Mihajlov 2909fdf41e Switch NSCondition to DispatchGroup
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
2023-03-06 12:51:05 +01:00
Andrej Mihajlov 3149c50299 Kit: replace path monitor with KVO observer on defaultPath
Signed-off-by: Andrej Mihajlov <and@mullvad.net>
2023-03-06 12:50:44 +01:00
Jason A. Donenfeld 2fec12a6e1 App: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-15 14:20:52 +01:00
Jason A. Donenfeld 7b279383d1 App: bump copyright
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-15 14:20:35 +01:00
Jason A. Donenfeld 901fe1cf58 App: bump minimum OS versions
This allows us to remove a good deal of legacy cruft.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-15 14:20:30 +01:00
Jason A. Donenfeld ccc7472fd7 WireGuardKitGo: bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-14 16:09:14 +01:00
John Biggs 12b095470a WireGuardKit: fix incorrect IP address allocation size
According to [1], the `capacity` parameter is specified as "the number
of instances of T in the re-bound region" and not the total size of the
rebound struct.

Without this patch, there are crashes in the extension with the
following error:

  Fatal error: self must be a properly aligned pointer for types Pointee and T`

Since the subsequent line in the code only reads `sizeof(in_addr)` or
`sizeof(in6_addr)` anyway, change the `capacity` parameter to just be a
count of 1.

[1] https://developer.apple.com/documentation/swift/unsafepointer/withmemoryrebound(to:capacity:_:)

Signed-off-by: John Biggs <john.biggs@proton.ch>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2023-02-08 13:08:40 -03:00
Jason A. Donenfeld 9c07693951 global: apply MIT more consistently
People keep asking.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2022-11-17 01:17:52 +01:00
Roopesh Chander 23618f994f UI: When saving on-demand rules, deactivate if reqd and then save
Signed-off-by: Roopesh Chander <roop@roopc.net>
2021-09-28 00:16:35 +05:30
Roopesh Chander ba644415c7 UI: When saving on-demand rules on a config, enable on-demand if active
When a user saves on-demand rules on the configuration, set
onDemandEnabled to true if the tunnel is active, and false if it isn't.
Then deactivate the tunnel.

Signed-off-by: Roopesh Chander <roop@roopc.net>
2021-09-24 01:01:10 +05:30
Jason A. Donenfeld 10da5cfdef App: version bump
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-23 06:20:28 +02:00
Jason A. Donenfeld 75b6925deb UI: macOS: increase login detector file timeout
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-23 06:19:48 +02:00
Jason A. Donenfeld 03a59ff38e Model: migrate iOS 14 keychain references to iOS 15 format
Keychain references used to be bijective, but with the change in format,
Apple tried to be too clever, and references are no longer bijective.
This lead to us deleting keychain entries, which in turn emptied out
people's configs upon upgrading to iOS 15. Disaster!

Fix this by detecting the change in format and saving the new password
reference. We still rely on this being bijective moving forward;
hopefully this bug won't repeat itself. It would be nice to not rely on
that property, but doing so without grinding startup to a halt isn't
obviously done, given how slow the keychain accesses are and how limited
the API is.

Reported-by: Eddie <stunnel@attglobal.net>
Reported-by: Anatoli <me@anatoli.ws>
Reported-by: Alan Graham <alan@meshify.app>
Reported-by: Jacob Wilder <oss@jacobwilder.org>
Reported-by: Miguel Arroz <miguel.arroz@gmail.com>
Reported-by: Reid Rankin <reidrankin@gmail.com>
Reported-by: Fabien <patate.cosmique@pm.me>
Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-23 06:11:19 +02:00
Jason A. Donenfeld abf506c1fe UI: iOS: remove list pinking when no config
This reverts commit 86afd1a46a.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-23 06:08:53 +02:00
Jason A. Donenfeld dfb685f258 WireGuardApp: restore old keychain consistency behavior
This reverts commit adcbd17ebe.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-09-23 05:40:10 +02:00
132 changed files with 1007 additions and 334 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
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
+2 -2
View File
@@ -6,8 +6,8 @@ import PackageDescription
let package = Package(
name: "WireGuardKit",
platforms: [
.macOS(.v10_14),
.iOS(.v12)
.macOS(.v12),
.iOS(.v15)
],
products: [
.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
```
- Install swiftlint and go 1.15:
- Install swiftlint and go 1.19:
```
$ brew install swiftlint go
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import os.log
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import Security
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import os.log
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
* Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
*/
#include <string.h>
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: MIT
*
* Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
* Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
*/
#ifndef RINGLOGGER_H
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import NetworkExtension
@@ -72,7 +72,7 @@ extension NETunnelProviderProtocol {
#error("Unimplemented")
#endif
guard passwordReference == nil else { return true }
wg_log(.debug, message: "Migrating tunnel configuration '\(name)'")
wg_log(.info, message: "Migrating tunnel configuration '\(name)'")
passwordReference = Keychain.makeReference(containing: oldConfig, called: name)
return true
}
@@ -81,6 +81,25 @@ extension NETunnelProviderProtocol {
providerConfiguration = ["UID": getuid()]
return true
}
#elseif os(iOS)
/* Update the stored reference from the old iOS 14 one to the canonical iOS 15 one.
* The iOS 14 ones are 96 bits, while the iOS 15 ones are 160 bits. We do this so
* that we can have fast set exclusion in deleteReferences safely. */
if passwordReference != nil && passwordReference!.count == 12 {
var result: CFTypeRef?
let ret = SecItemCopyMatching([kSecValuePersistentRef: passwordReference!,
kSecReturnPersistentRef: true] as CFDictionary,
&result)
if ret != errSecSuccess || result == nil {
return false
}
guard let newReference = result as? Data else { return false }
if !newReference.elementsEqual(passwordReference!) {
wg_log(.info, message: "Migrating iOS 14-style keychain reference to iOS 15-style keychain reference for '\(name)'")
passwordReference = newReference
return true
}
}
#endif
return false
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// iOS permission prompts
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
+2 -2
View File
@@ -1,2 +1,2 @@
VERSION_NAME = 1.0.14
VERSION_ID = 25
VERSION_NAME = 1.0.16
VERSION_ID = 27
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import NetworkExtension
@@ -42,7 +42,7 @@ extension ActivateOnDemandOption {
}
}
tunnelProviderManager.onDemandRules = rules
tunnelProviderManager.isOnDemandEnabled = false
tunnelProviderManager.isOnDemandEnabled = (rules != nil) && tunnelProviderManager.isOnDemandEnabled
}
init(from tunnelProviderManager: NETunnelProviderManager) {
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import NetworkExtension
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import NetworkExtension
@@ -56,19 +56,21 @@ class TunnelsManager {
tunnelManager.saveToPreferences { _ in }
}
#if os(iOS)
let verify = true
let passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
#elseif os(macOS)
let verify = proto.providerConfiguration?["UID"] as? uid_t == getuid()
let passwordRef: Data?
if proto.providerConfiguration?["UID"] as? uid_t == getuid() {
passwordRef = proto.verifyConfigurationReference() ? proto.passwordReference : nil
} else {
passwordRef = proto.passwordReference // To handle multiple users in macOS, we skip verifying
}
#else
#error("Unimplemented")
#endif
if verify && !proto.verifyConfigurationReference() {
wg_log(.error, message: "Unable to verify keychain entry of tunnel: \(tunnelManager.localizedDescription ?? "<unknown>")")
}
if let ref = proto.passwordReference {
if let ref = passwordRef {
refs.insert(ref)
} else {
wg_log(.error, message: "Removing orphaned tunnel with missing keychain entry: \(tunnelManager.localizedDescription ?? "<unknown>")")
wg_log(.info, message: "Removing orphaned tunnel with non-verifying keychain entry: \(tunnelManager.localizedDescription ?? "<unknown>")")
tunnelManager.removeFromPreferences { _ in }
tunnelManagers.remove(at: index)
}
@@ -204,7 +206,10 @@ class TunnelsManager {
}
}
func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration, onDemandOption: ActivateOnDemandOption, completionHandler: @escaping (TunnelsManagerError?) -> Void) {
func modify(tunnel: TunnelContainer, tunnelConfiguration: TunnelConfiguration,
onDemandOption: ActivateOnDemandOption,
shouldEnsureOnDemandEnabled: Bool = false,
completionHandler: @escaping (TunnelsManagerError?) -> Void) {
let tunnelName = tunnelConfiguration.name ?? ""
if tunnelName.isEmpty {
completionHandler(TunnelsManagerError.tunnelNameEmpty)
@@ -212,6 +217,20 @@ class TunnelsManager {
}
let tunnelProviderManager = tunnel.tunnelProvider
let isIntroducingOnDemandRules = (tunnelProviderManager.onDemandRules ?? []).isEmpty && onDemandOption != .off
if isIntroducingOnDemandRules && tunnel.status != .inactive && tunnel.status != .deactivating {
tunnel.onDeactivated = { [weak self] in
self?.modify(tunnel: tunnel, tunnelConfiguration: tunnelConfiguration,
onDemandOption: onDemandOption, shouldEnsureOnDemandEnabled: true,
completionHandler: completionHandler)
}
self.startDeactivation(of: tunnel)
return
} else {
tunnel.onDeactivated = nil
}
let oldName = tunnelProviderManager.localizedDescription ?? ""
let isNameChanged = tunnelName != oldName
if isNameChanged {
@@ -229,8 +248,11 @@ class TunnelsManager {
}
tunnelProviderManager.isEnabled = true
let isActivatingOnDemand = !tunnelProviderManager.isOnDemandEnabled && onDemandOption != .off
let isActivatingOnDemand = !tunnelProviderManager.isOnDemandEnabled && shouldEnsureOnDemandEnabled
onDemandOption.apply(on: tunnelProviderManager)
if shouldEnsureOnDemandEnabled {
tunnelProviderManager.isOnDemandEnabled = true
}
tunnelProviderManager.saveToPreferences { [weak self] error in
if let error = error {
@@ -497,6 +519,11 @@ class TunnelsManager {
}
}
if session.status == .disconnected {
tunnel.onDeactivated?()
tunnel.onDeactivated = nil
}
if tunnel.status == .restarting && session.status == .disconnected {
tunnel.startActivation(activationDelegate: self.activationDelegate)
return
@@ -567,6 +594,7 @@ class TunnelContainer: NSObject {
var activationAttemptId: String?
var activationTimer: Timer?
var deactivationTimer: Timer?
var onDeactivated: (() -> Void)?
fileprivate var tunnelProvider: NETunnelProviderManager {
didSet {
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
protocol ErrorPresenterProtocol {
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
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
import LocalAuthentication
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -9,11 +9,7 @@ class KeyValueCell: UITableViewCell {
let keyLabel = UILabel()
keyLabel.font = UIFont.preferredFont(forTextStyle: .body)
keyLabel.adjustsFontForContentSizeCategory = true
if #available(iOS 13.0, *) {
keyLabel.textColor = .label
} else {
keyLabel.textColor = .black
}
keyLabel.textColor = .label
keyLabel.textAlignment = .left
return keyLabel
}()
@@ -35,11 +31,7 @@ class KeyValueCell: UITableViewCell {
valueTextField.autocapitalizationType = .none
valueTextField.autocorrectionType = .no
valueTextField.spellCheckingType = .no
if #available(iOS 13.0, *) {
valueTextField.textColor = .secondaryLabel
} else {
valueTextField.textColor = .gray
}
valueTextField.textColor = .secondaryLabel
return valueTextField
}()
@@ -64,18 +56,10 @@ class KeyValueCell: UITableViewCell {
var isValueValid = true {
didSet {
if #available(iOS 13.0, *) {
if isValueValid {
keyLabel.textColor = .label
} else {
keyLabel.textColor = .systemRed
}
if isValueValid {
keyLabel.textColor = .label
} else {
if isValueValid {
keyLabel.textColor = .black
} else {
keyLabel.textColor = .red
}
keyLabel.textColor = .systemRed
}
}
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -16,11 +16,7 @@ class SwitchCell: UITableViewCell {
get { return switchView.isEnabled }
set(value) {
switchView.isEnabled = value
if #available(iOS 13.0, *) {
textLabel?.textColor = value ? .label : .secondaryLabel
} else {
textLabel?.textColor = value ? .black : .gray
}
textLabel?.textColor = value ? .label : .secondaryLabel
}
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -28,11 +28,7 @@ class TextCell: UITableViewCell {
override func prepareForReuse() {
super.prepareForReuse()
message = ""
if #available(iOS 13.0, *) {
setTextColor(.label)
} else {
setTextColor(.black)
}
setTextColor(.label)
setTextAlignment(.left)
}
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -30,11 +30,7 @@ class TunnelEditEditableKeyValueCell: TunnelEditKeyValueCell {
super.init(style: style, reuseIdentifier: reuseIdentifier)
copyableGesture = false
if #available(iOS 13.0, *) {
valueTextField.textColor = .label
} else {
valueTextField.textColor = .black
}
valueTextField.textColor = .label
valueTextField.isEnabled = true
valueLabelScrollView.isScrollEnabled = false
valueTextField.widthAnchor.constraint(equalTo: valueLabelScrollView.widthAnchor).isActive = true
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -41,21 +41,13 @@ class TunnelListCell: UITableViewCell {
label.font = UIFont.preferredFont(forTextStyle: .caption2)
label.adjustsFontForContentSizeCategory = true
label.numberOfLines = 1
if #available(iOS 13.0, *) {
label.textColor = .secondaryLabel
} else {
label.textColor = .gray
}
label.textColor = .secondaryLabel
return label
}()
let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView
if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator = UIActivityIndicatorView(style: .medium)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}()
@@ -159,10 +151,6 @@ class TunnelListCell: UITableViewCell {
statusSwitch.isUserInteractionEnabled = (status == .inactive || status == .active)
}
if tunnel.tunnelConfiguration == nil {
statusSwitch.isUserInteractionEnabled = false
backgroundColor = .systemPink
}
}
private func reset(animated: Bool) {
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -15,15 +15,9 @@ class LogViewController: UIViewController {
}()
let busyIndicator: UIActivityIndicatorView = {
if #available(iOS 13.0, *) {
let busyIndicator = UIActivityIndicatorView(style: .medium)
busyIndicator.hidesWhenStopped = true
return busyIndicator
} else {
let busyIndicator = UIActivityIndicatorView(style: .gray)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}
let busyIndicator = UIActivityIndicatorView(style: .medium)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}()
let paragraphStyle: NSParagraphStyle = {
@@ -41,12 +35,7 @@ class LogViewController: UIViewController {
override func loadView() {
view = UIView()
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.backgroundColor = .systemBackground
view.addSubview(textView)
textView.translatesAutoresizingMaskIntoConstraints = false
NSLayoutConstraint.activate([
@@ -92,15 +81,8 @@ class LogViewController: UIViewController {
let bodyFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.body)
let captionFont = UIFont.preferredFont(forTextStyle: UIFont.TextStyle.caption1)
for logEntry in fetchedLogEntries {
var bgColor: UIColor
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 bgColor: UIColor = self.isNextLineHighlighted ? .systemGray3 : .systemBackground
let fgColor: UIColor = .label
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])
richText.append(timestampText)
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -11,11 +11,7 @@ class MainViewController: UISplitViewController {
init() {
let detailVC = UIViewController()
if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
detailVC.view.backgroundColor = .systemBackground
let detailNC = UINavigationController(rootViewController: detailVC)
let masterVC = TunnelsListTableViewController()
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import AVFoundation
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
import SystemConfiguration.CaptiveNetwork
@@ -185,11 +185,7 @@ extension SSIDOptionEditTableViewController {
private func noSSIDsCell(for tableView: UITableView, at indexPath: IndexPath) -> UITableViewCell {
let cell: TextCell = tableView.dequeueReusableCell(for: indexPath)
cell.message = tr("tunnelOnDemandNoSSIDs")
if #available(iOS 13.0, *) {
cell.setTextColor(.secondaryLabel)
} else {
cell.setTextColor(.gray)
}
cell.setTextColor(.secondaryLabel)
cell.setTextAlignment(.center)
return cell
}
@@ -268,23 +264,8 @@ extension SSIDOptionEditTableViewController {
#if targetEnvironment(simulator)
completionHandler("Simulator Wi-Fi")
#else
if #available(iOS 14, *) {
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)
NEHotspotNetwork.fetchCurrent { hotspotNetwork in
completionHandler(hotspotNetwork?.ssid)
}
#endif
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
import os.log
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import UIKit
import MobileCoreServices
@@ -33,11 +33,7 @@ class TunnelsListTableViewController: UIViewController {
let busyIndicator: UIActivityIndicatorView = {
let busyIndicator: UIActivityIndicatorView
if #available(iOS 13.0, *) {
busyIndicator = UIActivityIndicatorView(style: .medium)
} else {
busyIndicator = UIActivityIndicatorView(style: .gray)
}
busyIndicator = UIActivityIndicatorView(style: .medium)
busyIndicator.hidesWhenStopped = true
return busyIndicator
}()
@@ -51,11 +47,7 @@ class TunnelsListTableViewController: UIViewController {
override func loadView() {
view = UIView()
if #available(iOS 13.0, *) {
view.backgroundColor = .systemBackground
} else {
view.backgroundColor = .white
}
view.backgroundColor = .systemBackground
tableView.dataSource = self
tableView.delegate = self
@@ -344,7 +336,6 @@ extension TunnelsListTableViewController: UITableViewDelegate {
}
guard let tunnelsManager = tunnelsManager else { return }
let tunnel = tunnelsManager.tunnel(at: indexPath.row)
guard tunnel.tunnelConfiguration != nil else { return }
showTunnelDetail(for: tunnel, animated: true)
}
@@ -407,11 +398,7 @@ extension TunnelsListTableViewController: TunnelsManagerListDelegate {
(splitViewController.viewControllers[0] as? UINavigationController)?.popToRootViewController(animated: false)
} else {
let detailVC = UIViewController()
if #available(iOS 13.0, *) {
detailVC.view.backgroundColor = .systemBackground
} else {
detailVC.view.backgroundColor = .white
}
detailVC.view.backgroundColor = .systemBackground
let detailNC = UINavigationController(rootViewController: detailVC)
splitViewController.showDetailViewController(detailNC, sender: self)
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
import ServiceManagement
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
+1 -1
View File
@@ -29,7 +29,7 @@
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.</string>
<string>Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.</string>
<key>NSPrincipalClass</key>
<string>WireGuard.Application</string>
<key>LSApplicationCategoryType</key>
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -14,6 +14,6 @@ class LaunchedAtLoginDetector {
let then = data.withUnsafeBytes { ptr in
ptr.load(as: UInt64.self)
}
return now - then <= 5000000000
return now - then <= 20000000000
}
}
@@ -25,7 +25,7 @@
<key>LSMinimumSystemVersion</key>
<string>$(MACOSX_DEPLOYMENT_TARGET)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.</string>
<string>Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>LSBackgroundOnly</key>
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
#import <Cocoa/Cocoa.h>
@@ -14,23 +14,19 @@ int main(int argc, char *argv[])
return 2;
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])
return 3;
if (@available(macOS 10.15, *)) {
NSCondition *condition = [[NSCondition alloc] init];
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
if (!appURL)
return 4;
NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
openConfiguration.activates = NO;
openConfiguration.addsToRecentItems = NO;
openConfiguration.hides = YES;
[NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
[condition signal];
}];
[condition wait];
} else {
[NSWorkspace.sharedWorkspace launchAppWithBundleIdentifier:appId options:NSWorkspaceLaunchWithoutActivation
additionalEventParamDescriptor:NULL launchIdentifier:NULL];
}
return 3;
NSCondition *condition = [[NSCondition alloc] init];
NSURL *appURL = [NSWorkspace.sharedWorkspace URLForApplicationWithBundleIdentifier:appId];
if (!appURL)
return 4;
NSWorkspaceOpenConfiguration *openConfiguration = [NSWorkspaceOpenConfiguration configuration];
openConfiguration.activates = NO;
openConfiguration.addsToRecentItems = NO;
openConfiguration.hides = YES;
[NSWorkspace.sharedWorkspace openApplicationAtURL:appURL configuration:openConfiguration completionHandler:^(NSRunningApplication * _Nullable app, NSError * _Nullable error) {
[condition signal];
}];
[condition wait];
return 0;
}
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import AppKit
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
import CoreWLAN
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: GPL-2.0
// SPDX-License-Identifier: MIT
/*
* Copyright (C) 2015-2020 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
@@ -1,4 +1,4 @@
/* SPDX-License-Identifier: GPL-2.0 */
/* SPDX-License-Identifier: MIT */
/*
* Copyright (C) 2015-2019 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
*/
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Cocoa
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
protocol WireGuardAppError: Error {
typealias AlertText = (title: String, message: String)
+1 -1
View File
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
enum WireGuardResult<T> {
case success(_ value: T)
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
import Foundation
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: MIT
// Copyright © 2018-2021 WireGuard LLC. All Rights Reserved.
// Copyright © 2018-2023 WireGuard LLC. All Rights Reserved.
// Generic alert action names

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