How throneproj/throne works
Purpose and Entry Points
Throne is a cross-platform Qt desktop proxy manager for Sing-box and optionally Xray-based configurations. The GUI process starts in src/main.cpp, builds the main window from src/ui/mainWindow/mainwindow_setup.cpp, and manages profile selection, proxy lifecycle, system integration, and runtime statistics. Its Go core/server starts at core/server/main.go.
Desktop UI and Application Orchestration
The main window is the user-facing control plane: profiles/groups, start-stop state, logs, connection views, hotkeys, tray behavior, deep links, and system-proxy/TUN actions are split into focused units under src/ui/mainWindow/. Profile editing maps each supported outbound protocol to a specialized editor, e.g. src/ui/profile/dialog_edit_profile.cpp, src/ui/profile/edit_vless.cpp, and src/ui/profile/edit_wireguard.cpp. Qt resources, themes, and translations ship under res/.
Persistent Domain Model
SQLite is the durable boundary for settings, groups, profiles, route rules, and traffic history. src/database/DatabaseManager.cpp coordinates database access; repository classes such as src/database/ProfilesRepo.cpp and src/database/RoutesRepo.cpp isolate CRUD from UI/configuration logic. Entities in src/database/entities/Profile.cpp and related headers represent persisted proxy and routing state.
Configuration and Subscription Pipeline
Persisted profiles are converted into executable Sing-box/Xray configuration through the outbound model/factory and generator: src/configs/common/OutboundFactory.cpp, src/configs/generate.cpp, and protocol implementations in src/configs/outbounds/. Subscription/group updates ingest supported share links and config formats via src/configs/sub/GroupUpdater.cpp, with route-profile updates handled by src/configs/sub/RouteUpdater.cpp. This is the boundary between externally supplied proxy data and validated internal profile/config objects.
Core IPC and Proxy Execution
The C++ application communicates with a bundled Go server over platform-specific IPC, defined by include/api/RPC.h and implemented in src/api/RPC.cpp; the service protocol is core/server/gen/libcore.proto. The server dispatches commands in core/server/dispatch.go, starts/manages the Sing-box runtime through core/server/internal/boxmain/cmd_run.go, and supports Xray process integration under core/server/internal/xray/. The GUI owns intent/configuration; the Go process owns core execution and privileged networking operations.
Networking, Routing, and System Boundaries
The core applies egress behavior in core/server/egress.go, provides auto-selection in core/server/server_autoselector.go, and handles DNS/system-network changes through core/server/internal/boxdns/. OS-specific boundaries cover Linux capabilities/SUID and checks (src/sys/linux/LinuxCap.cpp), macOS privilege/system support (src/sys/macos/MacOS.cpp), and Windows event/system support (src/sys/windows/eventHandler.cpp). These operations can alter system proxy, DNS, routes, or TUN-related state and therefore require platform-specific privilege handling.
Monitoring and External Dependencies
Runtime telemetry flows from core IPC into connection, traffic, and auto-selector monitors: src/stats/connectionLister/connectionLister.cpp, src/stats/traffic/TrafficStatsManager.cpp, and src/stats/autoselector/AutoSelectorMonitor.cpp, then to Qt dashboards. Major embedded dependencies include Qt, SQLiteCpp, QHotkey, QR tooling, YAML/protobuf libraries, while runtime external engines are Sing-box and Xray. Subscription/route updates use network HTTP facilities in src/global/HTTPRequestHelper.cpp; route profiles are sourced externally from the Throne routeprofiles repository.
Components 20
Qt Desktop App
- Desktop entry point
src/main.cpp - Main window control plane · Owns profile actions, lifecycle controls, tray, hotkeys, and dashboards.
src/ui/mainWindow/mainwindow_setup.cpp - Profile editors
src/ui/profile/dialog_edit_profile.cpp - Core IPC client
src/api/RPC.cpp - Runtime monitors
src/stats/traffic/TrafficStatsManager.cpp
Data & Configuration
- Database manager
src/database/DatabaseManager.cpp - Profile repository
src/database/ProfilesRepo.cpp - Route repository
src/database/RoutesRepo.cpp - Persisted profile
src/database/entities/Profile.cpp - Subscription updates · Parses supported share links and subscription formats into internal profiles.
src/configs/sub/GroupUpdater.cpp - Route updates
src/configs/sub/RouteUpdater.cpp - HTTP updates client
src/global/HTTPRequestHelper.cpp - Runtime config generator
src/configs/generate.cpp - Outbound factory
src/configs/common/OutboundFactory.cpp
Go Core Server
- Core server · Owns runtime execution and privileged networking operations.
core/server/main.go - Command dispatch
core/server/dispatch.go - Sing-box runtime manager
core/server/internal/boxmain/cmd_run.go - Egress and auto-selection
core/server/egress.go - Xray integration
System Integration
- OS privilege boundary · Applies platform-specific proxy, DNS, route, TUN, and privilege operations.
src/sys/linux/LinuxCap.cpp
Connections 25
- Desktop entry point → Main window control plane: creates
- Main window control plane → Profile editors: opens
- Main window control plane → Profile repository: manages profiles
- Main window control plane → Route repository: manages routes
- Main window control plane → Runtime config generator: requests config
- Main window control plane → Core IPC client: controls core
- Main window control plane → Runtime monitors: displays
- Profile editors → Profile repository: saves
- Profile repository → Database manager: persists through
- Route repository → Database manager: persists through
- Profile repository → Persisted profile: maps
- HTTP updates client → Subscription updates: fetches for
- HTTP updates client → Route updates: fetches for
- Subscription updates → Profile repository: updates profiles
- Route updates → Route repository: updates routes
- Profile repository → Runtime config generator: supplies profiles
- Route repository → Runtime config generator: supplies rules
- Runtime config generator → Outbound factory: builds outbounds
- Core IPC client → Core server: IPC commands and telemetry · Service contract is defined by core/server/gen/libcore.proto.
- Core server → Command dispatch: dispatches
- Command dispatch → Sing-box runtime manager: starts and manages
- Sing-box runtime manager → Egress and auto-selection: applies egress
- Sing-box runtime manager → Xray integration: optionally delegates
- Core server → OS privilege boundary: uses privileged operations
- Core server → Runtime monitors: publishes runtime data