Xray-core — Config Layout
Xray-core reads a single JSON document at startup. The root object maps directly to Go struct Config at infra/conf/xray.go:346. Every top-level field below corresponds to one JSON key.
Root keys
| Key | Go field | Type | Page | Description |
|---|---|---|---|---|
log | LogConfig | LogConfig | Log | Access and error log streams, level, DNS-query logging, IP masking. |
dns | DNSConfig | DNSConfig | DNS — Phase 5 | DNS resolver, server list, query strategy, fakedns linkage. |
routing | RouterConfig | RouterConfig | Routing — Phase 5 | Domain strategy, rules, balancers. |
inbounds | InboundConfigs | []InboundDetourConfig | Inbounds — Phase 3 | List of listening services. |
outbounds | OutboundConfigs | []OutboundDetourConfig | Outbounds — Phase 3 | List of upstream proxy targets. |
policy | Policy | PolicyConfig | Policy | Per-level timeouts, buffer size, user-stats toggles, system-stats toggles. |
api | API | APIConfig | API | gRPC management API inbound (tag + listen + service list). |
stats | Stats | StatsConfig | Stats | Empty struct; presence enables the stats subsystem. |
metrics | Metrics | MetricsConfig | Metrics | Prometheus exporter (tag + listen). |
reverse | Reverse | ReverseConfig | Reverse | Reverse-proxy bridges and portals. |
fakeDns | FakeDNS | FakeDNSConfig | FakeDNS | Fake-IP pool config (single object or array). |
observatory | Observatory | ObservatoryConfig | Observatory | Outbound latency probing. |
burstObservatory | BurstObservatory | BurstObservatoryConfig | Burst Observatory | Concurrent latency probing with health-check tuning. |
version | Version | VersionConfig | Version | Optional min/max version requirement. |
transport | Transport | map[string]json.RawMessage | Deprecated | Kept only to surface a friendly error if a legacy config carries it. |
Pages marked Phase 3/5 ship in those later phases; the column is here so the layout is complete today.
At a glance
json
{
"log": { "loglevel": "warning" },
"dns": {},
"routing": { "rules": [] },
"inbounds": [],
"outbounds": [],
"policy": { "levels": { "0": { "handshake": 4 } } },
"api": { "tag": "api", "listen": "127.0.0.1:10085", "services": ["HandlerService", "StatsService"] },
"stats": {},
"metrics": { "tag": "metrics", "listen": "127.0.0.1:9099" }
}Source: infra/conf/xray.go:346-365 · v1.260327.0 (d2758a0)
