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

chore: dont stop coder connect on device sleep#151

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 1 commit intomainfromethan/dont-stop-vpn-on-sleep
May 8, 2025
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletionsCoder-Desktop/VPN/Manager.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,10 +32,9 @@ actor Manager {
let sessionConfig = URLSessionConfiguration.default
// The tunnel might be asked to start before the network interfaces have woken up from sleep
sessionConfig.waitsForConnectivity = true
// URLSession's waiting for connectivity sometimes hangs even when
// the network is up so this is deliberately short (30s) to avoid a
// poor UX where it appears stuck.
sessionConfig.timeoutIntervalForResource = 30
// Timeout after 5 minutes, or if there's no data for 60 seconds
sessionConfig.timeoutIntervalForRequest = 60
sessionConfig.timeoutIntervalForResource = 300
try await download(src: dylibPath, dest: dest, urlSession: URLSession(configuration: sessionConfig))
} catch {
throw .download(error)
Expand Down
32 changes: 2 additions & 30 deletionsCoder-Desktop/VPN/PacketTunnelProvider.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,7 +57,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
start(completionHandler)
}

// called by `startTunnel` and on `wake`
// called by `startTunnel`
func start(_ completionHandler: @escaping (Error?) -> Void) {
guard let proto = protocolConfiguration as? NETunnelProviderProtocol,
let baseAccessURL = proto.serverAddress
Expand DownExpand Up@@ -108,7 +108,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
teardown(completionHandler)
}

// called by `stopTunnel` and `sleep`
// called by `stopTunnel`
func teardown(_ completionHandler: @escaping () -> Void) {
guard let manager else {
logger.error("teardown called with nil Manager")
Expand DownExpand Up@@ -138,34 +138,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
}
}

// sleep and wake reference: https://developer.apple.com/forums/thread/95988
override func sleep(completionHandler: @escaping () -> Void) {
logger.debug("sleep called")
teardown(completionHandler)
}

override func wake() {
// It's possible the tunnel is still starting up, if it is, wake should
// be a no-op.
guard !reasserting else { return }
guard manager == nil else {
logger.error("wake called with non-nil Manager")
return
}
logger.debug("wake called")
reasserting = true
currentSettings = .init(tunnelRemoteAddress: "127.0.0.1")
setTunnelNetworkSettings(nil)
start { error in
if let error {
self.logger.error("error starting tunnel after wake: \(error.localizedDescription)")
self.cancelTunnelWithError(error)
} else {
self.reasserting = false
}
}
}

// Wrapper around `setTunnelNetworkSettings` that supports merging updates
func applyTunnelNetworkSettings(_ diff: Vpn_NetworkSettingsRequest) async throws {
logger.debug("applying settings diff: \(diff.debugDescription, privacy: .public)")
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp