Skip to content

restructure codebase around LocalBackend with clear data ownership#370

Draft
garmr-ulfr wants to merge 10 commits intomainfrom
refactor
Draft

restructure codebase around LocalBackend with clear data ownership#370
garmr-ulfr wants to merge 10 commits intomainfrom
refactor

Conversation

@garmr-ulfr
Copy link
Collaborator

Summary

  • Reorganize project architecture to establish clear data ownership and unidirectional dependency flow
  • Introduce LocalBackend as central orchestrator, replacing the old Radiance struct
  • Rename TunnelService to VPNClient with all VPN operations as methods
  • Add CLI client (cmd/lantern) for interacting with the daemon over IPC

Package changes

  • api/account/, replacing resty with net/http
  • vpn/ipc/ → root-level ipc/ with separate client/server
  • New backend/ package with LocalBackend
  • New log/ package for logger creation and log streaming via PublishHandler
  • Removed option/ package

Architecture

  • Dependency flow is now ipc → vpn (not reverse)
  • IPC server uses HTTP mux with traced handlers
  • IPC client supports SSE streaming and mobile in-process fallback
  • Settings use typed key constants; filename changed to settings.json

Bug fixes

  • Fix event subscription collisions by keying on reflect.Type instead of zero-value instances
  • Fix setData() change detection (&&||)
  • Fix internal.LevelTracelog.LevelTrace import errors in several packages

Other

  • Simplify config.Config to alias ConfigResponse directly
  • Flatten servers.Manager map to map[string]Server
  • Remove go-resty/resty/v2, add alexflint/go-arg and golang.org/x/term

Test plan

  • go build ./... passes
  • go vet ./... passes
  • go test ./... passes
  • CLI client connects to daemon and executes subcommands
  • Mobile in-process fallback works when IPC socket is unavailable

…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.
…terns

Reorganize the project architecture to establish clear data ownership
and dependency flow, inspired by Tailscale's LocalBackend/localapi
pattern.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant