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

chore: reconfigure VPN on reinstall#84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ethanndickson merged 1 commit intomainfromethan/reconfigure-on-reinstall
Mar 3, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletionsCoder Desktop/Coder Desktop/Coder_DesktopApp.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -50,11 +50,10 @@ class AppDelegate: NSObject, NSApplicationDelegate {
object: nil
)
Task {
// If there's no NE config, then the user needs to sign in.
// However, they might have a session from a previous install, so we
// need to clear it.
// If there's no NE config, but the user is logged in, such as
// from a previous install, then we need to reconfigure.
if await !vpn.loadNetworkExtensionConfig() {
state.clearSession()
state.reconfigure()
}
}
}
Expand Down
2 changes: 2 additions & 0 deletionsCoder Desktop/Coder Desktop/MenuBarIconController.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,6 +13,8 @@ class MenuBarController {

init(menuBarExtra:FluidMenuBarExtra){
self.menuBarExtra= menuBarExtra
// Off by default, as `vpnDidUpdate` isn't called until the VPN is configured
menuBarExtra.setOpacity(offOpacity)
}

func vpnDidUpdate(_ connection:NETunnelProviderSession){
Expand Down
14 changes: 9 additions & 5 deletionsCoder Desktop/Coder Desktop/State.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -32,15 +32,15 @@ class AppState: ObservableObject {

@PublishedvaruseLiteralHeaders:Bool=UserDefaults.standard.bool(forKey:Keys.useLiteralHeaders){
didSet{
iflet onChange{onChange(tunnelProviderProtocol())}
reconfigure()
guard persistentelse{return}
UserDefaults.standard.set(useLiteralHeaders, forKey:Keys.useLiteralHeaders)
}
}

@PublishedvarliteralHeaders:[LiteralHeader]{
didSet{
iflet onChange{onChange(tunnelProviderProtocol())}
reconfigure()
guard persistentelse{return}
try?UserDefaults.standard.set(JSONEncoder().encode(literalHeaders), forKey:Keys.literalHeaders)
}
Expand DownExpand Up@@ -70,9 +70,13 @@ class AppState: ObservableObject {
privateletkeychain:Keychain
privateletpersistent:Bool

// This closure must be called when any property used to configure the VPN changes
letonChange:((NETunnelProviderProtocol?)->Void)?

// reconfigure must be called when any property used to configure the VPN changes
publicfunc reconfigure(){
iflet onChange{onChange(tunnelProviderProtocol())}
}

publicinit(onChange:((NETunnelProviderProtocol?)->Void)?=nil,
persistent:Bool=true)
{
Expand All@@ -97,13 +101,13 @@ class AppState: ObservableObject {
hasSession=true
self.baseAccessURL= baseAccessURL
self.sessionToken= sessionToken
iflet onChange{onChange(tunnelProviderProtocol())}
reconfigure()
}

publicfunc clearSession(){
hasSession=false
sessionToken=nil
iflet onChange{onChange(tunnelProviderProtocol())}
reconfigure()
}

privatefunc keychainGet(for key:String)->String?{
Expand Down
4 changes: 2 additions & 2 deletionsCoder Desktop/Coder Desktop/Views/LoginForm.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ struct LoginForm: View {
.animation(.easeInOut, value: currentPage)
.onAppear {
baseAccessURL = state.baseAccessURL?.absoluteString ?? baseAccessURL
sessionToken =""
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

We clear the Keychain password onSign out - so I don't think this does anything, actually.

sessionToken =state.sessionToken ?? sessionToken
}
.alert("Error", isPresented: Binding(
get: { loginError != nil },
Expand DownExpand Up@@ -122,7 +122,7 @@ struct LoginForm: View {
).disabled(true)
}
Section {
SecureField("Session Token", text: $sessionToken, prompt: Text("●●●●●●●●"))
Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Also removed the prompt because it was a lil confusing, and also the dots were way too big with no way to change it.

SecureField("Session Token", text: $sessionToken)
.autocorrectionDisabled()
.privacySensitive()
.focused($focusedField, equals: .sessionToken)
Expand Down
4 changes: 4 additions & 0 deletionsCoder Desktop/VPN/Manager.swift
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,6 +30,10 @@ actor Manager {
letsessionConfig=URLSessionConfiguration.default
// The tunnel might be asked to start before the network interfaces have woken up from sleep
sessionConfig.waitsForConnectivity=true
// URLSession's waiting for connectivity sometimes hangs even when
// the network is up so this is deliberately short (15s) to avoid a
// poor UX where it appears stuck.
sessionConfig.timeoutIntervalForResource=15
tryawaitdownload(src: dylibPath, dest: dest, urlSession:URLSession(configuration: sessionConfig))
}catch{
throw.download(error)
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp