Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: connect to xpc on vpn start#40

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 12 commits intomainfromethan/use-fqdn-as-name
Feb 12, 2025
Merged
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 26 additions & 11 deletionsCoder Desktop/Coder Desktop/VPNService.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -70,8 +70,6 @@ final class CoderVPNService: NSObject, VPNService {
Task {
await loadNetworkExtensionConfig()
}
xpc.connect()
xpc.getPeerState()
NotificationCenter.default.addObserver(
self,
selector: #selector(vpnDidUpdate(_:)),
Expand All@@ -93,8 +91,6 @@ final class CoderVPNService: NSObject, VPNService {
}

await startTunnel()
xpc.connect()
xpc.ping()
logger.debug("network extension enabled")
}

Expand DownExpand Up@@ -162,28 +158,47 @@ final class CoderVPNService: NSObject, VPNService {
}

extension CoderVPNService {
// The number of NETunnelProviderSession states makes the excessive branching
// necessary.
// swiftlint:disable:next cyclomatic_complexity
@objc private func vpnDidUpdate(_ notification: Notification) {
guard let connection = notification.object as? NETunnelProviderSession else {
return
}
switch connection.status {
case .disconnected:
switch (tunnelState, connection.status) {
// Any -> Disconnected: Update UI w/ error if present
case (_, .disconnected):
connection.fetchLastDisconnectError { err in
self.tunnelState = if let err {
.failed(.internalError(err.localizedDescription))
} else {
.disabled
}
}
case .connecting:
// Connecting -> Connecting: no-op
case (.connecting, .connecting):
break
// Connected -> Connected: no-op
case (.connected, .connected):
break
// Non-connecting -> Connecting: Establish XPC
case (_, .connecting):
xpc.connect()
xpc.ping()
tunnelState = .connecting
case .connected:
// Non-connected -> Connected: Retrieve Peers
case (_, .connected):
xpc.connect()
xpc.getPeerState()
tunnelState = .connected
case .reasserting:
// Any -> Reasserting
case (_, .reasserting):
tunnelState = .connecting
case .disconnecting:
// Any -> Disconnecting
case (_, .disconnecting):
tunnelState = .disconnecting
case .invalid:
// Any -> Invalid
case (_, .invalid):
tunnelState = .failed(.networkExtensionError(.unconfigured))
@unknown default:
tunnelState = .disabled
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp