Global: run through swiftlint
This commit is contained in:
parent
b3b63b5f5d
commit
355a555cc4
|
@ -89,7 +89,7 @@ class WgQuickConfigFileParser {
|
|||
return peer
|
||||
}
|
||||
|
||||
var interfaceConfiguration: InterfaceConfiguration? = nil
|
||||
var interfaceConfiguration: InterfaceConfiguration?
|
||||
var peerConfigurations: [PeerConfiguration] = []
|
||||
|
||||
let lines = text.split(separator: "\n")
|
||||
|
|
|
@ -17,8 +17,8 @@ struct InterfaceConfiguration: Codable {
|
|||
var name: String
|
||||
var privateKey: Data
|
||||
var addresses: [IPAddressRange] = []
|
||||
var listenPort: UInt16? = nil
|
||||
var mtu: UInt16? = nil
|
||||
var listenPort: UInt16?
|
||||
var mtu: UInt16?
|
||||
var dns: [DNSServer] = []
|
||||
|
||||
var publicKey: Data {
|
||||
|
|
|
@ -39,7 +39,7 @@ class TunnelViewModel {
|
|||
class InterfaceData {
|
||||
var scratchpad: [InterfaceField: String] = [:]
|
||||
var fieldsWithError: Set<InterfaceField> = []
|
||||
var validatedConfiguration: InterfaceConfiguration? = nil
|
||||
var validatedConfiguration: InterfaceConfiguration?
|
||||
|
||||
subscript(field: InterfaceField) -> String {
|
||||
get {
|
||||
|
@ -176,7 +176,7 @@ class TunnelViewModel {
|
|||
var index: Int
|
||||
var scratchpad: [PeerField: String] = [:]
|
||||
var fieldsWithError: Set<PeerField> = []
|
||||
var validatedConfiguration: PeerConfiguration? = nil
|
||||
var validatedConfiguration: PeerConfiguration?
|
||||
|
||||
// For exclude private IPs
|
||||
var shouldAllowExcludePrivateIPsControl: Bool = false /* Read-only from the VC's point of view */
|
||||
|
|
|
@ -18,7 +18,7 @@ class SettingsTableViewController: UITableViewController {
|
|||
]
|
||||
|
||||
let tunnelsManager: TunnelsManager?
|
||||
var wireguardCaptionedImage: (view: UIView, size: CGSize)? = nil
|
||||
var wireguardCaptionedImage: (view: UIView, size: CGSize)?
|
||||
|
||||
init(tunnelsManager: TunnelsManager?) {
|
||||
self.tunnelsManager = tunnelsManager
|
||||
|
@ -201,7 +201,7 @@ class TunnelSettingsTableViewButtonCell: UITableViewCell {
|
|||
get { return button.title(for: .normal) ?? "" }
|
||||
set(value) { button.setTitle(value, for: .normal) }
|
||||
}
|
||||
var onTapped: (() -> Void)? = nil
|
||||
var onTapped: (() -> Void)?
|
||||
|
||||
let button: UIButton
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ class TunnelDetailTableViewController: UITableViewController {
|
|||
|
||||
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
||||
onConfirmed: @escaping (() -> Void)) {
|
||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in
|
||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in
|
||||
onConfirmed()
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
||||
|
@ -221,11 +221,11 @@ class TunnelDetailTableViewStatusCell: UITableViewCell {
|
|||
get { return statusSwitch.isUserInteractionEnabled }
|
||||
set(value) { statusSwitch.isUserInteractionEnabled = value }
|
||||
}
|
||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
||||
var onSwitchToggled: ((Bool) -> Void)?
|
||||
private var isOnSwitchToggledHandlerEnabled: Bool = true
|
||||
|
||||
let statusSwitch: UISwitch
|
||||
private var statusObservervationToken: AnyObject? = nil
|
||||
private var statusObservervationToken: AnyObject?
|
||||
|
||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||
statusSwitch = UISwitch()
|
||||
|
@ -382,7 +382,7 @@ class TunnelDetailTableViewButtonCell: UITableViewCell {
|
|||
get { return button.tintColor == UIColor.red }
|
||||
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
||||
}
|
||||
var onTapped: (() -> Void)? = nil
|
||||
var onTapped: (() -> Void)?
|
||||
|
||||
let button: UIButton
|
||||
var buttonStandardTintColor: UIColor
|
||||
|
|
|
@ -12,7 +12,7 @@ protocol TunnelEditTableViewControllerDelegate: class {
|
|||
|
||||
class TunnelEditTableViewController: UITableViewController {
|
||||
|
||||
weak var delegate: TunnelEditTableViewControllerDelegate? = nil
|
||||
weak var delegate: TunnelEditTableViewControllerDelegate?
|
||||
|
||||
let interfaceFieldsBySection: [[TunnelViewModel.InterfaceField]] = [
|
||||
[.name],
|
||||
|
@ -388,7 +388,7 @@ extension TunnelEditTableViewController {
|
|||
|
||||
func showConfirmationAlert(message: String, buttonTitle: String, from sourceView: UIView,
|
||||
onConfirmed: @escaping (() -> Void)) {
|
||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (action) in
|
||||
let destroyAction = UIAlertAction(title: buttonTitle, style: .destructive) { (_) in
|
||||
onConfirmed()
|
||||
}
|
||||
let cancelAction = UIAlertAction(title: "Cancel", style: .cancel)
|
||||
|
@ -440,8 +440,8 @@ class TunnelEditTableViewKeyValueCell: CopyableLabelTableViewCell {
|
|||
set(value) { valueTextField.keyboardType = value }
|
||||
}
|
||||
|
||||
var onValueChanged: ((String) -> Void)? = nil
|
||||
var onValueBeingEdited: ((String) -> Void)? = nil
|
||||
var onValueChanged: ((String) -> Void)?
|
||||
var onValueBeingEdited: ((String) -> Void)?
|
||||
|
||||
let keyLabel: UILabel
|
||||
let valueTextField: UITextField
|
||||
|
@ -534,7 +534,7 @@ class TunnelEditTableViewButtonCell: UITableViewCell {
|
|||
get { return button.tintColor == UIColor.red }
|
||||
set(value) { button.tintColor = value ? UIColor.red : buttonStandardTintColor }
|
||||
}
|
||||
var onTapped: (() -> Void)? = nil
|
||||
var onTapped: (() -> Void)?
|
||||
|
||||
let button: UIButton
|
||||
var buttonStandardTintColor: UIColor
|
||||
|
@ -586,7 +586,7 @@ class TunnelEditTableViewSwitchCell: UITableViewCell {
|
|||
}
|
||||
}
|
||||
|
||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
||||
var onSwitchToggled: ((Bool) -> Void)?
|
||||
|
||||
let switchView: UISwitch
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@ import MobileCoreServices
|
|||
|
||||
class TunnelsListTableViewController: UIViewController {
|
||||
|
||||
var tunnelsManager: TunnelsManager? = nil
|
||||
var onTunnelsManagerReady: ((TunnelsManager) -> Void)? = nil
|
||||
var tunnelsManager: TunnelsManager?
|
||||
var onTunnelsManagerReady: ((TunnelsManager) -> Void)?
|
||||
|
||||
var busyIndicator: UIActivityIndicatorView? = nil
|
||||
var centeredAddButton: BorderedTextButton? = nil
|
||||
var tableView: UITableView? = nil
|
||||
var busyIndicator: UIActivityIndicatorView?
|
||||
var centeredAddButton: BorderedTextButton?
|
||||
var tableView: UITableView?
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
@ -88,17 +88,17 @@ class TunnelsListTableViewController: UIViewController {
|
|||
@objc func addButtonTapped(sender: AnyObject) {
|
||||
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 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()
|
||||
}
|
||||
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()
|
||||
}
|
||||
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 {
|
||||
s.presentViewControllerForTunnelCreation(tunnelsManager: tunnelsManager, tunnelConfiguration: nil)
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ class TunnelsListTableViewController: UIViewController {
|
|||
let fileBaseName = url.deletingPathExtension().lastPathComponent.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
if let fileContents = try? String(contentsOf: url),
|
||||
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 {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: self)
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ extension TunnelsListTableViewController: UIDocumentPickerDelegate {
|
|||
extension TunnelsListTableViewController: QRScanViewControllerDelegate {
|
||||
func addScannedQRCode(tunnelConfiguration: TunnelConfiguration, qrScanViewController: QRScanViewController,
|
||||
completionHandler: (() -> Void)?) {
|
||||
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (tunnel, error) in
|
||||
tunnelsManager?.add(tunnelConfiguration: tunnelConfiguration) { (_, error) in
|
||||
if let error = error {
|
||||
ErrorPresenter.showErrorAlert(error: error, from: qrScanViewController, onDismissal: completionHandler)
|
||||
} else {
|
||||
|
@ -377,14 +377,14 @@ class TunnelsListTableViewCell: UITableViewCell {
|
|||
}
|
||||
}
|
||||
}
|
||||
var onSwitchToggled: ((Bool) -> Void)? = nil
|
||||
var onSwitchToggled: ((Bool) -> Void)?
|
||||
|
||||
let nameLabel: UILabel
|
||||
let busyIndicator: UIActivityIndicatorView
|
||||
let statusSwitch: UISwitch
|
||||
|
||||
private var statusObservervationToken: AnyObject? = nil
|
||||
private var nameObservervationToken: AnyObject? = nil
|
||||
private var statusObservervationToken: AnyObject?
|
||||
private var nameObservervationToken: AnyObject?
|
||||
|
||||
override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
|
||||
nameLabel = UILabel()
|
||||
|
@ -466,7 +466,7 @@ class BorderedTextButton: UIView {
|
|||
set(value) { button.setTitle(value, for: .normal) }
|
||||
}
|
||||
|
||||
var onTapped: (() -> Void)? = nil
|
||||
var onTapped: (() -> Void)?
|
||||
|
||||
init() {
|
||||
button = UIButton(type: .system)
|
||||
|
@ -491,4 +491,3 @@ class BorderedTextButton: UIView {
|
|||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -109,8 +109,8 @@ extension DNSResolver {
|
|||
// getaddrinfo succeeded
|
||||
let ipv4Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET_ADDRSTRLEN))
|
||||
let ipv6Buffer = UnsafeMutablePointer<Int8>.allocate(capacity: Int(INET6_ADDRSTRLEN))
|
||||
var ipv4AddressString: String? = nil
|
||||
var ipv6AddressString: String? = nil
|
||||
var ipv4AddressString: String?
|
||||
var ipv6AddressString: String?
|
||||
while (resultPointer != nil) {
|
||||
let result = resultPointer!.pointee
|
||||
resultPointer = result.ai_next
|
||||
|
|
|
@ -32,7 +32,7 @@ enum TunnelManagementError: Error {
|
|||
class TunnelsManager {
|
||||
|
||||
private var tunnels: [TunnelContainer]
|
||||
weak var delegate: TunnelsManagerDelegate? = nil
|
||||
weak var delegate: TunnelsManagerDelegate?
|
||||
|
||||
private var isAddingTunnel: Bool = false
|
||||
private var isModifyingTunnel: Bool = false
|
||||
|
@ -97,7 +97,7 @@ class TunnelsManager {
|
|||
return
|
||||
}
|
||||
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 {
|
||||
self?.addMultiple(tunnelConfigurations: tail, numberSuccessful: numberSuccessful + (error == nil ? 1 : 0), completionHandler: completionHandler)
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ class TunnelsManager {
|
|||
|
||||
let tunnelProviderManager = tunnel.tunnelProvider
|
||||
let isNameChanged = (tunnelName != tunnelProviderManager.localizedDescription)
|
||||
var oldName: String? = nil
|
||||
var oldName: String?
|
||||
if (isNameChanged) {
|
||||
if self.tunnels.contains(where: { $0.name == tunnelName }) {
|
||||
completionHandler(TunnelManagementError.tunnelAlreadyExistsWithThatName)
|
||||
|
@ -238,7 +238,7 @@ class TunnelContainer: NSObject {
|
|||
fileprivate let tunnelProvider: NETunnelProviderManager
|
||||
private var statusObservationToken: AnyObject?
|
||||
|
||||
private var dnsResolver: DNSResolver? = nil
|
||||
private var dnsResolver: DNSResolver?
|
||||
|
||||
init(tunnel: NETunnelProviderManager) {
|
||||
self.name = tunnel.localizedDescription ?? "Unnamed"
|
||||
|
@ -314,9 +314,9 @@ class TunnelContainer: NSObject {
|
|||
assert(resolvedEndpoints.allSatisfy { (resolvedEndpoint) in
|
||||
guard let resolvedEndpoint = resolvedEndpoint else { return true }
|
||||
switch (resolvedEndpoint.host) {
|
||||
case .ipv4(_): return true
|
||||
case .ipv6(_): return true
|
||||
case .name(_, _): return false
|
||||
case .ipv4: return true
|
||||
case .ipv6: return true
|
||||
case .name: return false
|
||||
}
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue