# leadaxe/sing-box-lx architecture

> Architecture diagram of the GitHub repository leadaxe/sing-box-lx, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leadaxe/sing-box-lx
- Repository: https://github.com/leadaxe/sing-box-lx

## Overview

sing-box-lx is a configurable proxy and VPN core, exposed as a sing-box CLI, an Android/native library, and optional control APIs. Its main runtime path accepts configured traffic, routes it by rules, and sends it through selected proxy or VPN outbounds; DNS is a parallel resolution path. The fork’s documented branches add Xray-compatible transports, AmneziaWG, WARP/MASQUE, TrustTunnel, daemon control, and observability. Edges are limited to README statements and shown source references; several runtime connections are therefore left unverified rather than asserted.

Main entry points: [`box.go`](https://github.com/leadaxe/sing-box-lx/blob/lx/box.go) (Proxy VPN core), [`adapter/outbound/manager.go`](https://github.com/leadaxe/sing-box-lx/blob/lx/adapter/outbound/manager.go) (Outbound manager), [`route/router.go`](https://github.com/leadaxe/sing-box-lx/blob/lx/route/router.go) (Traffic router), [`dns/transport_manager.go`](https://github.com/leadaxe/sing-box-lx/blob/lx/dns/transport_manager.go) (DNS transports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Core runtime"]
  node_core["Proxy VPN core<br/>[box.go]"]
end

subgraph group_network["Traffic and DNS"]
  node_router["Traffic router<br/>[router.go]"]
  node_rules["Routing rules"]
  node_outbounds["Outbound manager<br/>[manager.go]"]
  node_dnsmanager["DNS transports"]
  node_dnstrack["DNS query events<br/>[manager.go]"]
end

subgraph group_interfaces["Control interfaces"]
  node_cli["CLI commands<br/>[cmd.go]"]
  node_daemon["lxd daemon<br/>[server.go]"]
  node_libbox["Native command API<br/>[command_client.go]"]
  node_clashapi["Clash API<br/>[server.go]"]
  node_v2rayapi["V2Ray API<br/>[server.go]"]
end

subgraph group_protocols["Protocol extensions"]
  node_openvpn["OpenVPN server<br/>[server.go]"]
  node_openconnect["OpenConnect client<br/>[client.go]"]
  node_reality["REALITY / TLS<br/>[reality_client.go]"]
  node_masque["WARP MASQUE<br/>[client_h2.go]"]
  node_xhttp["XHTTP transport<br/>[client.go]"]
  node_trusttunnel["TrustTunnel<br/>[client.go]"]
  node_awg["AmneziaWG"]
end

subgraph group_services["Supporting services"]
  node_openvpnservice["OpenVPN service<br/>[server.go]"]
  node_tailssh["Tailscale SSH<br/>[server.go]"]
  node_origin["Origin CA<br/>[service.go]"]
  node_ccm["CCM usage<br/>[service_usage.go]"]
  node_ocm["OCM usage<br/>[service_usage.go]"]
end

node_operator(("Operator / app"))

node_operator -->|"runs commands"| node_cli
node_cli -.->|"starts core"| node_core
node_core -.->|"routes traffic"| node_router
node_router -.->|"matches rules"| node_rules
node_router -.->|"selects outbound"| node_outbounds
node_core -.->|"resolves DNS"| node_dnsmanager
node_dnsmanager -.->|"emits query events"| node_dnstrack
node_operator -->|"controls daemon"| node_daemon
node_operator -->|"uses native API"| node_libbox
node_operator -->|"uses REST API"| node_clashapi
node_operator -.->|"uses API"| node_v2rayapi
node_daemon -->|"uses command API"| node_libbox
node_clashapi -->|"exposes routing state"| node_router
node_core -->|"supports endpoint"| node_openvpn
node_core -.->|"supports client"| node_openconnect
node_outbounds -.->|"uses TLS"| node_reality
node_outbounds -->|"uses transport"| node_masque
node_outbounds -->|"uses transport"| node_xhttp
node_outbounds -->|"uses transport"| node_trusttunnel
node_outbounds -->|"uses WireGuard endpoint"| node_awg
node_core -.->|"supports service"| node_tailssh
node_core -.->|"provides service"| node_origin
node_core -.->|"provides usage service"| node_ccm
node_core -.->|"provides usage service"| node_ocm

click node_cli "https://github.com/leadaxe/sing-box-lx/blob/lx/cmd/sing-box/cmd.go"
click node_core "https://github.com/leadaxe/sing-box-lx/blob/lx/box.go"
click node_router "https://github.com/leadaxe/sing-box-lx/blob/lx/route/router.go"
click node_rules "https://github.com/leadaxe/sing-box-lx/blob/lx/route/rule/rule_item_query_client_subnet.go"
click node_outbounds "https://github.com/leadaxe/sing-box-lx/blob/lx/adapter/outbound/manager.go"
click node_dnsmanager "https://github.com/leadaxe/sing-box-lx/blob/lx/dns/transport_manager.go"
click node_dnstrack "https://github.com/leadaxe/sing-box-lx/blob/lx/common/dnstrack/manager.go"
click node_openvpn "https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openvpn/server.go"
click node_openconnect "https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openconnect/client.go"
click node_reality "https://github.com/leadaxe/sing-box-lx/blob/lx/common/tls/reality_client.go"
click node_masque "https://github.com/leadaxe/sing-box-lx/blob/lx/transport/masque/client_h2.go"
click node_xhttp "https://github.com/leadaxe/sing-box-lx/blob/lx/transport/v2rayxhttp/client.go"
click node_trusttunnel "https://github.com/leadaxe/sing-box-lx/blob/lx/transport/trusttunnel/client.go"
click node_awg "https://github.com/leadaxe/sing-box-lx/blob/lx/transport/wireguard/quic_clienthello_utls_awg.go"
click node_daemon "https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/boxdd/server.go"
click node_libbox "https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/libbox/command_client.go"
click node_clashapi "https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/clashapi/server.go"
click node_v2rayapi "https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/v2rayapi/server.go"
click node_openvpnservice "https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openvpn/server.go"
click node_tailssh "https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/tailscale/tailssh/server.go"
click node_origin "https://github.com/leadaxe/sing-box-lx/blob/lx/service/origin_ca/service.go"
click node_ccm "https://github.com/leadaxe/sing-box-lx/blob/lx/service/ccm/service_usage.go"
click node_ocm "https://github.com/leadaxe/sing-box-lx/blob/lx/service/ocm/service_usage.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_core toneBlue
class node_router,node_rules,node_outbounds,node_dnsmanager,node_dnstrack toneAmber
class node_cli,node_daemon,node_libbox,node_clashapi,node_v2rayapi toneMint
class node_openvpn,node_openconnect,node_reality,node_masque,node_xhttp,node_trusttunnel,node_awg toneRose
class node_openvpnservice,node_tailssh,node_origin,node_ccm,node_ocm,node_operator toneIndigo
```

## Components

### Core runtime

- [Proxy VPN core](https://github.com/leadaxe/sing-box-lx/blob/lx/box.go): `box.go`

### Traffic and DNS

- [Traffic router](https://github.com/leadaxe/sing-box-lx/blob/lx/route/router.go): `route/router.go`
- [Routing rules](https://github.com/leadaxe/sing-box-lx/blob/lx/route/rule/rule_item_query_client_subnet.go): `route/rule/rule_item_query_client_subnet.go`
- [Outbound manager](https://github.com/leadaxe/sing-box-lx/blob/lx/adapter/outbound/manager.go): `adapter/outbound/manager.go`
- [DNS transports](https://github.com/leadaxe/sing-box-lx/blob/lx/dns/transport_manager.go): `dns/transport_manager.go`
- [DNS query events](https://github.com/leadaxe/sing-box-lx/blob/lx/common/dnstrack/manager.go): `common/dnstrack/manager.go`

### Control interfaces

- [CLI commands](https://github.com/leadaxe/sing-box-lx/blob/lx/cmd/sing-box/cmd.go): `cmd/sing-box/cmd.go`
- [lxd daemon](https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/boxdd/server.go): `experimental/boxdd/server.go`
- [Native command API](https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/libbox/command_client.go): `experimental/libbox/command_client.go`
- [Clash API](https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/clashapi/server.go): `experimental/clashapi/server.go`
- [V2Ray API](https://github.com/leadaxe/sing-box-lx/blob/lx/experimental/v2rayapi/server.go): `experimental/v2rayapi/server.go`

### Protocol extensions

- [OpenVPN server](https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openvpn/server.go): `protocol/openvpn/server.go`
- [OpenConnect client](https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openconnect/client.go): `protocol/openconnect/client.go`
- [REALITY / TLS](https://github.com/leadaxe/sing-box-lx/blob/lx/common/tls/reality_client.go): `common/tls/reality_client.go`
- [WARP MASQUE](https://github.com/leadaxe/sing-box-lx/blob/lx/transport/masque/client_h2.go): `transport/masque/client_h2.go`
- [XHTTP transport](https://github.com/leadaxe/sing-box-lx/blob/lx/transport/v2rayxhttp/client.go): `transport/v2rayxhttp/client.go`
- [TrustTunnel](https://github.com/leadaxe/sing-box-lx/blob/lx/transport/trusttunnel/client.go): `transport/trusttunnel/client.go`
- [AmneziaWG](https://github.com/leadaxe/sing-box-lx/blob/lx/transport/wireguard/quic_clienthello_utls_awg.go): `transport/wireguard/quic_clienthello_utls_awg.go`

### Supporting services

- [OpenVPN service](https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/openvpn/server.go): `protocol/openvpn/server.go`
- [Tailscale SSH](https://github.com/leadaxe/sing-box-lx/blob/lx/protocol/tailscale/tailssh/server.go): `protocol/tailscale/tailssh/server.go`
- [Origin CA](https://github.com/leadaxe/sing-box-lx/blob/lx/service/origin_ca/service.go): `service/origin_ca/service.go`
- [CCM usage](https://github.com/leadaxe/sing-box-lx/blob/lx/service/ccm/service_usage.go): `service/ccm/service_usage.go`
- [OCM usage](https://github.com/leadaxe/sing-box-lx/blob/lx/service/ocm/service_usage.go): `service/ocm/service_usage.go`

### Other components

- **Operator / app**

## Connections

- Operator / app → CLI commands: runs commands (evidence: `README.md`)
- CLI commands → Proxy VPN core: starts core
- Proxy VPN core → Traffic router: routes traffic
- Traffic router → Routing rules: matches rules
- Traffic router → Outbound manager: selects outbound
- Proxy VPN core → DNS transports: resolves DNS
- DNS transports → DNS query events: emits query events
- Operator / app → lxd daemon: controls daemon (evidence: `README.md`)
- Operator / app → Native command API: uses native API (evidence: `README.md`)
- Operator / app → Clash API: uses REST API (evidence: `experimental/clashapi/server.go`)
- Operator / app → V2Ray API: uses API
- lxd daemon → Native command API: uses command API (evidence: `experimental/boxdd/server.go`)
- Clash API → Traffic router: exposes routing state (evidence: `experimental/clashapi/server.go`)
- Proxy VPN core → OpenVPN server: supports endpoint (evidence: `README.md`)
- Proxy VPN core → OpenConnect client: supports client
- Outbound manager → REALITY / TLS: uses TLS
- Outbound manager → WARP MASQUE: uses transport (evidence: `README.md`)
- Outbound manager → XHTTP transport: uses transport (evidence: `README.md`)
- Outbound manager → TrustTunnel: uses transport (evidence: `README.md`)
- Outbound manager → AmneziaWG: uses WireGuard endpoint (evidence: `README.md`)
- Proxy VPN core → Tailscale SSH: supports service
- Proxy VPN core → Origin CA: provides service
- Proxy VPN core → CCM usage: provides usage service
- Proxy VPN core → OCM usage: provides usage service
