How v2ray/v2ray-core works
Project V is a configurable network proxy platform for securing connections and protecting privacy. The runtime starts from a server configuration, accepts TCP/UDP traffic through inbound handlers, and routes requests to destinations; proxy protocols, outbound handlers, and transports provide the connection mechanisms. DNS resolution, routing policy, multiplexing, and management/configuration are separate supporting capabilities. The excerpts show key dispatch relationships, but many subsystems are represented by their directory because their implementations were not sampled.
Main entry points: router.go Router · handler.go Outbound handlers · worker.go Inbound workers · proxy Other proxy protocols
Components 18
Runtime and configuration
- Runtime launcher
main/main.go - Config conversion
infra/conf - Core server
core.go
Traffic handling
- Inbound workers
app/proxyman/inbound/worker.go - Outbound handlers
app/proxyman/outbound/handler.go - Session policy
app/policy/manager.go - Traffic statistics
app/stats - Reverse proxy
app/reverse
Routing and DNS
- Router
app/router/router.go - DNS service
app/dns/server.go
Proxy protocols
- HTTP proxy
proxy/http/server.go - SOCKS proxy
proxy/socks/server.go - Trojan proxy
proxy/trojan/server.go - Other proxy protocols
proxy
Transport and services
- Multiplexing
common/mux - Network transports
transport/internet
Other components
- Operator
- Network clients
Connections 16
- Operator → Runtime launcher: starts
main/main.go - Runtime launcher → Core server: creates
main/main.go - Config conversion → Router: builds routing config
infra/conf/router.go - Network clients → Inbound workers: sends traffic
- Inbound workers → Other proxy protocols: selects handler
app/proxyman/inbound/worker.go - Inbound workers → Network transports: uses connections
app/proxyman/inbound/worker.go - HTTP proxy → Router: dispatches requests
proxy/http/server.go - SOCKS proxy → Router: dispatches requests
proxy/socks/server.go - Trojan proxy → Router: dispatches requests
proxy/trojan/server.go - Other proxy protocols → Outbound handlers: uses outbound
app/proxyman/outbound/handler.go - Outbound handlers → Network transports: dials destinations
app/proxyman/outbound/handler.go - Outbound handlers → Multiplexing: dispatches sessions
app/proxyman/outbound/handler.go - Router → DNS service: resolves domains
- DNS service → Router: requests dispatcher
app/dns/server.go - Other proxy protocols → Session policy: reads session limits
- Outbound handlers → Traffic statistics: updates counters
app/proxyman/outbound/handler.go