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

Commit942e899

Browse files
committed
feat: add coder connect startup progress messages
1 parent5569302 commit942e899

File tree

8 files changed

+47
-3
lines changed

8 files changed

+47
-3
lines changed

‎Coder-Desktop/Coder-Desktop/Preview Content/PreviewVPN.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ final class PreviewVPN: Coder_Desktop.VPNService {
3333
self.shouldFail= shouldFail
3434
}
3535

36+
@PublishedvarprogressMessage:String?
37+
3638
varstartTask:Task<Void,Never>?
3739
func start()async{
3840
ifawait startTask?.value!=nil{

‎Coder-Desktop/Coder-Desktop/VPN/VPNService.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import VPNLib
77
protocolVPNService:ObservableObject{
88
varstate:VPNServiceState{get}
99
varmenuState:VPNMenuState{get}
10+
varprogressMessage:String?{get}
1011
func start()async
1112
func stop()async
1213
func configureTunnelProviderProtocol(proto:NETunnelProviderProtocol?)
@@ -72,6 +73,8 @@ final class CoderVPNService: NSObject, VPNService {
7273
return tunnelState
7374
}
7475

76+
@PublishedvarprogressMessage:String?
77+
7578
@PublishedvarmenuState:VPNMenuState=.init()
7679

7780
// Whether the VPN should start as soon as possible
@@ -155,6 +158,10 @@ final class CoderVPNService: NSObject, VPNService {
155158
}
156159
}
157160

161+
func onProgress(_ msg:String?){
162+
progressMessage= msg
163+
}
164+
158165
func applyPeerUpdate(with update:Vpn_PeerUpdate){
159166
// Delete agents
160167
update.deletedAgents.forEach{ menuState.deleteAgent(withId: $0.id)}

‎Coder-Desktop/Coder-Desktop/Views/VPN/VPNState.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ struct VPNState<VPN: VPNService>: View {
66

77
letinspection=Inspection<Self>()
88

9+
varprogressMessage:String{
10+
iflet msg= vpn.progressMessage{
11+
msg
12+
}else{
13+
vpn.state==.connecting?"Starting Coder Connect...":"Stopping Coder Connect..."
14+
}
15+
}
16+
917
varbody:someView{
1018
Group{
1119
switch(vpn.state, state.hasSession){
@@ -28,9 +36,11 @@ struct VPNState<VPN: VPNService>: View {
2836
case(.connecting, _),(.disconnecting, _):
2937
HStack{
3038
Spacer()
31-
ProgressView(
32-
vpn.state==.connecting?"Starting Coder Connect...":"Stopping Coder Connect..."
33-
).padding()
39+
ProgressView{
40+
Text(progressMessage)
41+
.multilineTextAlignment(.center)
42+
}
43+
.padding()
3444
Spacer()
3545
}
3646
caselet(.failed(vpnErr), _):

‎Coder-Desktop/Coder-Desktop/XPCInterface.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,12 @@ import VPNLib
7171
}
7272
}
7373

74+
func onProgress(msg:String?){
75+
Task{@MainActorin
76+
svc.onProgress(msg)
77+
}
78+
}
79+
7480
// The NE has verified the dylib and knows better than Gatekeeper
7581
func removeQuarantine(path:String, reply:@escaping(Bool)->Void){
7682
letreply=CallbackWrapper(reply)

‎Coder-Desktop/Coder-DesktopTests/Util.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ class MockVPNService: VPNService, ObservableObject {
1010
@Publishedvarstate:Coder_Desktop.VPNServiceState=.disabled
1111
@PublishedvarbaseAccessURL:URL=.init(string:"https://dev.coder.com")!
1212
@PublishedvarmenuState:VPNMenuState=.init()
13+
@PublishedvarprogressMessage:String?
1314
varonStart:(()async->Void)?
1415
varonStop:(()async->Void)?
1516

‎Coder-Desktop/VPN/Manager.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ actor Manager {
3939
}catch{
4040
throw.download(error)
4141
}
42+
pushProgress(msg:"Fetching server version...")
4243
letclient=Client(url: cfg.serverUrl)
4344
letbuildInfo:BuildInfoResponse
4445
do{
@@ -49,6 +50,7 @@ actor Manager {
4950
guardlet semver= buildInfo.semverelse{
5051
throw.serverInfo("invalid version:\(buildInfo.version)")
5152
}
53+
pushProgress(msg:"Validating library...")
5254
do{
5355
trySignatureValidator.validate(path: dest, expectedVersion: semver)
5456
}catch{
@@ -59,11 +61,13 @@ actor Manager {
5961
// so it's safe to execute. However, the SE must be sandboxed, so we defer to the app.
6062
tryawaitremoveQuarantine(dest)
6163

64+
pushProgress(msg:"Opening library...")
6265
do{
6366
try tunnelHandle=TunnelHandle(dylibPath: dest)
6467
}catch{
6568
throw.tunnelSetup(error)
6669
}
70+
pushProgress(msg:"Setting up tunnel...")
6771
speaker=awaitSpeaker<Vpn_ManagerMessage,Vpn_TunnelMessage>(
6872
writeFD: tunnelHandle.writeHandle,
6973
readFD: tunnelHandle.readHandle
@@ -158,6 +162,7 @@ actor Manager {
158162
}
159163

160164
func startVPN()asyncthrows(ManagerError){
165+
pushProgress(msg:nil)
161166
logger.info("sending start rpc")
162167
guardlet tunFd= ptp.tunnelFileDescriptorelse{
163168
logger.error("no fd")
@@ -234,6 +239,15 @@ actor Manager {
234239
}
235240
}
236241

242+
func pushProgress(msg:String?){
243+
guardlet conn= globalXPCListenerDelegate.connelse{
244+
logger.error("couldn't send progress message to app: no connection")
245+
return
246+
}
247+
logger.info("sending progress message to app:\(msg??"nil")")
248+
conn.onProgress(msg: msg)
249+
}
250+
237251
structManagerConfig{
238252
letapiToken:String
239253
letserverUrl:URL
@@ -312,6 +326,7 @@ private func removeQuarantine(_ dest: URL) async throws(ManagerError) {
312326
letfile=NSURL(fileURLWithPath: dest.path)
313327
try? file.getResourceValue(&flag, forKey: kCFURLQuarantinePropertiesKeyasURLResourceKey)
314328
if flag!=nil{
329+
pushProgress(msg:"Unquarantining download...")
315330
// Try the privileged helper first (it may not even be registered)
316331
ifawait globalHelperXPCSpeaker.tryRemoveQuarantine(path: dest.path){
317332
// Success!

‎Coder-Desktop/VPN/PacketTunnelProvider.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
9292
logger.info("vpn started")
9393
self.manager= manager
9494
completionHandler(nil)
95+
// Clear progress message
96+
pushProgress(msg:nil)
9597
} catch{
9698
logger.error("error starting manager:\(error.description, privacy:.public)")
9799
completionHandler(

‎Coder-Desktop/VPNLib/XPC.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ import Foundation
1010
@objcpublicprotocolVPNXPCClientCallbackProtocol{
1111
// data is a serialized `Vpn_PeerUpdate`
1212
func onPeerUpdate(_ data:Data)
13+
func onProgress(msg:String?)
1314
func removeQuarantine(path:String, reply:@escaping(Bool)->Void)
1415
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp