Global: run through swiftlint
This commit is contained in:
parent
b3b63b5f5d
commit
355a555cc4
|
@ -23,7 +23,7 @@ class WgQuickConfigFileParser {
|
||||||
|
|
||||||
assert(!name.isEmpty)
|
assert(!name.isEmpty)
|
||||||
|
|
||||||
func collate(interfaceAttributes attributes: [String:String]) -> InterfaceConfiguration? {
|
func collate(interfaceAttributes attributes: [String: String]) -> InterfaceConfiguration? {
|
||||||
// required wg fields
|
// required wg fields
|
||||||
guard let privateKeyString = attributes["PrivateKey"] else { return nil }
|
guard let privateKeyString = attributes["PrivateKey"] else { return nil }
|
||||||
guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == 32 else { return nil }
|
guard let privateKey = Data(base64Encoded: privateKeyString), privateKey.count == 32 else { return nil }
|
||||||
|
@ -59,7 +59,7 @@ class WgQuickConfigFileParser {
|
||||||
return interface
|
return interface
|
||||||
}
|
}
|
||||||
|
|
||||||
func collate(peerAttributes attributes: [String:String]) -> PeerConfiguration? {
|
func collate(peerAttributes attributes: [String: String]) -> PeerConfiguration? {
|
||||||
// required wg fields
|
// required wg fields
|
||||||
guard let publicKeyString = attributes["PublicKey"] else { return nil }
|
guard let publicKeyString = attributes["PublicKey"] else { return nil }
|
||||||
guard let publicKey = Data(base64Encoded: publicKeyString), publicKey.count == 32 else { return nil }
|
guard let publicKey = Data(base64Encoded: publicKeyString), publicKey.count == 32 else { return nil }
|
||||||
|
@ -89,13 +89,13 @@ class WgQuickConfigFileParser {
|
||||||
return peer
|
return peer
|
||||||
}
|
}
|
||||||
|
|
||||||
var interfaceConfiguration: InterfaceConfiguration? = nil
|
var interfaceConfiguration: InterfaceConfiguration?
|
||||||
var peerConfigurations: [PeerConfiguration] = []
|
var peerConfigurations: [PeerConfiguration] = []
|
||||||
|
|
||||||
let lines = text.split(separator: "\n")
|
let lines = text.split(separator: "\n")
|
||||||
|
|
||||||
var parserState: ParserState = .notInASection
|
var parserState: ParserState = .notInASection
|
||||||
var attributes: [String:String] = [:]
|
var attributes: [String: String] = [:]
|
||||||
|
|
||||||
for (lineIndex, line) in lines.enumerated() {
|
for (lineIndex, line) in lines.enumerated() {
|
||||||
var trimmedLine: String
|
var trimmedLine: String
|
||||||
|
|
|
@ -17,8 +17,8 @@ struct InterfaceConfiguration: Codable {
|
||||||
var name: String
|
var name: String
|
||||||
var privateKey: Data
|
var privateKey: Data
|
||||||
var addresses: [IPAddressRange] = []
|
var addresses: [IPAddressRange] = []
|
||||||
var listenPort: UInt16? = nil
|
var listenPort: UInt16?
|
||||||
var mtu: UInt16? = nil
|
var mtu: UInt16?
|
||||||
var dns: [DNSServer] = []
|
var dns: [DNSServer] = []
|
||||||
|
|
||||||
var publicKey: Data {
|
var publicKey: Data {
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TunnelViewModel {
|
||||||
class InterfaceData {
|
class InterfaceData {
|
||||||
var scratchpad: [InterfaceField: String] = [:]
|
var scratchpad: [InterfaceField: String] = [:]
|
||||||
var fieldsWithError: Set<InterfaceField> = []
|
var fieldsWithError: Set<InterfaceField> = []
|
||||||
var validatedConfiguration: InterfaceConfiguration? = nil
|
var validatedConfiguration: InterfaceConfiguration?
|
||||||
|
|
||||||
subscript(field: InterfaceField) -> String {
|
subscript(field: InterfaceField) -> String {
|
||||||
get {
|
get {
|
||||||
|
@ -176,7 +176,7 @@ class TunnelViewModel {
|
||||||
var index: Int
|
var index: Int
|
||||||
var scratchpad: [PeerField: String] = [:]
|
var scratchpad: [PeerField: String] = [:]
|
||||||
var fieldsWithError: Set<PeerField> = []
|
var fieldsWithError: Set<PeerField> = []
|
||||||
var validatedConfiguration: PeerConfiguration? = nil
|
var validatedConfiguration: PeerConfiguration?
|
||||||
|
|
||||||
// For exclude private IPs
|
// For exclude private IPs
|
||||||
var shouldAllowExcludePrivateIPsControl: Bool = false /* Read-only from the VC's point of view */
|
var shouldAllowExcludePrivateIPsControl: Bool = false /* Read-only from the VC's point of view */
|
||||||
|
|
|
@ -26,7 +26,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
|
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool {
|
||||||
defer {
|
defer {
|
||||||
do {
|
do {
|
||||||
try FileManager.default.removeItem(at: url)
|
try FileManager.default.removeItem(at: url)
|
||||||
|
|
|
@ -6,7 +6,7 @@ import CoreData
|
||||||
import UIKit
|
import UIKit
|
||||||
|
|
||||||
protocol QRScanViewControllerDelegate: class {
|
protocol QRScanViewControllerDelegate: class {
|
||||||
func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController, completionHandler: (() ->Void)?)
|
func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController, completionHandler: (() -> Void)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
class QRScanViewController: UIViewController {
|
class QRScanViewController: UIViewController {
|
||||||
|
|
|
@ -12,13 +12,13 @@ class SettingsTableViewController: UITableViewController {
|
||||||
case exportZipArchive = "Export zip archive"
|
case exportZipArchive = "Export zip archive"
|
||||||
}
|
}
|
||||||
|
|
||||||
let settingsFieldsBySection : [[SettingsFields]] = [
|
let settingsFieldsBySection: [[SettingsFields]] = [
|
||||||
[.exportZipArchive],
|
[.exportZipArchive],
|
||||||
[.iosAppVersion, .goBackendVersion]
|
[.iosAppVersion, .goBackendVersion]
|
||||||
]
|
]
|
||||||
|
|
||||||
let tunnelsManager: TunnelsManager?
|
let tunnelsManager: TunnelsManager?
|
||||||
var wireguardCaptionedImage: (view: UIView, size: CGSize)? = nil
|
var wireguardCaptionedImage: (view: UIView, size: CGSize)?
|
||||||
|
|
||||||
init(tunnelsManager: TunnelsManager?) {
|
init(tunnelsManager: TunnelsManager?) {
|
||||||
self.tunnelsManager = tunnelsManager
|
self.tunnelsManager = tunnelsManager
|
||||||
|
@ -97,7 +97,7 @@ class SettingsTableViewController: UITableViewController {
|
||||||
// popoverPresentationController shall be non-nil on the iPad
|
// popoverPresentationController shall be non-nil on the iPad
|
||||||
activityVC.popoverPresentationController?.sourceView = sourceView
|
activityVC.popoverPresentationController?.sourceView = sourceView
|
||||||
present(activityVC, animated: true)
|
present(activityVC, animated: true)
|
||||||
|
|
||||||
} catch (let error) {
|
} catch (let error) {
|
||||||
showErrorAlert(title: "Unable to export", message: "There was an error exporting the tunnel configuration archive: \(String(describing: error))")
|
showErrorAlert(title: "Unable to export", message: "There was an error exporting the tunnel configuration archive: \(String(describing: error))")
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ class TunnelSettingsTableViewButtonCell: UITableViewCell {
|
||||||
get { return button.title(for: .normal) ?? "" }
|
get { return button.title(for: .normal) ?? "" }
|
||||||
set(value) { button.setTitle(value, for: .normal) }
|
set(value) { button.setTitle(value, for: .normal) }
|
||||||
}
|
}
|
||||||
var onTapped: (() -> Void)? = nil
|
var onTapped: (() -> Void)?
|
||||||
|
|
||||||
let button: UIButton
|
let button: UIButton
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ class TunnelDetailTableViewController: UITableViewController {
|
||||||
|
|
||||||
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
||||||
onConfirmed: @escaping (() -> Void)) {
|
onConfirmed: @escaping (() -> Void)) {
|
||||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in
|
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in
|
||||||
onConfirmed()
|
onConfirmed()
|
||||||
}
|
}
|
||||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
||||||
|
@ -221,11 +221,11 @@ class TunnelDetailTableViewStatusCell: UITableViewCell {
|
||||||
get { return statusSwitch.isUserInteractionEnabled }
|
get { return statusSwitch.isUserInteractionEnabled }
|
||||||
set(value) { statusSwitch.isUserInteractionEnabled = value }
|
set(value) { statusSwitch.isUserInteractionEnabled = value }
|
||||||
}
|
}
|
||||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
var onSwitchToggled: ((Bool) -> Void)?
|
||||||
private var isOnSwitchToggledHandlerEnabled: Bool = true
|
private var isOnSwitchToggledHandlerEnabled: Bool = true
|
||||||
|
|
||||||
let statusSwitch: UISwitch
|
let statusSwitch: UISwitch
|
||||||
private var statusObservervationToken: AnyObject? = nil
|
private var statusObservervationToken: AnyObject?
|
||||||
|
|
||||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||||
statusSwitch = UISwitch()
|
statusSwitch = UISwitch()
|
||||||
|
@ -382,7 +382,7 @@ class TunnelDetailTableViewButtonCell: UITableViewCell {
|
||||||
get { return button.tintColor == UIColor.red }
|
get { return button.tintColor == UIColor.red }
|
||||||
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
||||||
}
|
}
|
||||||
var onTapped: (() -> Void)? = nil
|
var onTapped: (() -> Void)?
|
||||||
|
|
||||||
let button: UIButton
|
let button: UIButton
|
||||||
var buttonStandardTintColor: UIColor
|
var buttonStandardTintColor: UIColor
|
||||||
|
|
|
@ -12,7 +12,7 @@ protocol TunnelEditTableViewControllerDelegate: class {
|
||||||
|
|
||||||
class TunnelEditTableViewController: UITableViewController {
|
class TunnelEditTableViewController: UITableViewController {
|
||||||
|
|
||||||
weak var delegate: TunnelEditTableViewControllerDelegate? = nil
|
weak var delegate: TunnelEditTableViewControllerDelegate?
|
||||||
|
|
||||||
let interfaceFieldsBySection: [[TunnelViewModel.InterfaceField]] = [
|
let interfaceFieldsBySection: [[TunnelViewModel.InterfaceField]] = [
|
||||||
[.name],
|
[.name],
|
||||||
|
@ -388,7 +388,7 @@ extension TunnelEditTableViewController {
|
||||||
|
|
||||||
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
||||||
onConfirmed: @escaping (() -> Void)) {
|
onConfirmed: @escaping (() -> Void)) {
|
||||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in
|
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in
|
||||||
onConfirmed()
|
onConfirmed()
|
||||||
}
|
}
|
||||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
||||||
|
@ -440,8 +440,8 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
||||||
set(value) { valueTextField.keyboardType = value }
|
set(value) { valueTextField.keyboardType = value }
|
||||||
}
|
}
|
||||||
|
|
||||||
var onValueChanged: ((String) -> Void)? = nil
|
var onValueChanged: ((String) -> Void)?
|
||||||
var onValueBeingEdited: ((String) -> Void)? = nil
|
var onValueBeingEdited: ((String) -> Void)?
|
||||||
|
|
||||||
let keyLabel: UILabel
|
let keyLabel: UILabel
|
||||||
let valueTextField: UITextField
|
let valueTextField: UITextField
|
||||||
|
@ -534,7 +534,7 @@ class TunnelEditTableViewButtonCell: UITableViewCell {
|
||||||
get { return button.tintColor == UIColor.red }
|
get { return button.tintColor == UIColor.red }
|
||||||
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
||||||
}
|
}
|
||||||
var onTapped: (() -> Void)? = nil
|
var onTapped: (() -> Void)?
|
||||||
|
|
||||||
let button: UIButton
|
let button: UIButton
|
||||||
var buttonStandardTintColor: UIColor
|
var buttonStandardTintColor: UIColor
|
||||||
|
@ -586,7 +586,7 @@ class TunnelEditTableViewSwitchCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
var onSwitchToggled: ((Bool) -> Void)?
|
||||||
|
|
||||||
let switchView: UISwitch
|
let switchView: UISwitch
|
||||||
|
|
||||||
|
|
|
@ -6,12 +6,12 @@ import MobileCoreServices
|
||||||
|
|
||||||
class TunnelsListTableViewController: UIViewController {
|
class TunnelsListTableViewController: UIViewController {
|
||||||
|
|
||||||
var tunnelsManager: TunnelsManager? = nil
|
var tunnelsManager: TunnelsManager?
|
||||||
var onTunnelsManagerReady: ((TunnelsManager) -> Void)? = nil
|
var onTunnelsManagerReady: ((TunnelsManager) -> Void)?
|
||||||
|
|
||||||
var busyIndicator: UIActivityIndicatorView? = nil
|
var busyIndicator: UIActivityIndicatorView?
|
||||||
var centeredAddButton: BorderedTextButton? = nil
|
var centeredAddButton: BorderedTextButton?
|
||||||
var tableView: UITableView? = nil
|
var tableView: UITableView?
|
||||||
|
|
||||||
override func viewDidLoad() {
|
override func viewDidLoad() {
|
||||||
super.viewDidLoad()
|
super.viewDidLoad()
|
||||||
|
@ -88,17 +88,17 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
@objc func addButtonTapped(sender: AnyObject) {
|
@objc func addButtonTapped(sender: AnyObject) {
|
||||||
if (self.tunnelsManager == nil) { return } // Do nothing until we've loaded the tunnels
|
if (self.tunnelsManager == nil) { return } // Do nothing until we've loaded the tunnels
|
||||||
let alert = UIAlertController(title: "", message: "Add a new WireGuard tunnel", preferredStyle: .actionSheet)
|
let alert = UIAlertController(title: "", message: "Add a new WireGuard tunnel", preferredStyle: .actionSheet)
|
||||||
let importFileAction = UIAlertAction(title: "Create from file or archive", style: .default) { [weak self] (action) in
|
let importFileAction = UIAlertAction(title: "Create from file or archive", style: .default) { [weak self] (_) in
|
||||||
self?.presentViewControllerForFileImport()
|
self?.presentViewControllerForFileImport()
|
||||||
}
|
}
|
||||||
alert.addAction(importFileAction)
|
alert.addAction(importFileAction)
|
||||||
|
|
||||||
let scanQRCodeAction = UIAlertAction(title: "Create from QR code", style: .default) { [weak self] (action) in
|
let scanQRCodeAction = UIAlertAction(title: "Create from QR code", style: .default) { [weak self] (_) in
|
||||||
self?.presentViewControllerForScanningQRCode()
|
self?.presentViewControllerForScanningQRCode()
|
||||||
}
|
}
|
||||||
alert.addAction(scanQRCodeAction)
|
alert.addAction(scanQRCodeAction)
|
||||||
|
|
||||||
let createFromScratchAction = UIAlertAction(title: "Create from scratch", style: .default) { [weak self] (action) in
|
let createFromScratchAction = UIAlertAction(title: "Create from scratch", style: .default) { [weak self] (_) in
|
||||||
if let s = self, let tunnelsManager = s.tunnelsManager {
|
if let s = self, let tunnelsManager = s.tunnelsManager {
|
||||||
s.presentViewControllerForTunnelCreation(tunnelsManager: tunnelsManager, tunnelConfiguration: nil)
|
s.presentViewControllerForTunnelCreation(tunnelsManager: tunnelsManager, tunnelConfiguration: nil)
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines)
|
let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
if let fileContents = try? String(contentsOf: url),
|
if let fileContents = try? String(contentsOf: url),
|
||||||
let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) {
|
let tunnelConfiguration = try? WgQuickConfigFileParser.parse(fileContents, name: fileBaseName) {
|
||||||
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in
|
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (_, error) in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
ErrorPresenter.showErrorAlert(error: error, from: self)
|
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||||
}
|
}
|
||||||
|
@ -203,7 +203,7 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
showErrorAlert(title: "Unable to read zip archive", message: "Unexpected error: \(String(describing: error))")
|
showErrorAlert(title: "Unable to read zip archive", message: "Unexpected error: \(String(describing: error))")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i, unarchivedFile) in unarchivedFiles.enumerated().reversed() {
|
for (i, unarchivedFile) in unarchivedFiles.enumerated().reversed() {
|
||||||
let fileBaseName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent
|
let fileBaseName = URL(string: unarchivedFile.fileName)?.deletingPathExtension().lastPathComponent
|
||||||
if let trimmedName = fileBaseName?.trimmingCharacters(in: .whitespacesAndNewlines), !trimmedName.isEmpty {
|
if let trimmedName = fileBaseName?.trimmingCharacters(in: .whitespacesAndNewlines), !trimmedName.isEmpty {
|
||||||
|
@ -218,7 +218,7 @@ class TunnelsListTableViewController: UIViewController {
|
||||||
}
|
}
|
||||||
guard let tunnelsManager = tunnelsManager else { return }
|
guard let tunnelsManager = tunnelsManager else { return }
|
||||||
unarchivedFiles.sort { $0.fileName < $1.fileName }
|
unarchivedFiles.sort { $0.fileName < $1.fileName }
|
||||||
var lastFileName : String?
|
var lastFileName: String?
|
||||||
var configs: [TunnelConfiguration] = []
|
var configs: [TunnelConfiguration] = []
|
||||||
for file in unarchivedFiles {
|
for file in unarchivedFiles {
|
||||||
if file.fileName == lastFileName {
|
if file.fileName == lastFileName {
|
||||||
|
@ -258,8 +258,8 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
|
||||||
|
|
||||||
extension TunnelsListTableViewController: QRScanViewControllerDelegate {
|
extension TunnelsListTableViewController: QRScanViewControllerDelegate {
|
||||||
func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController,
|
func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController,
|
||||||
completionHandler: (() ->Void)?) {
|
completionHandler: (() -> Void)?) {
|
||||||
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in
|
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (_, error) in
|
||||||
if let error = error {
|
if let error = error {
|
||||||
ErrorPresenter.showErrorAlert(error: error, from: qrScanViewController, onDismissal: completionHandler)
|
ErrorPresenter.showErrorAlert(error: error, from: qrScanViewController, onDismissal: completionHandler)
|
||||||
} else {
|
} else {
|
||||||
|
@ -354,7 +354,7 @@ extension TunnelsListTableViewController: TunnelsManagerDelegate {
|
||||||
func tunnelMoved(at oldIndex: Int, to newIndex: Int) {
|
func tunnelMoved(at oldIndex: Int, to newIndex: Int) {
|
||||||
tableView?.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0))
|
tableView?.moveRow(at: IndexPath(row: oldIndex, section: 0), to: IndexPath(row: newIndex, section: 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
func tunnelRemoved(at index: Int) {
|
func tunnelRemoved(at index: Int) {
|
||||||
tableView?.deleteRows(at: [IndexPath(row: index, section: 0)], with: .automatic)
|
tableView?.deleteRows(at: [IndexPath(row: index, section: 0)], with: .automatic)
|
||||||
centeredAddButton?.isHidden = (tunnelsManager?.numberOfTunnels() ?? 0 > 0)
|
centeredAddButton?.isHidden = (tunnelsManager?.numberOfTunnels() ?? 0 > 0)
|
||||||
|
@ -377,14 +377,14 @@ class TunnelsListTableViewCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
var onSwitchToggled: ((Bool) -> Void)?
|
||||||
|
|
||||||
let nameLabel: UILabel
|
let nameLabel: UILabel
|
||||||
let busyIndicator: UIActivityIndicatorView
|
let busyIndicator: UIActivityIndicatorView
|
||||||
let statusSwitch: UISwitch
|
let statusSwitch: UISwitch
|
||||||
|
|
||||||
private var statusObservervationToken: AnyObject? = nil
|
private var statusObservervationToken: AnyObject?
|
||||||
private var nameObservervationToken: AnyObject? = nil
|
private var nameObservervationToken: AnyObject?
|
||||||
|
|
||||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||||
nameLabel = UILabel()
|
nameLabel = UILabel()
|
||||||
|
@ -466,7 +466,7 @@ class BorderedTextButton: UIView {
|
||||||
set(value) { button.setTitle(value, for: .normal) }
|
set(value) { button.setTitle(value, for: .normal) }
|
||||||
}
|
}
|
||||||
|
|
||||||
var onTapped: (() -> Void)? = nil
|
var onTapped: (() -> Void)?
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
button = UIButton(type: .system)
|
button = UIButton(type: .system)
|
||||||
|
@ -491,4 +491,3 @@ class BorderedTextButton: UIView {
|
||||||
fatalError("init(coder:) has not been implemented")
|
fatalError("init(coder:) has not been implemented")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,8 +109,8 @@ extension DNSResolver {
|
||||||
// getaddrinfo succeeded
|
// getaddrinfo succeeded
|
||||||
let ipv4Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET_ADDRSTRLEN))
|
let ipv4Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET_ADDRSTRLEN))
|
||||||
let ipv6Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET6_ADDRSTRLEN))
|
let ipv6Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET6_ADDRSTRLEN))
|
||||||
var ipv4AddressString: String? = nil
|
var ipv4AddressString: String?
|
||||||
var ipv6AddressString: String? = nil
|
var ipv6AddressString: String?
|
||||||
while (resultPointer != nil) {
|
while (resultPointer != nil) {
|
||||||
let result = resultPointer!.pointee
|
let result = resultPointer!.pointee
|
||||||
resultPointer = result.ai_next
|
resultPointer = result.ai_next
|
||||||
|
|
|
@ -6,8 +6,8 @@ import Network
|
||||||
|
|
||||||
class PacketTunnelOptionsGenerator {
|
class PacketTunnelOptionsGenerator {
|
||||||
static func generateOptions(from tc: TunnelConfiguration,
|
static func generateOptions(from tc: TunnelConfiguration,
|
||||||
withResolvedEndpoints resolvedEndpoints: [Endpoint?]) -> [String:NSObject] {
|
withResolvedEndpoints resolvedEndpoints: [Endpoint?]) -> [String: NSObject] {
|
||||||
var options: [String:NSObject] = [:]
|
var options: [String: NSObject] = [:]
|
||||||
|
|
||||||
// Interface name
|
// Interface name
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ enum TunnelManagementError: Error {
|
||||||
class TunnelsManager {
|
class TunnelsManager {
|
||||||
|
|
||||||
private var tunnels: [TunnelContainer]
|
private var tunnels: [TunnelContainer]
|
||||||
weak var delegate: TunnelsManagerDelegate? = nil
|
weak var delegate: TunnelsManagerDelegate?
|
||||||
|
|
||||||
private var isAddingTunnel: Bool = false
|
private var isAddingTunnel: Bool = false
|
||||||
private var isModifyingTunnel: Bool = false
|
private var isModifyingTunnel: Bool = false
|
||||||
|
@ -58,7 +58,7 @@ class TunnelsManager {
|
||||||
completionHandler(nil, TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
completionHandler(nil, TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if self.tunnels.contains(where: { $0.name == tunnelName }) {
|
if self.tunnels.contains(where: { $0.name == tunnelName }) {
|
||||||
completionHandler(nil, TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
completionHandler(nil, TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
||||||
return
|
return
|
||||||
|
@ -97,7 +97,7 @@ class TunnelsManager {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let tail = tunnelConfigurations.dropFirst()
|
let tail = tunnelConfigurations.dropFirst()
|
||||||
self.add(tunnelConfiguration: head) { [weak self, tail] (tunnel, error) in
|
self.add(tunnelConfiguration: head) { [weak self, tail] (_, error) in
|
||||||
DispatchQueue.main.async {
|
DispatchQueue.main.async {
|
||||||
self?.addMultiple(tunnelConfigurations: tail, numberSuccessful: numberSuccessful + (error == nil ? 1 : 0), completionHandler: completionHandler)
|
self?.addMultiple(tunnelConfigurations: tail, numberSuccessful: numberSuccessful + (error == nil ? 1 : 0), completionHandler: completionHandler)
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ class TunnelsManager {
|
||||||
|
|
||||||
let tunnelProviderManager = tunnel.tunnelProvider
|
let tunnelProviderManager = tunnel.tunnelProvider
|
||||||
let isNameChanged = (tunnelName != tunnelProviderManager.localizedDescription)
|
let isNameChanged = (tunnelName != tunnelProviderManager.localizedDescription)
|
||||||
var oldName: String? = nil
|
var oldName: String?
|
||||||
if (isNameChanged) {
|
if (isNameChanged) {
|
||||||
if self.tunnels.contains(where: { $0.name == tunnelName }) {
|
if self.tunnels.contains(where: { $0.name == tunnelName }) {
|
||||||
completionHandler(TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
completionHandler(TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
||||||
|
@ -238,7 +238,7 @@ class TunnelContainer: NSObject {
|
||||||
fileprivate let tunnelProvider: NETunnelProviderManager
|
fileprivate let tunnelProvider: NETunnelProviderManager
|
||||||
private var statusObservationToken: AnyObject?
|
private var statusObservationToken: AnyObject?
|
||||||
|
|
||||||
private var dnsResolver: DNSResolver? = nil
|
private var dnsResolver: DNSResolver?
|
||||||
|
|
||||||
init(tunnel: NETunnelProviderManager) {
|
init(tunnel: NETunnelProviderManager) {
|
||||||
self.name = tunnel.localizedDescription ?? "Unnamed"
|
self.name = tunnel.localizedDescription ?? "Unnamed"
|
||||||
|
@ -314,9 +314,9 @@ class TunnelContainer: NSObject {
|
||||||
assert(resolvedEndpoints.allSatisfy { (resolvedEndpoint) in
|
assert(resolvedEndpoints.allSatisfy { (resolvedEndpoint) in
|
||||||
guard let resolvedEndpoint = resolvedEndpoint else { return true }
|
guard let resolvedEndpoint = resolvedEndpoint else { return true }
|
||||||
switch (resolvedEndpoint.host) {
|
switch (resolvedEndpoint.host) {
|
||||||
case .ipv4(_): return true
|
case .ipv4: return true
|
||||||
case .ipv6(_): return true
|
case .ipv6: return true
|
||||||
case .name(_, _): return false
|
case .name: return false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue