feat(ipc): remove ipc dependeny on data directory#337
Open
garmr-ulfr wants to merge 6 commits intomainfrom
Open
feat(ipc): remove ipc dependeny on data directory#337garmr-ulfr wants to merge 6 commits intomainfrom
garmr-ulfr wants to merge 6 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes the IPC layer's dependency on the data directory by eliminating file watching and moving server configuration responsibility to the caller. The tunnel now receives pre-built configuration as JSON and exposes explicit outbound management methods.
Changes:
- Replaced file-watching with event-driven server propagation via the events package
- Changed Service interface to accept serialized options strings and added UpdateOutbounds/AddOutbounds/RemoveOutbounds methods
- Introduced typed VPNStatus (Connected, Disconnected, Connecting, Disconnecting) replacing string constants
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| vpn/vpn.go | Added init() event subscriptions to forward server changes to tunnel; added AutoConnect/Connect/Restart public APIs; deprecated old APIs |
| vpn/tunnel.go | Removed file watcher and reloadOptions; split updateGroup into separate addOutbounds/removeOutbounds/updateOutbounds methods; changed start() to accept options string |
| vpn/service.go | Updated Start/Restart to accept options string; added UpdateOutbounds/AddOutbounds/RemoveOutbounds delegating to tunnel |
| vpn/ipc/server.go | Changed Service interface signatures; added outbound management routes; improved status transition handling |
| vpn/ipc/status.go | Replaced string status constants with VPNStatus type; fixed GetStatus return type |
| vpn/ipc/outbound.go | Added UpdateOutbounds/AddOutbounds/RemoveOutbounds handlers and client functions |
| vpn/ipc/endpoints.go | Added three new endpoint constants for outbound management |
| vpn/ipc/set.go | Removed entire file (SetSettingsPath endpoint and go:linkname hack) |
| servers/manager.go | Added ServersUpdatedEvent/ServersAddedEvent/ServersRemovedEvent emitted on changes |
| vpn/tunnel_test.go | Updated tests for new VPNStatus type and split outbound operations |
| vpn/vpn_test.go | Updated mockService to implement new Service interface |
| telemetry/connections.go | Updated status check to use ipc.Connected |
| vpn/ipc/group.go | Updated status check to use Connected constant |
| vpn/ipc/connections.go | Updated status checks to use Connected constant |
| vpn/ipc/clash_mode.go | Updated status check to use Connected constant |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR decouples the IPC layer from the data directory by moving server configuration building and file watching responsibilities out of the tunnel/IPC server and into the caller.
Primary Change: Remove IPC dependency on data directory
AddOutbounds,RemoveOutbounds, andUpdateOutboundsmethods for dynamic server management. (vpn/tunnel.go)vpn/ipc/set.goentirely, which contained theSetSettingsPathendpoint and thego:linknamehack for reloading settings — a Linux-specific workaround that is no longer needed.Serviceinterface now accepts anoptions stringforStartandRestartinstead ofgroup/tagpairs, and addsUpdateOutbounds,AddOutbounds, andRemoveOutboundsmethods. (vpn/ipc/server.go)TunnelServiceimplements the new interface, delegating outbound mutations to the underlying tunnel. Options are built and serialized by the caller before being passed over IPC. (vpn/service.go)New IPC endpoints for outbound management
/outbound/update,/outbound/add, and/outbound/removewith corresponding handlers and client functions. (vpn/ipc/endpoints.go,vpn/ipc/outbound.go)setSettingsPathEndpointroute. (vpn/ipc/server.go)Event-driven server propagation
ServersUpdatedEvent,ServersAddedEvent, andServersRemovedEventevent types emitted when the server manager modifies its server list. (servers/manager.go)init()subscriptions that forward these events to the running tunnel via the new IPC endpoints, replacing the previous file-watcher approach. (vpn/vpn.go)VPN status type refinement
StatusRunning,StatusClosed, etc.) with a typedVPNStatustype and new values (Connected,Disconnected,Connecting,Disconnecting). (vpn/ipc/status.go, and all handlers)Connecting,Disconnecting) and handle concurrent state transitions more explicitly. (vpn/ipc/server.go)Public API updates
AutoConnect,Connect,Restart, andSelectServeras the new public API; deprecatedQuickConnect,ConnectToServer, andReconnect. (vpn/vpn.go)SelectServernow supports theautoAllTaggroup for switching to auto mode via clash mode. (vpn/vpn.go)getOptions()builds and serializes tunnel options from settings, centralizing option construction at the caller level. (vpn/vpn.go)Test updates
VPNStatusconstants, the changedServiceinterface signatures, and the separatedaddOutbounds/removeOutboundscalls. (vpn/tunnel_test.go,vpn/vpn_test.go)