How xtls/xray-core works
Project X (Xray-core) is a configurable network proxy and tunneling core. Its runtime handles inbound proxy traffic, routes requests, and forwards them through outbound handlers and network transports; configuration, DNS, policy, and operational features support that flow. The excerpts show concrete dispatch from several inbound handlers and show routing, policy, DNS, and multiplexing dependencies. Many protocol and observability capabilities are evident in the tree but were not sampled, so their connections are left unverified rather than inferred.
Main entry points: worker.go Inbound workers · router.go Request routing · handler.go Outbound handlers · server.go WireGuard proxy
Components 20
Traffic runtime
- Inbound workers
app/proxyman/inbound/worker.go - Request routing
app/router/router.go - Outbound handlers
app/proxyman/outbound/handler.go - Network transports
transport/internet - Multiplexing
common/mux/server.go
Proxy protocols
- HTTP proxy
proxy/http/server.go - SOCKS proxy
proxy/socks/server.go - Trojan proxy
proxy/trojan/server.go - Shadowsocks proxy
proxy/shadowsocks/server.go - Hysteria proxy
proxy/hysteria/server.go - MASQUE proxy
proxy/masque/server.go - WireGuard proxy
proxy/wireguard/server.go
Core services
- DNS service
app/dns/dns.go - DNS cache
app/dns/cache_controller.go - Policy manager
app/policy/manager.go - Configuration loading
infra/conf/loader.go
Operations
- Traffic statistics
app/stats/stats.go - Health observation
app/observatory/observatory.go - Control API
main/commands/all/api/api.go
Other components
- Proxy client
Connections 25
- Proxy client → Inbound workers: opens connection
- Inbound workers → HTTP proxy: handles HTTP
- Inbound workers → SOCKS proxy: handles SOCKS
- Inbound workers → Trojan proxy: handles Trojan
- Inbound workers → Shadowsocks proxy: handles Shadowsocks
- Inbound workers → Hysteria proxy: handles Hysteria
- Inbound workers → MASQUE proxy: handles MASQUE
- Inbound workers → WireGuard proxy: handles WireGuard
- HTTP proxy → Request routing: dispatches links
proxy/http/server.go - SOCKS proxy → Request routing: dispatches links
proxy/socks/server.go - Trojan proxy → Request routing: dispatches packets
proxy/trojan/server.go - Shadowsocks proxy → Request routing: dispatches packets
proxy/shadowsocks/server.go - Hysteria proxy → Request routing: dispatches links
proxy/hysteria/server.go - WireGuard proxy → Request routing: dispatches links
proxy/wireguard/server.go - MASQUE proxy → WireGuard proxy: uses tunnel support
proxy/masque/server.go - Request routing → DNS service: uses DNS features
app/router/router.go - Outbound handlers → Multiplexing: uses multiplexing
app/proxyman/outbound/handler.go - Outbound handlers → Network transports: uses transports
app/proxyman/outbound/handler.go - Inbound workers → Network transports: accepts connections
app/proxyman/inbound/worker.go - Inbound workers → Request routing: dispatches requests
- Outbound handlers → Policy manager: applies policy
app/proxyman/outbound/handler.go - DNS service → DNS cache: caches answers
- Configuration loading → Request routing: builds rules
- Control API → Traffic statistics: queries statistics
- Health observation → Request routing: observes routing