Skip to content

Commit 1413f5a

Browse files
committed
avoid double connecting
1 parent bb0667e commit 1413f5a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Coder Desktop/Coder Desktop/XPCInterface.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import VPNLib
66
@objc final class VPNXPCInterface: NSObject, VPNXPCClientCallbackProtocol, @unchecked Sendable {
77
private var svc: CoderVPNService
88
private let logger = Logger(subsystem: Bundle.main.bundleIdentifier!, category: "VPNXPCInterface")
9-
private var xpc: VPNXPCProtocol? = nil
9+
private var xpc: VPNXPCProtocol?
1010

1111
init(vpn: CoderVPNService) {
1212
svc = vpn
1313
super.init()
1414
}
1515

1616
func connect() {
17+
guard xpc == nil else {
18+
return
19+
}
1720
let networkExtDict = Bundle.main.object(forInfoDictionaryKey: "NetworkExtension") as? [String: Any]
1821
let machServiceName = networkExtDict?["NEMachServiceName"] as? String
1922
let xpcConn = NSXPCConnection(machServiceName: machServiceName!)

0 commit comments

Comments
 (0)