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

Commite64ea22

Browse files
committed
review
1 parent024d7e3 commite64ea22

File tree

4 files changed

+15
-33
lines changed

4 files changed

+15
-33
lines changed

‎Coder Desktop/Coder Desktop/Views/VPNMenu.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ struct VPNMenu<VPN: VPNService, S: Session>: View {
9292
}
9393

9494
func openSystemExtensionSettings(){
95-
//TODO: Check this still works in a new macOS version
95+
//Sourced from:
9696
// https://gist.github.com/rmcdongit/f66ff91e0dad78d4d6346a75ded4b751?permalink_comment_id=5261757
97+
// We'll need to ensure this continues to work in future macOS versions
9798
// swiftlint:disable:next line_length
9899
NSWorkspace.shared.open(URL(string:"x-apple.systempreferences:com.apple.ExtensionsPreferences?extensionPointIdentifier=com.apple.system_extension.network_extension.extension-point")!)
99100
}

‎Coder Desktop/VPN/Manager.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,7 @@ actor Manager {
9191
logger.error("tunnel read loop failed:\(error.localizedDescription, privacy:.public)")
9292
tryawait tunnelHandle.close()
9393
ptp.cancelTunnelWithError(
94-
NSError(
95-
domain:"\(Bundle.main.bundleIdentifier!).Manager",
96-
code:-1,
97-
userInfo:[NSLocalizedDescriptionKey:"Tunnel read loop failed:\(error.localizedDescription)"]
98-
)
94+
makeNSError(suffix:"Manager", desc:"Tunnel read loop failed:\(error.localizedDescription)")
9995
)
10096
return
10197
}

‎Coder Desktop/VPN/PacketTunnelProvider.swift

Lines changed: 4 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,45 +43,26 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
4343
returnnil
4444
}
4545

46-
// swiftlint:disable:next function_body_length
4746
overridefunc startTunnel(
4847
options _:[String:NSObject]?, completionHandler:@escaping(Error?)->Void
4948
){
5049
logger.info("startTunnel called")
5150
guard manager==nilelse{
5251
logger.error("startTunnel called with non-nil Manager")
53-
completionHandler(
54-
NSError(
55-
domain:"\(Bundle.main.bundleIdentifier!).PTP",
56-
code:-1,
57-
userInfo:[NSLocalizedDescriptionKey:"Already running"]
58-
)
59-
)
52+
completionHandler(makeNSError(suffix:"PTP", desc:"Already running"))
6053
return
6154
}
6255
guardlet proto= protocolConfigurationas?NETunnelProviderProtocol,
6356
let baseAccessURL= proto.serverAddress
6457
else{
6558
logger.error("startTunnel called with nil protocolConfiguration")
66-
completionHandler(
67-
NSError(
68-
domain:"\(Bundle.main.bundleIdentifier!).PTP",
69-
code:-1,
70-
userInfo:[NSLocalizedDescriptionKey:"Missing Configuration"]
71-
)
72-
)
59+
completionHandler(makeNSError(suffix:"PTP", desc:"Missing Configuration"))
7360
return
7461
}
7562
// HACK: We can't write to the system keychain, and the NE can't read the user keychain.
7663
guardlet token= proto.providerConfiguration?["token"]as?Stringelse{
7764
logger.error("startTunnel called with nil token")
78-
completionHandler(
79-
NSError(
80-
domain:"\(Bundle.main.bundleIdentifier!).PTP",
81-
code:-1,
82-
userInfo:[NSLocalizedDescriptionKey:"Missing Token"]
83-
)
84-
)
65+
completionHandler(makeNSError(suffix:"PTP", desc:"Missing Token"))
8566
return
8667
}
8768
logger.debug("retrieved token & access URL")
@@ -104,11 +85,7 @@ class PacketTunnelProvider: NEPacketTunnelProvider, @unchecked Sendable {
10485
} catch{
10586
logger.error("error starting manager:\(error.description, privacy:.public)")
10687
completionHandler(
107-
NSError(
108-
domain:"\(Bundle.main.bundleIdentifier!).Manager",
109-
code:-1,
110-
userInfo:[NSLocalizedDescriptionKey: error.description]
111-
)
88+
makeNSError(suffix:"Manager", desc: error.description)
11289
)
11390
}
11491
}

‎Coder Desktop/VPNLib/Util.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,11 @@ public struct CompletionWrapper<T>: @unchecked Sendable {
2121
block()
2222
}
2323
}
24+
25+
publicfunc makeNSError(suffix:String, code:Int=-1, desc:String)->NSError{
26+
NSError(
27+
domain:"\(Bundle.main.bundleIdentifier!).\(suffix)",
28+
code: code,
29+
userInfo:[NSLocalizedDescriptionKey: desc]
30+
)
31+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp