feat(ipc): add SSE status event streaming to clients in real-time#343
Open
garmr-ulfr wants to merge 3 commits intomainfrom
Open
feat(ipc): add SSE status event streaming to clients in real-time#343garmr-ulfr wants to merge 3 commits intomainfrom
garmr-ulfr wants to merge 3 commits intomainfrom
Conversation
…ith VPNStatus type Introduce a Server-Sent Events endpoint (/status/events) that streams VPN status changes to clients in real time, replacing the previous poll-based approach. Refactor status representation from string constants (StatusRunning, StatusClosed, etc.) to a typed VPNStatus enum (Connected, Disconnected, Connecting, Disconnecting, Restarting, ErrorStatus) and move status emission from the IPC server into the tunnel layer. The tracer middleware is scoped to standard routes so it no longer buffers long-lived SSE connections, and the HTTP transport is upgraded to unencrypted HTTP/2 for multiplexed streaming support.
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request modernizes the VPN status handling by introducing a strongly-typed VPNStatus enum to replace string-based status values, adds a new SSE endpoint for real-time status event streaming, and improves HTTP/2 support for long-lived streaming connections. The changes centralize status management through an event-driven architecture where status updates are emitted as StatusUpdateEvent events rather than being managed directly by the IPC server.
Changes:
- Introduced
VPNStatusenum type with values: Connecting, Connected, Disconnecting, Disconnected, Restarting, and ErrorStatus - Added SSE endpoint
/status/eventsfor streaming VPN status updates to clients in real-time - Refactored status management to use event-driven architecture with
StatusUpdateEventemissions from the tunnel layer - Updated HTTP server configuration to support HTTP/2 and removed WriteTimeout to enable long-lived SSE connections
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| vpn/ipc/events.go | Implements SSE handler for streaming status events with StatusUpdateEvent type definition |
| vpn/ipc/events_client.go | Client implementation for consuming status event stream with retry logic |
| vpn/ipc/events_test.go | Test coverage for status event streaming handler |
| vpn/ipc/endpoints.go | Adds /status/events endpoint constant |
| vpn/ipc/server.go | Introduces VPNStatus enum, removes legacy status management, configures HTTP/2, and separates SSE routes from tracer middleware |
| vpn/ipc/status.go | Updates GetStatus and statusHandler to use VPNStatus type, removes legacy string constants |
| vpn/ipc/http.go | Configures HTTP/2 protocol support for client and server transports |
| vpn/ipc/connections.go | Updates status comparisons from StatusRunning to Connected |
| vpn/ipc/clash_mode.go | Updates status comparisons from StatusRunning to Connected |
| vpn/ipc/group.go | Updates status comparisons from StatusRunning to Connected |
| vpn/ipc/outbound.go | Updates status comparisons from StatusRunning to Connected |
| vpn/tunnel.go | Implements status management with atomic.Value, emits StatusUpdateEvent on status changes, adds Restarting status handling |
| vpn/service.go | Updates Status() return type to VPNStatus, sets Restarting status during restart |
| vpn/vpn.go | Updates isOpen check from StatusRunning to Connected |
| vpn/vpn_test.go | Updates mock service to use VPNStatus type and Connected constant |
| vpn/tunnel_test.go | Updates test assertions from StatusRunning/StatusClosed to Connected/Disconnected |
| telemetry/connections.go | Updates status comparison from StatusRunning to Connected |
💡 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 pull request introduces a new server-sent events (SSE) endpoint for streaming VPN status updates and refactors the VPN status handling throughout the IPC server. The changes replace the previous string-based status checks with a strongly-typed
VPNStatusenum, update endpoint handlers to use the new status values, and remove legacy status management logic. Additionally, HTTP/2 protocol handling is improved to support streaming responses. The most important changes are grouped below.VPN Status Event Streaming
statusEventsEndpoint) and handler (statusEventsHandler) for real-time VPN status updates, including a client implementation and test coverage. (vpn/ipc/events.go,vpn/ipc/events_client.go,vpn/ipc/events_test.go,vpn/ipc/endpoints.go) [1] [2] [3] [4]Refactoring Status Management
Replaced legacy string-based status checks (e.g.,
StatusRunning,StatusClosed) with the newVPNStatusenum values (Connected,Disconnected, etc.) across all endpoint handlers and service logic. (vpn/ipc/server.go,vpn/ipc/connections.go,vpn/ipc/clash_mode.go,vpn/ipc/group.go,vpn/ipc/outbound.go,telemetry/connections.go,vpn/ipc/status.go) [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15]Removed legacy status constants and the
setVPNStatusmethod, simplifying the codebase and centralizing status updates via the new event stream. (vpn/ipc/server.go,vpn/ipc/status.go) [1] [2] [3]HTTP/2 Streaming Support
vpn/ipc/http.go,vpn/ipc/server.go) [1] [2] [3]Endpoint Routing Improvements
vpn/ipc/server.go)These changes modernize the IPC server's status handling, introduce real-time event streaming, and improve protocol support for streaming connections.