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

Commitf039526

Browse files
chore: dont stop coder connect on device sleep (#151)
Closes#88.Withcoder/internal#563 resolved, there's no need to stop the VPN on sleep, as when the device wakes the tunnel will have the correct workspace & agent state.However, if the Coder deployment doesn't include the patch incoder/coder#17598 (presumably v2.23 or later), the UI state will go out of sync when the device is slept or internet connection is lost. I think this is fine honestly, and I don't think it's worth doing a server version check to determine whether we should stop the VPN on sleep.
1 parent31bdfa5 commitf039526

File tree

2 files changed

+5
-34
lines changed

2 files changed

+5
-34
lines changed

‎Coder-Desktop/VPN/Manager.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ actor Manager {
3232
letsessionConfig=URLSessionConfiguration.default
3333
// The tunnel might be asked to start before the network interfaces have woken up from sleep
3434
sessionConfig.waitsForConnectivity=true
35-
// URLSession's waiting for connectivity sometimes hangs even when
36-
// the network is up so this is deliberately short (30s) to avoid a
37-
// poor UX where it appears stuck.
38-
sessionConfig.timeoutIntervalForResource=30
35+
// Timeout after 5 minutes, or if there's no data for 60 seconds
36+
sessionConfig.timeoutIntervalForRequest=60
37+
sessionConfig.timeoutIntervalForResource=300
3938
tryawaitdownload(src: dylibPath, dest: dest, urlSession:URLSession(configuration: sessionConfig))
4039
}catch{
4140
throw.download(error)

‎Coder-Desktop/VPN/PacketTunnelProvider.swift

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
5757
start(completionHandler)
5858
}
5959

60-
// called by `startTunnel` and on `wake`
60+
// called by `startTunnel`
6161
func start(_ completionHandler:@escaping(Error?)->Void){
6262
guardlet proto= protocolConfigurationas?NETunnelProviderProtocol,
6363
let baseAccessURL= proto.serverAddress
@@ -108,7 +108,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
108108
teardown(completionHandler)
109109
}
110110

111-
// called by `stopTunnel` and `sleep`
111+
// called by `stopTunnel`
112112
func teardown(_ completionHandler:@escaping()->Void){
113113
guardlet managerelse{
114114
logger.error("teardown called with nil Manager")
@@ -138,34 +138,6 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
138138
}
139139
}
140140

141-
// sleep and wake reference: https://developer.apple.com/forums/thread/95988
142-
overridefunc sleep(completionHandler:@escaping()->Void){
143-
logger.debug("sleep called")
144-
teardown(completionHandler)
145-
}
146-
147-
overridefunc wake(){
148-
// It's possible the tunnel is still starting up, if it is, wake should
149-
// be a no-op.
150-
guard !reassertingelse{return}
151-
guard manager==nilelse{
152-
logger.error("wake called with non-nil Manager")
153-
return
154-
}
155-
logger.debug("wake called")
156-
reasserting=true
157-
currentSettings=.init(tunnelRemoteAddress:"127.0.0.1")
158-
setTunnelNetworkSettings(nil)
159-
start{ errorin
160-
iflet error{
161-
self.logger.error("error starting tunnel after wake:\(error.localizedDescription)")
162-
self.cancelTunnelWithError(error)
163-
}else{
164-
self.reasserting=false
165-
}
166-
}
167-
}
168-
169141
// Wrapper around `setTunnelNetworkSettings` that supports merging updates
170142
func applyTunnelNetworkSettings(_ diff:Vpn_NetworkSettingsRequest)asyncthrows{
171143
logger.debug("applying settings diff:\(diff.debugDescription, privacy:.public)")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp