This document provides a high-level introduction to Xray-core, a unified platform for anti-censorship network tools. It covers the project's purpose, core architectural design, key capabilities, and how the major components interact.
For detailed information about specific subsystems, see:
Sources: README.md1-50 core/core.go1-44
Xray-core is a unified network platform designed to provide anti-censorship tools and secure tunneling capabilities. The project originates from the XTLS protocol and has evolved into a comprehensive suite of network utilities that can accept incoming connections with various protocols, process traffic, and forward it through different connection types on demand.
The core mission statement, as defined in the codebase, is: "A unified platform for anti-censorship." The current codename is "Xray, Penetrates Everything."
Sources: core/core.go19-29 README.md1-50
Xray-core uses a semantic versioning scheme with three components: Version_x, Version_y, and Version_z. The version information is defined in core/core.go:
This translates to version 25.12.8. The version statement also includes build information and runtime details (Go version, OS, architecture) for debugging and compatibility verification.
| Component | Value | Purpose |
|---|---|---|
Version_x | 25 | Major version |
Version_y | 12 | Minor version |
Version_z | 8 | Patch version |
build | "Custom" (default) | Build identifier |
codename | "Xray, Penetrates Everything." | Project tagline |
intro | "A unified platform for anti-censorship." | Mission statement |
Sources: core/core.go19-43
Xray-core is organized into several major subsystems that work together to provide a flexible, extensible proxy platform:
Diagram: Core Component Architecture with Code Entities
The architecture follows a layered design:
Core Platform Layer: The core.Instance serves as the main orchestrator, managing all features and components through a feature registry system.
Connection Management Layer: Handles incoming and outgoing connections through proxyman.InboundHandler and proxyman.OutboundHandler interfaces, with workers (tcpWorker, udpWorker) managing the actual socket operations.
Proxy Protocol Layer: Implements various proxy protocols (proxy/vless, proxy/wireguard, proxy/freedom, etc.) that encode/decode traffic according to their specifications.
Traffic Management Layer: The app/dispatcher coordinates routing decisions with app/router, performs DNS lookups via app/dns, and collects statistics through app/stats.
Transport Layer: Provides security and obfuscation through transport/internet/tls, transport/internet/reality, and various other transport mechanisms, all using the internet.Dialer abstraction for network operations.
Sources: core/core.go1-44 proxy/wireguard/client.go48-78 proxy/wireguard/server.go26-72 transport/internet/reality/reality.go1-50
REALITY is Xray's advanced anti-censorship transport protocol that provides TLS traffic obfuscation while appearing as legitimate HTTPS connections. The implementation includes:
Diagram: REALITY Protocol Components
The REALITY client (UConn) establishes connections by:
If verification fails (indicating a potential MITM or redirection), the spider mechanism activates to mimic real browser behavior by crawling the destination website.
Sources: transport/internet/reality/reality.go1-299
VLESS is a lightweight proxy protocol designed for efficiency and flexibility. When combined with XTLS Vision, it provides:
The VLESS protocol stack integrates with various transports (TLS, REALITY, SplitHTTP) and supports advanced flow control mechanisms.
Sources: README.md79-91
Xray-core includes full WireGuard protocol support as both client and server, enabling:
The WireGuard implementation in proxy/wireguard creates a virtual TUN interface using gvisor's netstack, allowing WireGuard to operate without kernel modules while benefiting from Xray's routing and DNS capabilities.
Sources: proxy/wireguard/client.go1-339 proxy/wireguard/server.go1-191
Xray-core relies on several critical external libraries to implement its functionality:
| Dependency | Version | Purpose |
|---|---|---|
github.com/cloudflare/circl | v1.6.2 | Post-quantum cryptography (ML-KEM-768, ML-DSA-65) |
github.com/xtls/reality | v0.0.0-20251014195629 | REALITY protocol implementation |
github.com/refraction-networking/utls | v1.8.1 | TLS fingerprinting and client hello customization |
github.com/quic-go/quic-go | v0.58.0 | QUIC and HTTP/3 support |
golang.zx2c4.com/wireguard | v0.0.0-20231211153847 | WireGuard protocol implementation |
gvisor.dev/gvisor | v0.0.0-20250428193742 | Userspace network stack for WireGuard |
github.com/miekg/dns | v1.1.69 | DNS protocol handling |
google.golang.org/grpc | v1.78.0 | gRPC transport support |
google.golang.org/protobuf | v1.36.11 | Protocol buffer serialization |
Sources: go.mod1-57 go.sum1-165
Xray-core supports an extensive range of platforms through its automated build system:
Diagram: Build and Deployment Pipeline
The build system includes:
-trimpath, -buildvcs=false, -ldflags) for deterministic outputSources: .github/workflows/release.yml1-255 .github/workflows/docker.yml1-134 .github/workflows/release-win7.yml1-149 .github/workflows/scheduled-assets-update.yml1-66 .github/workflows/test.yml1-62
Understanding how traffic flows through Xray-core is essential for grasping the platform's operation:
Diagram: Traffic Flow Through Xray-core
The traffic flow follows these steps:
SystemListener accepts incoming connections and passes them to a worker (tcpWorker or udpWorker)proxy.Inbound) decodes the protocol-specific header and extracts the destinationDispatcher consults the Router to select an appropriate outbound handler based on routing rulesproxy.Outbound) establishes a connection to the target using the SystemDialerSources: proxy/wireguard/client.go145-252 proxy/wireguard/server.go79-120
Xray-core uses a flexible configuration system that supports JSON, TOML, and YAML formats, with a multi-file override mechanism:
Diagram: Configuration Processing Pipeline
The configuration system processes input through multiple stages:
infra/conf package converts human-readable config into structured types (InboundDetourConfig, OutboundDetourConfig, etc.)core.Instance loads the protobuf config and instantiates all handlers and featuresFor detailed configuration documentation, see Configuration System.
Sources: go.mod1-34
To understand specific aspects of Xray-core in more detail:
Xray-core includes a built-in statistics system for monitoring traffic and connection metrics. The app/stats package provides:
The statistics system uses a Channel implementation that supports:
Sources: app/stats/channel_test.go1-406
Xray-core follows a unified platform approach where all components interact through well-defined interfaces:
proxy.Inbound, proxy.Outbound) regardless of their underlying mechanismThis design philosophy enables Xray-core to support a wide variety of anti-censorship scenarios while maintaining code clarity and testability.
Sources: core/core.go1-44 README.md1-50
Refresh this wiki
This wiki was recently refreshed. Please wait 7 days to refresh again.