Skip to content

Commit ea50192

Browse files
committed
feat: add start vpn on launch setting
1 parent 93e7a8f commit ea50192

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

Coder Desktop/Coder Desktop/Coder_DesktopApp.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5858
if await !vpn.loadNetworkExtensionConfig() {
5959
state.reconfigure()
6060
}
61+
if state.startVPNOnLaunch {
62+
await vpn.start()
63+
}
6164
}
6265
// TODO: Start the daemon only once a file sync is configured
6366
Task {

Coder Desktop/Coder Desktop/State.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ class AppState: ObservableObject {
5454
}
5555
}
5656

57+
@Published var startVPNOnLaunch: Bool = UserDefaults.standard.bool(forKey: Keys.startVPNOnLaunch) {
58+
didSet {
59+
guard persistent else { return }
60+
UserDefaults.standard.set(startVPNOnLaunch, forKey: Keys.startVPNOnLaunch)
61+
}
62+
}
63+
5764
func tunnelProviderProtocol() -> NETunnelProviderProtocol? {
5865
if !hasSession { return nil }
5966
let proto = NETunnelProviderProtocol()
@@ -133,6 +140,7 @@ class AppState: ObservableObject {
133140
static let useLiteralHeaders = "UseLiteralHeaders"
134141
static let literalHeaders = "LiteralHeaders"
135142
static let stopVPNOnQuit = "StopVPNOnQuit"
143+
static let startVPNOnLaunch = "StartVPNOnLaunch"
136144
}
137145
}
138146

Coder Desktop/Coder Desktop/Views/Settings/GeneralTab.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,16 @@ struct GeneralTab: View {
66
var body: some View {
77
Form {
88
Section {
9-
LaunchAtLogin.Toggle("Launch at Login")
9+
LaunchAtLogin.Toggle("Launch at login")
1010
}
1111
Section {
1212
Toggle(isOn: $state.stopVPNOnQuit) {
13-
Text("Stop Coder Connect on Quit")
13+
Text("Stop Coder Connect on quit")
14+
}
15+
}
16+
Section {
17+
Toggle(isOn: $state.startVPNOnLaunch) {
18+
Text("Start Coder Connect on launch")
1419
}
1520
}
1621
}.formStyle(.grouped)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy