How sagernet/sing-box works
sing-box is a universal proxy platform. Its principal workflow is configuring network entry points and proxy endpoints, then routing traffic through protocol handlers and transports; DNS and service/API capabilities complement that flow. The graph preserves those major runtime areas and the daemon/mobile-facing interfaces visible in the tree. Evidence is limited: the README gives only the product description, and sampled source/index references support some links but not a complete startup or traffic pipeline; unverified connections are dashed.
Main entry points: router.go Traffic router · masque/server.go VPN endpoints · box.go Box runtime · clashapi/server.go Clash API
Components 15
Runtime and configuration
- Configuration options
option/options.go - CLI commands
cmd/sing-box/cmd_run.go - Box runtime
box.go
Traffic handling
- Inbound manager
adapter/inbound/manager.go - Traffic router
route/router.go - Outbound manager
adapter/outbound/manager.go - DNS transports
dns/transport_manager.go
Protocols and transports
- VPN endpoints
protocol/masque/server.go - Protocol handlers
protocol/openvpn/server.go - Transport servers
transport/http/server.go
Services and APIs
- Clash API
experimental/clashapi/server.go - Service APIs
service/api/server.go
Platform interfaces
- Desktop daemon
experimental/boxdd/server.go - Native client bridge
experimental/libbox/command_client.go
Other components
- Network user
Connections 15
- Network user → Configuration options: defines settings
- Network user → CLI commands: runs commands
- CLI commands → Box runtime: starts runtime
- Configuration options → Box runtime: configures
- Box runtime → Inbound manager: starts
- Inbound manager → Traffic router: dispatches traffic
- Traffic router → Outbound manager: selects proxy
- Traffic router → DNS transports: uses DNS
- Protocol handlers → VPN endpoints: implements endpoint
- VPN endpoints → Transport servers: uses HTTP server
protocol/masque/server.go - VPN endpoints → Outbound manager: uses router
- Clash API → Traffic router: serves proxy routes
experimental/clashapi/server.go - Clash API → DNS transports: serves DNS routes
experimental/clashapi/server.go - Desktop daemon → Native client bridge: configures bridge
experimental/boxdd/server.go - Desktop daemon → Service APIs: hosts services