$ show XTLS/Xray-core
Xray-core is a production-grade network proxy framework written in Go. It implements a wide range of proxy protocols (VMess, VLESS, Shadowsocks, Trojan, Hysteria, WireGuard, SOCKS, HTTP) and transport layers (TCP, WebSocket, gRPC, KCP, SplitHTTP, HTTPUpgrade, QUIC) with advanced obfuscation techniques (Noise, Sudoku, XMC, Realm) for censorship circumvention. The architecture is modular, with pluggable inbound/outbound handlers, a rule-based router with domain/IP/port/protocol matching, a DNS subsystem supporting multiple upstreams (DoH, DoQ, TCP, UDP, FakeDNS), and an observatory for health-based load balancing. Configuration is via JSON/protobuf, and runtime management is exposed through gRPC APIs. The codebase is extensive, well-tested (unit and integration scenarios), and leverages Go's concurrency primitives heavily for performance. However, it includes experimental transports and deprecated features (e.g., legacy Shadowsocks, xtls security), indicating ongoing evolution and some technical drift in the ecosystem.
The LLM identified 4 files worth highlighting for reuse:
Provides a recyclable buffer (Alloc/Free) with managed and unmanaged ownership, multi-buffer concatenation, and copy-free slice operations. Used pervasively across all proxy protocols and transport layers. Demonstrates careful memory management and zero-copy design patterns.
Implements a domain matcher using a minimal perfect hash (MPH) function for O(1) lookup of exact/full domain patterns. Includes a compact encoding variant for memory efficiency. A self-contained, performance-critical component that can be extracted for any high-throughput string matching task.
Defines a custom error type that captures caller file/line and supports formatted messages with severity levels. Used as the single error path throughout the codebase, enabling consistent logging and debugging without external dependencies.
Manages multiplexed sessions over a single transport connection, including frame sequencing, ID tracking, and XUDP support. Isolated from transport specifics, this component can be reused for any multiplexing protocol that requires session lifecycle management.