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: support operating the VPN without the app#36

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 7 commits intomainfromethan/vpn-no-app
Feb 10, 2025

Conversation

ethanndickson
Copy link
Member

@ethanndicksonethanndickson commentedFeb 3, 2025
edited
Loading

Currently, CoderVPN disables it's system-level configuration when it's turned off. This means it can't be started and stopped from System Preferences. Since the network extension works fine without the app, we can remove this restriction.

However, it then becomes necessary to retrieve the state of the peers (agents) when starting the app whilst the VPN is running. We already have support for this on the dylib side, so this PR wires that functionality up over XPC.

Demo (I launch the app once the VPN reports itself as connected):

vpn-no-app-demo.mov

This behaviour is only present in a Release build of the app. In a Debug build, launching the app will trigger a replacement of the network extension installed on the system, but not before disconnecting the VPN.

@ethanndicksonGraphite App
Copy link
MemberAuthor

ethanndickson commentedFeb 3, 2025
edited
Loading

@ethanndicksonethanndickson marked this pull request as ready for reviewFebruary 3, 2025 05:48
@ethanndicksonethanndicksonforce-pushed theethan/vpn-no-app branch 2 times, most recently fromdd9870f to3d407c4CompareFebruary 4, 2025 03:00
// If we moved from disabled to connected, then the NE was already
// running, and we need to request the current peer state
if tunnelState == .disabled {
xpc.getPeerState()
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like this kind of logic doesn't belong at this layer, where we're using history to infer what needs to happen next. Very path dependent.

Instead when we make an XPC connection we should explicitly (or implicitly on new connection) request the peer state. It's always the case that we need peer state at start of day.

As the tunnel goes up and down that also needs to be communicated (e.g. the user could stop the VPN via the System Settings).

Copy link
MemberAuthor

@ethanndicksonethanndicksonFeb 4, 2025
edited
Loading

Choose a reason for hiding this comment

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

As the tunnel goes up and down that also needs to be communicated (e.g. the user could stop the VPN via the System Settings).

This functionvpnDidUpdate gets called by theNotificationCentre, syncing it up with the VPN in System Settings. (Subscribing to events retrieves the current state too, so that works on app startup)

Instead when we make an XPC connection we should explicitly (or implicitly on new connection) request the peer state.

An XPC connection is only made when the app attempts to communicate with the NE, so we can't rely on XPC to tell us the NE is already running. (As seen in theNE & XPC example)

It's always the case that we need peer state at start of day.

However, always attempting to retrieve the peer state onCoderVPNService.init works just as well. Though if the NE isn't running, we do create a spurious error log. WDYT?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's fine for us to wait until we know whether the NE is running before we attempt to query the peer state. What I'm worried about is path dependence in the state machine: if we later add more states, or more transitions, you could end up in the.connected state in a way that does require us to query the peer state, but we haven't transitioned directly from thedisabled state.

Could we just always request a peer state update when we get to.connected? That way we have some belief that the NE is running, so if we can't get it, it's a legit error. I realize in the case where we are starting the VPN up we'll request a spurious update, but are the updates idempotent?

Copy link
MemberAuthor

@ethanndicksonethanndicksonFeb 6, 2025
edited
Loading

Choose a reason for hiding this comment

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

Yeah, the first update sent when the VPN starts will be identical to the one we manually request - but the one requested will overwrite the other if it arrives after. I'll have it always request on.connected.

Copy link
MemberAuthor

@ethanndicksonethanndicksonFeb 6, 2025
edited
Loading

Choose a reason for hiding this comment

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

Actually, this is causing the NE to crash.vpnDidUpdate gets called when other parts of the VPN configuration change, not just the status, so the.connected branch was running multiple times on startup. The XPC was going through to the NE fine, but It looks like the speaker or the dylib can't keep up with multiple peer state requests in quick succession - We'll need to investigate that at some point, but not now.

Comment on lines +154 to +155
clearPeers()
applyPeerUpdate(with: msg)
Copy link
Member

Choose a reason for hiding this comment

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

Doesn't this clear call make handling thedeletedAgents anddeletedWorkspaces inapplyPeerUpdate unnecessary since there won't be any workspaces or agents left?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

update.deletedAgents andupdate.deletedWorkspaces will always be empty on agetPeerState response, yeah. The Go code already keeps track of all known agents & workspaces, so as Dean suggested I think it'd be good to just send the full current state to the NE on any update.

@ethanndicksonethanndickson changed the base branch fromethan/agents-to-ui tomainFebruary 10, 2025 02:36
@ethanndicksonethanndickson merged commitdf3d755 intomainFeb 10, 2025
1 check passed
@ethanndicksonethanndickson deleted the ethan/vpn-no-app branchFebruary 12, 2025 12:26
@ethanndicksonethanndickson self-assigned thisFeb 12, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@ThomasK33ThomasK33ThomasK33 left review comments

@spikecurtisspikecurtisspikecurtis approved these changes

Assignees

@ethanndicksonethanndickson

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@ethanndickson@ThomasK33@spikecurtis

[8]ページ先頭

©2009-2025 Movatter.jp