Skip to content

Commit df5447f

Browse files
committed
feat: add start vpn on launch setting
1 parent 2094e9f commit df5447f

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
@@ -55,6 +55,9 @@ class AppDelegate: NSObject, NSApplicationDelegate {
5555
if await !vpn.loadNetworkExtensionConfig() {
5656
state.reconfigure()
5757
}
58+
if state.startVPNOnLaunch {
59+
await vpn.start()
60+
}
5861
}
5962
}
6063

Coder Desktop/Coder Desktop/State.swift

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

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

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