Enable SwiftLint inside of Xcode
This commit also fixes all linter warnings and errors.
This commit is contained in:
parent
941d465570
commit
3c30a4b336
7 changed files with 130 additions and 21 deletions
|
|
@ -4,7 +4,6 @@ import SwiftUI
|
|||
@main
|
||||
@MainActor
|
||||
struct BurrowApp: App {
|
||||
|
||||
static let tunnel = Tunnel { manager, proto in
|
||||
proto.serverAddress = "hackclub.com"
|
||||
manager.localizedDescription = "Burrow"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ extension Tunnel {
|
|||
return "Disabled"
|
||||
case .connecting:
|
||||
return "Connecting"
|
||||
case .connected(_):
|
||||
case .connected:
|
||||
return "Connected"
|
||||
case .disconnecting:
|
||||
return "Disconnecting"
|
||||
|
|
@ -40,4 +40,3 @@ extension Tunnel {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import Combine
|
||||
import NetworkExtension
|
||||
import SwiftUI
|
||||
import Combine
|
||||
|
||||
@MainActor
|
||||
class Tunnel: ObservableObject {
|
||||
|
|
@ -61,10 +61,6 @@ class Tunnel: ObservableObject {
|
|||
tasks = [statusTask, configurationTask]
|
||||
}
|
||||
|
||||
deinit {
|
||||
tasks.forEach { $0.cancel() }
|
||||
}
|
||||
|
||||
func update() async {
|
||||
do {
|
||||
managers = try await NETunnelProviderManager.managers
|
||||
|
|
@ -96,7 +92,7 @@ class Tunnel: ObservableObject {
|
|||
let proto = NETunnelProviderProtocol()
|
||||
proto.providerBundleIdentifier = bundleIdentifier
|
||||
manager.protocolConfiguration = proto
|
||||
|
||||
|
||||
configure(manager, proto)
|
||||
try await manager.save()
|
||||
}
|
||||
|
|
@ -111,10 +107,14 @@ class Tunnel: ObservableObject {
|
|||
guard let manager = managers?.first else { return }
|
||||
manager.connection.stopVPNTunnel()
|
||||
}
|
||||
|
||||
deinit {
|
||||
tasks.forEach { $0.cancel() }
|
||||
}
|
||||
}
|
||||
|
||||
private extension NEVPNConnection {
|
||||
var tunnelStatus: Tunnel.Status {
|
||||
extension NEVPNConnection {
|
||||
var tunnelStatus: Tunnel.Status {
|
||||
switch status {
|
||||
case .connected:
|
||||
return .connected(connectedDate!)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
import SwiftUI
|
||||
|
||||
struct TunnelView: View {
|
||||
|
||||
@ObservedObject
|
||||
var tunnel: Tunnel
|
||||
@ObservedObject var tunnel: Tunnel
|
||||
|
||||
var body: some View {
|
||||
VStack {
|
||||
Text(verbatim: tunnel.status.description)
|
||||
switch tunnel.status {
|
||||
case .connected(_):
|
||||
case .connected:
|
||||
Button("Disconnect", action: stop)
|
||||
case .permissionRequired:
|
||||
Button("Allow", action: configure)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue