mcp-xray-pilot 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +502 -0
  3. package/data/docs/_index.json +533 -0
  4. package/data/docs/basic__api.md +148 -0
  5. package/data/docs/basic__dns.md +366 -0
  6. package/data/docs/basic__fakedns.md +202 -0
  7. package/data/docs/basic__geodata.md +64 -0
  8. package/data/docs/basic__inbound.md +159 -0
  9. package/data/docs/basic__index.md +136 -0
  10. package/data/docs/basic__log.md +67 -0
  11. package/data/docs/basic__metrics.md +262 -0
  12. package/data/docs/basic__observatory.md +115 -0
  13. package/data/docs/basic__outbound.md +164 -0
  14. package/data/docs/basic__policy.md +140 -0
  15. package/data/docs/basic__reverse.md +268 -0
  16. package/data/docs/basic__routing.md +474 -0
  17. package/data/docs/basic__stats.md +61 -0
  18. package/data/docs/basic__transport.md +1283 -0
  19. package/data/docs/features__features_browser_dialer.md +61 -0
  20. package/data/docs/features__features_env.md +66 -0
  21. package/data/docs/features__features_fallback.md +110 -0
  22. package/data/docs/features__features_index.md +17 -0
  23. package/data/docs/features__features_multiple.md +144 -0
  24. package/data/docs/features__features_xtls.md +13 -0
  25. package/data/docs/inbounds__inbounds_dokodemo.md +11 -0
  26. package/data/docs/inbounds__inbounds_http.md +80 -0
  27. package/data/docs/inbounds__inbounds_hysteria.md +60 -0
  28. package/data/docs/inbounds__inbounds_index.md +22 -0
  29. package/data/docs/inbounds__inbounds_shadowsocks.md +118 -0
  30. package/data/docs/inbounds__inbounds_socks.md +87 -0
  31. package/data/docs/inbounds__inbounds_trojan.md +78 -0
  32. package/data/docs/inbounds__inbounds_tun.md +47 -0
  33. package/data/docs/inbounds__inbounds_tunnel.md +86 -0
  34. package/data/docs/inbounds__inbounds_vless.md +135 -0
  35. package/data/docs/inbounds__inbounds_vmess.md +95 -0
  36. package/data/docs/inbounds__inbounds_wireguard.md +78 -0
  37. package/data/docs/outbounds__outbounds_blackhole.md +42 -0
  38. package/data/docs/outbounds__outbounds_dns.md +97 -0
  39. package/data/docs/outbounds__outbounds_freedom.md +170 -0
  40. package/data/docs/outbounds__outbounds_http.md +70 -0
  41. package/data/docs/outbounds__outbounds_hysteria.md +39 -0
  42. package/data/docs/outbounds__outbounds_index.md +24 -0
  43. package/data/docs/outbounds__outbounds_loopback.md +65 -0
  44. package/data/docs/outbounds__outbounds_shadowsocks.md +105 -0
  45. package/data/docs/outbounds__outbounds_socks.md +58 -0
  46. package/data/docs/outbounds__outbounds_trojan.md +49 -0
  47. package/data/docs/outbounds__outbounds_vless.md +122 -0
  48. package/data/docs/outbounds__outbounds_vmess.md +76 -0
  49. package/data/docs/outbounds__outbounds_wireguard.md +141 -0
  50. package/data/docs/transports__transports_grpc.md +137 -0
  51. package/data/docs/transports__transports_h2.md +11 -0
  52. package/data/docs/transports__transports_http.md +11 -0
  53. package/data/docs/transports__transports_httpupgrade.md +61 -0
  54. package/data/docs/transports__transports_hysteria.md +110 -0
  55. package/data/docs/transports__transports_index.md +19 -0
  56. package/data/docs/transports__transports_mkcp.md +125 -0
  57. package/data/docs/transports__transports_quic.md +11 -0
  58. package/data/docs/transports__transports_raw.md +156 -0
  59. package/data/docs/transports__transports_splithttp.md +11 -0
  60. package/data/docs/transports__transports_tcp.md +11 -0
  61. package/data/docs/transports__transports_websocket.md +75 -0
  62. package/data/docs/transports__transports_xhttp.md +11 -0
  63. package/dist/data/compatibility.js +170 -0
  64. package/dist/data/compatibility.js.map +1 -0
  65. package/dist/data/geocatalogue.js +191 -0
  66. package/dist/data/geocatalogue.js.map +1 -0
  67. package/dist/docs.js +339 -0
  68. package/dist/docs.js.map +1 -0
  69. package/dist/handlers.js +217 -0
  70. package/dist/handlers.js.map +1 -0
  71. package/dist/index.js +66 -0
  72. package/dist/index.js.map +1 -0
  73. package/dist/lint.js +737 -0
  74. package/dist/lint.js.map +1 -0
  75. package/dist/schemas/protocols/blackhole.js +16 -0
  76. package/dist/schemas/protocols/blackhole.js.map +1 -0
  77. package/dist/schemas/protocols/common.js +32 -0
  78. package/dist/schemas/protocols/common.js.map +1 -0
  79. package/dist/schemas/protocols/dns.js +14 -0
  80. package/dist/schemas/protocols/dns.js.map +1 -0
  81. package/dist/schemas/protocols/dokodemo.js +17 -0
  82. package/dist/schemas/protocols/dokodemo.js.map +1 -0
  83. package/dist/schemas/protocols/freedom.js +45 -0
  84. package/dist/schemas/protocols/freedom.js.map +1 -0
  85. package/dist/schemas/protocols/http.js +38 -0
  86. package/dist/schemas/protocols/http.js.map +1 -0
  87. package/dist/schemas/protocols/hysteria.js +51 -0
  88. package/dist/schemas/protocols/hysteria.js.map +1 -0
  89. package/dist/schemas/protocols/index.js +50 -0
  90. package/dist/schemas/protocols/index.js.map +1 -0
  91. package/dist/schemas/protocols/loopback.js +11 -0
  92. package/dist/schemas/protocols/loopback.js.map +1 -0
  93. package/dist/schemas/protocols/shadowsocks.js +60 -0
  94. package/dist/schemas/protocols/shadowsocks.js.map +1 -0
  95. package/dist/schemas/protocols/socks.js +42 -0
  96. package/dist/schemas/protocols/socks.js.map +1 -0
  97. package/dist/schemas/protocols/trojan.js +34 -0
  98. package/dist/schemas/protocols/trojan.js.map +1 -0
  99. package/dist/schemas/protocols/tun.js +19 -0
  100. package/dist/schemas/protocols/tun.js.map +1 -0
  101. package/dist/schemas/protocols/vless.js +44 -0
  102. package/dist/schemas/protocols/vless.js.map +1 -0
  103. package/dist/schemas/protocols/vmess.js +48 -0
  104. package/dist/schemas/protocols/vmess.js.map +1 -0
  105. package/dist/schemas/protocols/wireguard.js +34 -0
  106. package/dist/schemas/protocols/wireguard.js.map +1 -0
  107. package/dist/schemas/security/index.js +16 -0
  108. package/dist/schemas/security/index.js.map +1 -0
  109. package/dist/schemas/security/reality.js +35 -0
  110. package/dist/schemas/security/reality.js.map +1 -0
  111. package/dist/schemas/security/tls.js +46 -0
  112. package/dist/schemas/security/tls.js.map +1 -0
  113. package/dist/schemas/security/xtls.js +17 -0
  114. package/dist/schemas/security/xtls.js.map +1 -0
  115. package/dist/schemas/transports/grpc.js +18 -0
  116. package/dist/schemas/transports/grpc.js.map +1 -0
  117. package/dist/schemas/transports/httpupgrade.js +14 -0
  118. package/dist/schemas/transports/httpupgrade.js.map +1 -0
  119. package/dist/schemas/transports/hysteria.js +25 -0
  120. package/dist/schemas/transports/hysteria.js.map +1 -0
  121. package/dist/schemas/transports/index.js +32 -0
  122. package/dist/schemas/transports/index.js.map +1 -0
  123. package/dist/schemas/transports/mkcp.js +34 -0
  124. package/dist/schemas/transports/mkcp.js.map +1 -0
  125. package/dist/schemas/transports/raw.js +19 -0
  126. package/dist/schemas/transports/raw.js.map +1 -0
  127. package/dist/schemas/transports/websocket.js +15 -0
  128. package/dist/schemas/transports/websocket.js.map +1 -0
  129. package/dist/schemas/transports/xhttp.js +34 -0
  130. package/dist/schemas/transports/xhttp.js.map +1 -0
  131. package/dist/search.js +78 -0
  132. package/dist/search.js.map +1 -0
  133. package/dist/state.js +87 -0
  134. package/dist/state.js.map +1 -0
  135. package/dist/tools.js +274 -0
  136. package/dist/tools.js.map +1 -0
  137. package/dist/tools_impl/diff.js +55 -0
  138. package/dist/tools_impl/diff.js.map +1 -0
  139. package/dist/tools_impl/github.js +416 -0
  140. package/dist/tools_impl/github.js.map +1 -0
  141. package/dist/tools_impl/merge.js +181 -0
  142. package/dist/tools_impl/merge.js.map +1 -0
  143. package/dist/tools_impl/refresh.js +46 -0
  144. package/dist/tools_impl/refresh.js.map +1 -0
  145. package/dist/tools_impl/suggest.js +169 -0
  146. package/dist/tools_impl/suggest.js.map +1 -0
  147. package/dist/types.js +10 -0
  148. package/dist/types.js.map +1 -0
  149. package/dist/utils.js +81 -0
  150. package/dist/utils.js.map +1 -0
  151. package/dist/validate.js +408 -0
  152. package/dist/validate.js.map +1 -0
  153. package/package.json +62 -0
@@ -0,0 +1,262 @@
1
+ ---
2
+ url: https://xtls.github.io/en/config/metrics.html
3
+ source_url: https://raw.githubusercontent.com/XTLS/Xray-docs-next/main/docs/en/config/metrics.md
4
+ title: Metrics
5
+ category: basic
6
+ slug: metrics
7
+ fetched_at: 2026-05-04T18:42:43.602Z
8
+ ---
9
+ # Metrics
10
+
11
+ A more direct (and hopefully better) way to export statistics.
12
+
13
+ ## Relevant Configuration
14
+
15
+ Add `metrics` to the basic configuration:
16
+
17
+ ```json
18
+ "metrics": {
19
+ "tag": "Metrics",
20
+ "listen": "127.0.0.1:11111"
21
+ }
22
+ ```
23
+
24
+ > `tag`: string
25
+
26
+ The outbound proxy tag corresponding to metrics. You can access it by setting up a dokodemo-door inbound + routing rules that point the dokodemo-door to this outbound.
27
+
28
+ > `listen`: string
29
+
30
+ A simpler method: directly listen on an address and port to provide the service.
31
+
32
+ When setting this field, if `tag` is empty, it will automatically be set to `Metrics`. If neither (`tag` nor `listen`) is set, the core will fail to start.
33
+
34
+ ## Usage
35
+
36
+ ### pprof
37
+
38
+ Visit `http://127.0.0.1:11111/debug/pprof/` or use `go tool pprof` for debugging.
39
+
40
+ To report excessive memory usage/memory leak issues, please provide files from `/debug/pprof/heap` and `/debug/pprof/goroutine`.
41
+
42
+ ### expvars
43
+
44
+ Visit `http://127.0.0.1:11111/debug/vars`
45
+
46
+ Variables included:
47
+
48
+ - `stats`: Includes all inbound, outbound, and user data.
49
+ - `observatory`: Includes observatory results.
50
+
51
+ For example, in [luci-app-xray](https://github.com/yichya/luci-app-xray), you can get output like this (standard expvar content like cmdline and memstats are omitted):
52
+
53
+ <details><summary>Click to view</summary><br>
54
+
55
+ ```json
56
+ {
57
+ "observatory": {
58
+ "tcp_outbound": {
59
+ "alive": true,
60
+ "delay": 782,
61
+ "outbound_tag": "tcp_outbound",
62
+ "last_seen_time": 1648477189,
63
+ "last_try_time": 1648477189
64
+ },
65
+ "udp_outbound": {
66
+ "alive": true,
67
+ "delay": 779,
68
+ "outbound_tag": "udp_outbound",
69
+ "last_seen_time": 1648477191,
70
+ "last_try_time": 1648477191
71
+ }
72
+ },
73
+ "stats": {
74
+ "inbound": {
75
+ "api": {
76
+ "downlink": 0,
77
+ "uplink": 0
78
+ },
79
+ "dns_server_inbound_5300": {
80
+ "downlink": 14286,
81
+ "uplink": 5857
82
+ },
83
+ "http_inbound": {
84
+ "downlink": 74460,
85
+ "uplink": 10231
86
+ },
87
+ "https_inbound": {
88
+ "downlink": 0,
89
+ "uplink": 0
90
+ },
91
+ "metrics": {
92
+ "downlink": 6327,
93
+ "uplink": 1347
94
+ },
95
+ "socks_inbound": {
96
+ "downlink": 19925615,
97
+ "uplink": 5512
98
+ },
99
+ "tproxy_tcp_inbound": {
100
+ "downlink": 4739161,
101
+ "uplink": 1568869
102
+ },
103
+ "tproxy_udp_inbound": {
104
+ "downlink": 0,
105
+ "uplink": 2608142
106
+ }
107
+ },
108
+ "outbound": {
109
+ "blackhole_outbound": {
110
+ "downlink": 0,
111
+ "uplink": 0
112
+ },
113
+ "direct": {
114
+ "downlink": 97714548,
115
+ "uplink": 3234617
116
+ },
117
+ "dns_server_outbound": {
118
+ "downlink": 7116,
119
+ "uplink": 2229
120
+ },
121
+ "manual_tproxy_outbound_tcp_1": {
122
+ "downlink": 0,
123
+ "uplink": 0
124
+ },
125
+ "manual_tproxy_outbound_udp_1": {
126
+ "downlink": 0,
127
+ "uplink": 0
128
+ },
129
+ "tcp_outbound": {
130
+ "downlink": 23873238,
131
+ "uplink": 1049595
132
+ },
133
+ "udp_outbound": {
134
+ "downlink": 639282,
135
+ "uplink": 74634
136
+ }
137
+ },
138
+ "user": {}
139
+ }
140
+ }
141
+ ```
142
+
143
+ </details>
144
+
145
+ To get better visualization output, you can use [Netdata](https://github.com/netdata/netdata) (with python.d plugin):
146
+
147
+ 1. Edit the relevant configuration file (`sudo /etc/netdata/edit-config python.d/go_expvar.conf`).
148
+ 2. Use the example configuration below:
149
+
150
+ <details><summary>Click to view</summary><br>
151
+
152
+ ```yaml
153
+ xray:
154
+ name: "xray"
155
+ update_every: 2
156
+ url: "http://127.0.0.1:11111/debug/vars"
157
+ collect_memstats: false
158
+ extra_charts:
159
+ - id: "inbounds"
160
+ options:
161
+ name: "inbounds"
162
+ title: "Xray System Inbounds"
163
+ units: bytes
164
+ family: xray
165
+ context: xray.inbounds
166
+ chart_type: line
167
+ lines:
168
+ - expvar_key: stats.inbound.tproxy_tcp_inbound.downlink
169
+ id: "tcp.downlink"
170
+ algorithm: incremental
171
+ expvar_type: int
172
+ - expvar_key: stats.inbound.tproxy_udp_inbound.downlink
173
+ id: "udp.downlink"
174
+ algorithm: incremental
175
+ expvar_type: int
176
+ - expvar_key: stats.inbound.http_inbound.downlink
177
+ id: "http.downlink"
178
+ algorithm: incremental
179
+ expvar_type: int
180
+ - expvar_key: stats.inbound.https_inbound.downlink
181
+ id: "https.downlink"
182
+ algorithm: incremental
183
+ expvar_type: int
184
+ - expvar_key: stats.inbound.socks_inbound.downlink
185
+ id: "socks.downlink"
186
+ algorithm: incremental
187
+ expvar_type: int
188
+ - expvar_key: stats.inbound.tproxy_tcp_inbound.uplink
189
+ id: "tcp.uplink"
190
+ algorithm: incremental
191
+ expvar_type: int
192
+ - expvar_key: stats.inbound.tproxy_udp_inbound.uplink
193
+ id: "udp.uplink"
194
+ algorithm: incremental
195
+ expvar_type: int
196
+ - expvar_key: stats.inbound.http_inbound.uplink
197
+ id: "http.uplink"
198
+ algorithm: incremental
199
+ expvar_type: int
200
+ - expvar_key: stats.inbound.https_inbound.uplink
201
+ id: "https.uplink"
202
+ algorithm: incremental
203
+ expvar_type: int
204
+ - expvar_key: stats.inbound.socks_inbound.uplink
205
+ id: "socks.uplink"
206
+ algorithm: incremental
207
+ expvar_type: int
208
+ - id: "outbounds"
209
+ options:
210
+ name: "outbounds"
211
+ title: "Xray System Outbounds"
212
+ units: bytes
213
+ family: xray
214
+ context: xray.outbounds
215
+ chart_type: line
216
+ lines:
217
+ - expvar_key: stats.outbound.tcp_outbound.downlink
218
+ id: "tcp.downlink"
219
+ algorithm: incremental
220
+ expvar_type: int
221
+ - expvar_key: stats.outbound.udp_outbound.downlink
222
+ id: "udp.downlink"
223
+ algorithm: incremental
224
+ expvar_type: int
225
+ - expvar_key: stats.outbound.direct.downlink
226
+ id: "direct.downlink"
227
+ algorithm: incremental
228
+ expvar_type: int
229
+ - expvar_key: stats.outbound.tcp_outbound.uplink
230
+ id: "tcp.uplink"
231
+ algorithm: incremental
232
+ expvar_type: int
233
+ - expvar_key: stats.outbound.udp_outbound.uplink
234
+ id: "udp.uplink"
235
+ algorithm: incremental
236
+ expvar_type: int
237
+ - expvar_key: stats.outbound.direct.uplink
238
+ id: "direct.uplink"
239
+ algorithm: incremental
240
+ expvar_type: int
241
+ - id: "observatory"
242
+ options:
243
+ name: "observatory"
244
+ title: "Xray Observatory Metrics"
245
+ units: milliseconds
246
+ family: xray
247
+ context: xray.observatory
248
+ chart_type: line
249
+ lines:
250
+ - expvar_key: observatory.tcp_outbound.delay
251
+ id: tcp
252
+ expvar_type: int
253
+ - expvar_key: observatory.udp_outbound.delay
254
+ id: udp
255
+ expvar_type: int
256
+ ```
257
+
258
+ </details>
259
+
260
+ You can get results similar to this:
261
+
262
+ ![160428235-2988bf69-5d6c-41ec-8267-1bd512508aa8](https://github.com/chika0801/Xray-docs-next/assets/88967758/455e88ce-ced2-4593-a9fa-425bb293215b)
@@ -0,0 +1,115 @@
1
+ ---
2
+ url: https://xtls.github.io/en/config/observatory.html
3
+ source_url: https://raw.githubusercontent.com/XTLS/Xray-docs-next/main/docs/en/config/observatory.md
4
+ title: Observatory
5
+ category: basic
6
+ slug: observatory
7
+ fetched_at: 2026-05-04T18:42:44.122Z
8
+ ---
9
+ # Observatory
10
+
11
+ The Observatory component uses HTTPing to probe the connection status of outbound proxies. The observation results can be used by other components, such as the Load Balancer. Currently, there are two types: [observatory](#observatoryobject) (Background Connection Observatory) and [burstObservatory](#burstobservatoryobject) (Burst Connection Observatory). Choose one according to your needs.
12
+
13
+ ## ObservatoryObject
14
+
15
+ ```json
16
+ {
17
+ "subjectSelector": ["outbound"],
18
+ "probeUrl": "https://www.google.com/generate_204",
19
+ "probeInterval": "10s",
20
+ "enableConcurrency": false
21
+ }
22
+ ```
23
+
24
+ > `subjectSelector`: \[ string \]
25
+
26
+ An array of strings, where each string is used for prefix matching against outbound proxy tags. Given the following outbound proxy tags: `[ "a", "ab", "c", "ba" ]`, `"subjectSelector": ["a"]` will match `[ "a", "ab" ]`.
27
+
28
+ > `probeUrl`: string
29
+
30
+ The URL used to probe the connection status of the outbound proxy.
31
+
32
+ > `probeInterval`: string
33
+
34
+ The interval for initiating probes. The time format is number + unit, such as `"10s"`, `"2h45m"`. Supported time units are `ns`, `us`, `ms`, `s`, `m`, `h`, corresponding to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours respectively.
35
+
36
+ Note that since the request interval is fixed, periodic fixed requests might lead to behavioral fingerprinting. Using protocols with multiplexing or enabling `mux` can alleviate this issue.
37
+
38
+ > `enableConcurrency`: true | false
39
+
40
+ - `true`: Probe all matched outbound proxies concurrently. Pauses for the time set in `probeInterval` after all are completed.
41
+ - `false`: Probe matched outbound proxies one by one. Pauses for the time set in `probeInterval` after each outbound proxy is probed.
42
+
43
+ ## BurstObservatoryObject
44
+
45
+ ```json
46
+ {
47
+ "subjectSelector": ["outbound"],
48
+ "pingConfig": {}
49
+ }
50
+ ```
51
+
52
+ > `subjectSelector`: \[ string \]
53
+
54
+ An array of strings, where each string is used for prefix matching against outbound proxy tags. Given the following outbound proxy tags: `[ "a", "ab", "c", "ba" ]`, `"subjectSelector": ["a"]` will match `[ "a", "ab" ]`.
55
+
56
+ > `pingConfig`: [PingConfigObject](#pingconfigobject)
57
+
58
+ ### PingConfigObject
59
+
60
+ ```json
61
+ {
62
+ // For each outbound, probe 10 times within 10 minutes; specific probe times are random.
63
+ // If they all fail, it will be marked as a faulty node within 10 ~ 20 minutes.
64
+ // After failure, a single successful probe will mark it as a healthy node; at slowest, it takes 10 minutes.
65
+ "destination": "https://connectivitycheck.gstatic.com/generate_204",
66
+ "connectivity": "",
67
+ "interval": "1m",
68
+ "sampling": 10,
69
+ "timeout": "5s",
70
+ "httpMethod": "HEAD"
71
+ }
72
+ ```
73
+
74
+ > `destination`: string
75
+
76
+ The URL used to probe the connection status of the outbound proxy. This URL should return an HTTP 204 success status code.
77
+ Default `"https://connectivitycheck.gstatic.com/generate_204"`.
78
+
79
+ > `connectivity`: string
80
+
81
+ The URL used to check local network connectivity. This URL should return an HTTP 204 success status code.
82
+
83
+ An empty string indicates no local network connectivity check.
84
+
85
+ This probe is executed only when the `destination` probe fails. This makes the cause of network failure clearer in the logs.
86
+
87
+ Note: In transparent proxy mode, this request might be captured by the transparent proxy and re-enter Xray for routing (depending on your configuration). You need to use extra means to ensure it is not captured by the transparent proxy, such as bypassing based on the URL IP, or using cgroup/pid routing to completely prevent Xray's requests from being captured. Alternatively, you can choose a URL that matches a direct connection rule and allow this request to be captured by the transparent proxy.
88
+
89
+ > `interval`: string
90
+
91
+ The expected **average** probe interval for each outbound proxy.
92
+
93
+ The time format is number + unit, such as `"10s"`, `"2h45m"`. Supported time units are `ns`, `us`, `ms`, `s`, `m`, `h`, corresponding to nanoseconds, microseconds, milliseconds, seconds, minutes, and hours respectively.
94
+ Default `"1m"`. Minimum allowed value is `"10s"`. If less is specified, `"10s"` will be used.
95
+
96
+ > `sampling`: number
97
+
98
+ The number of recent probe results to keep.
99
+ Default `10`.
100
+
101
+ > `timeout`: string
102
+
103
+ Probe timeout. Format is the same as `interval` above.
104
+ Default `"5s"`.
105
+
106
+ > `httpMethod`: string
107
+
108
+ The HTTP method used for probing (e.g. `"HEAD"`, `"GET"`).
109
+ Default `"HEAD"`.
110
+
111
+ ::: tip
112
+ The working principle of Burst Observatory is to immediately schedule probe tasks for each matched outbound at every `interval` \* `sampling` (hereinafter referred to as the probe cycle). However, within each task's cycle, the probe is executed at a random time. This means compared to `observatory` (Background Connection Observatory), the fingerprint of this detector is less obvious. But if `interval` is set too small, or `sampling` is too large causing frequent probing, the fingerprint will be more obvious.
113
+
114
+ `interval` and `sampling` jointly affect the sensitivity of failover and recovery. When a node fails probes continuously, it takes at fastest 1 probe cycle to mark the node as faulty, and at slowest 2 probe cycles. Recovering from failure requires one successful probe, which depends on the probe density; at slowest, it takes 1 probe cycle.
115
+ :::
@@ -0,0 +1,164 @@
1
+ ---
2
+ url: https://xtls.github.io/en/config/outbound.html
3
+ source_url: https://raw.githubusercontent.com/XTLS/Xray-docs-next/main/docs/en/config/outbound.md
4
+ title: Outbound Proxy (Mux, XUDP)
5
+ category: basic
6
+ slug: outbound
7
+ fetched_at: 2026-05-04T18:42:40.576Z
8
+ ---
9
+ # Outbound Proxy (Mux, XUDP)
10
+
11
+ Outbound connections are used to send data. For available protocols, please see [Outbound Protocols](./outbounds/).
12
+
13
+ ## OutboundObject
14
+
15
+ `OutboundObject` corresponds to a sub-element of the `outbounds` item in the configuration file.
16
+
17
+ ::: tip
18
+ The first element in the list serves as the primary outbound. When a routing match does not exist or fails, traffic is sent via the primary outbound.
19
+ :::
20
+
21
+ ```json
22
+ {
23
+ "outbounds": [
24
+ {
25
+ "sendThrough": "0.0.0.0",
26
+ "protocol": "protocol_name",
27
+ "settings": {},
28
+ "tag": "identifier",
29
+ "streamSettings": {},
30
+ "proxySettings": {
31
+ "tag": "another-outbound-tag",
32
+ "transportLayer": false
33
+ },
34
+ "mux": {},
35
+ "targetStrategy": "AsIs"
36
+ }
37
+ ]
38
+ }
39
+ ```
40
+
41
+ > `sendThrough`: address
42
+
43
+ The IP address used to send data. This is effective when the host has multiple IP addresses. The default value is `"0.0.0.0"`.
44
+
45
+ You can enter an IPv6 CIDR block (e.g., `114:514:1919:810::/64`), and Xray will use a random IP address from the address block to initiate external connections.
46
+ You need to correctly configure the network access method, routing table, and kernel parameters to allow Xray to bind to any IP within the address block.
47
+
48
+ For networks using NDP access, it is not recommended to set a subnet smaller than `/120`. Otherwise, it may cause issues such as NDP flooding, leading to the router's neighbor cache becoming full.
49
+
50
+ Special value `origin`: If this value is used, the request will be sent using the IP address of the local machine that received the connection.
51
+
52
+ For example, if the machine has a full IPv4 range `11.4.5.0/24` and listens on `0.0.0.0` (all IPv4 and IPv6 on the network interface), if a client connects to the local machine via `11.4.5.14`, the outbound request will also be sent via `11.4.5.14`. If the client connects via `11.4.5.10`, the outbound request will be sent via `11.4.5.10`. This also applies to cases where the machine has a full range/multiple IPv6 addresses.
53
+
54
+ As mentioned in the inbound introduction, because of the connectionless nature of UDP, Xray cannot know the original destination IP where the request entered the core (for example, in the same QUIC connection, it might even change), so this feature cannot take effect for UDP.
55
+
56
+ > `protocol`: "blackhole" | "dns" | "freedom" | "http" | "loopback" | "shadowsocks" | "socks" | "trojan" | "vless" | "vmess" | "hysteria" | "wireguard"
57
+
58
+ The connection protocol name. For the list of optional protocols, see [Outbound Protocols](./outbounds/) on the left.
59
+
60
+ > `settings`: OutboundConfigurationObject
61
+
62
+ Specific configuration content, which varies by protocol. See `OutboundConfigurationObject` in each protocol for details.
63
+
64
+ > `tag`: string
65
+
66
+ The identifier for this outbound connection, used to locate this connection in other configurations.
67
+
68
+ ::: danger
69
+ When not empty, its value must be **unique** among all `tag`s.
70
+ :::
71
+
72
+ > `streamSettings`: [StreamSettingsObject](./transport.md#streamsettingsobject)
73
+
74
+ The underlying transport method is the way the current Xray node connects with other nodes.
75
+
76
+ > `proxySettings`: [ProxySettingsObject](#proxysettingsobject)
77
+
78
+ Outbound proxy configuration.
79
+
80
+ > `mux`: [MuxObject](#muxobject)
81
+
82
+ Specific configuration related to Mux.
83
+
84
+ > `targetStrategy`: "AsIs" | "UseIP" | "UseIPv6v4" | "UseIPv6" | "UseIPv4v6" | "UseIPv4" | "ForceIP" | "ForceIPv6v4" | "ForceIPv6" | "ForceIPv4v6" | "ForceIPv4"
85
+
86
+ If this outbound attempts to send a domain request, this controls whether it is resolved/how it is resolved to an IP before sending.
87
+
88
+ The default value is `AsIs`, meaning it is sent to the remote server as is. All parameter meanings are roughly equivalent to `domainStrategy` in [sockopt](./transport.md#sockoptobject).
89
+
90
+ ::: tip
91
+ This controls **proxied requests**. If the address of the outbound proxy server is a domain name, and you need to select a resolution strategy for the domain name itself, you should configure `domainStrategy` in [sockopt](./transport.md#sockoptobject).
92
+ :::
93
+
94
+ ### ProxySettingsObject
95
+
96
+ ```json
97
+ {
98
+ "tag": "another-outbound-tag",
99
+ "transportLayer": false
100
+ }
101
+ ```
102
+
103
+ > `tag`: string
104
+
105
+ When the identifier of another outbound is specified, data sent by this outbound will be forwarded to the specified outbound for transmission.
106
+
107
+ ::: danger
108
+ This option conflicts with [SockOpt.dialerProxy](./transport.md#sockoptobject). Choose one as needed.
109
+
110
+ By default, this forwarding method **does not go through** the underlying transport method (REALITY/XHTTP/gRPC...), meaning the `streamSettings` of this outbound will not take effect.<br>
111
+ If you need forwarding that supports underlying transport methods, please use `SockOpt.dialerProxy` instead or set `transportLayer` to `true`.
112
+ :::
113
+
114
+ > `transportLayer`: true | false
115
+
116
+ `true` converts this setting to `SockOpt.dialerProxy` to support forwarding via underlying transport methods. The default is `false`, meaning no conversion.
117
+
118
+ ### MuxObject
119
+
120
+ The Mux function distributes data from multiple TCP connections over a single TCP connection. For implementation details, see [Mux.Cool](../development/protocols/muxcool.md). Mux is designed to reduce TCP handshake latency, not to increase connection throughput. Using Mux for watching videos, downloading, or speed testing usually has a negative effect. Mux only needs to be enabled on the client side; the server side adapts automatically. The second use of Mux is to distribute multiple UDP connections, i.e., XUDP.
121
+
122
+ `MuxObject` corresponds to the `mux` item in `OutboundObject`.
123
+
124
+ ```json
125
+ {
126
+ "enabled": true,
127
+ "concurrency": 8,
128
+ "xudpConcurrency": 16,
129
+ "xudpProxyUDP443": "reject"
130
+ }
131
+ ```
132
+
133
+ > `enabled`: true | false
134
+
135
+ Whether to enable Mux for forwarding requests. Default is `false`.
136
+
137
+ > `concurrency`: number
138
+
139
+ Maximum concurrent connections. Minimum `1`, maximum `128`. If omitted or set to `0`, it equals `8`. Values greater than `128` are treated as 128, because once a connection reaches the maximum reuse count of 128, it will no longer be assigned any new sub-connections.
140
+
141
+ This value represents the maximum number of sub-connections carried on a single TCP connection. For example, if `concurrency=8` is set, when the client issues 8 TCP requests, Xray will only issue one actual TCP connection, and all 8 requests from the client are transmitted over this TCP connection.
142
+
143
+ When the maximum sub-connection capacity of all Mux connections is fully occupied, the core will initiate new connections to carry sub-connections. If a large number of sub-connections are concurrent in a short time and subsequently decrease, the internal scheduler of the core will tend to distribute requests to 2 connections alternately and leave other connections idle, waiting for all their sub-connections to end naturally before closing them to save resources. If the total number of sub-connections continues to be lower than `concurrency` for a long time, after one of the connections reaches the maximum reuse count, the core will revert to a single connection state.
144
+
145
+ ::: tip
146
+ When set to a negative number, such as `-1`, the Mux module is not used to carry TCP traffic.
147
+ :::
148
+
149
+ > `xudpConcurrency`: number
150
+
151
+ Use a new XUDP aggregation tunnel (i.e., another Mux connection) to proxy UDP traffic. Fill in the maximum number of concurrent sub-UoT. Minimum `1`, maximum `1024`.
152
+ If omitted or set to `0`, it will follow the same path as TCP traffic, which is the traditional behavior.
153
+
154
+ ::: tip
155
+ When set to a negative number, such as `-1`, the Mux module is not used to carry UDP traffic. The proxy protocol's original UDP transmission method will be used. For example, `Shadowsocks` will use native UDP, and `VLESS` will use UoT.
156
+ :::
157
+
158
+ > `xudpProxyUDP443`: string
159
+
160
+ Controls how Mux handles proxied UDP/443 (QUIC) traffic:
161
+
162
+ - Default `reject`: Rejects traffic (browsers typically fall back to TCP HTTP2 automatically).
163
+ - `allow`: Allows traffic to go through the Mux connection.
164
+ - `skip`: Does not use the Mux module to carry UDP 443 traffic. The proxy protocol's original UDP transmission method will be used. For example, `Shadowsocks` will use native UDP, and `VLESS` will use UoT.
@@ -0,0 +1,140 @@
1
+ ---
2
+ url: https://xtls.github.io/en/config/policy.html
3
+ source_url: https://raw.githubusercontent.com/XTLS/Xray-docs-next/main/docs/en/config/policy.md
4
+ title: Local Policy
5
+ category: basic
6
+ slug: policy
7
+ fetched_at: 2026-05-04T18:42:41.083Z
8
+ ---
9
+ # Local Policy
10
+
11
+ Local policy allows setting different user levels and corresponding policy settings, such as connection timeout settings. Every connection processed by Xray corresponds to a user, and different policies are applied according to the user's level.
12
+
13
+ ## PolicyObject
14
+
15
+ `PolicyObject` corresponds to the `policy` item in the configuration file.
16
+
17
+ ```json
18
+ {
19
+ "policy": {
20
+ "levels": {
21
+ "0": {
22
+ "handshake": 4,
23
+ "connIdle": 300,
24
+ "uplinkOnly": 2,
25
+ "downlinkOnly": 5,
26
+ "statsUserUplink": false,
27
+ "statsUserDownlink": false,
28
+ "statsUserOnline": false,
29
+ "bufferSize": 4
30
+ }
31
+ },
32
+ "system": {
33
+ "statsInboundUplink": false,
34
+ "statsInboundDownlink": false,
35
+ "statsOutboundUplink": false,
36
+ "statsOutboundDownlink": false
37
+ }
38
+ }
39
+ }
40
+ ```
41
+
42
+ > `level`: map{string: [LevelPolicyObject](#levelpolicyobject)}
43
+
44
+ A set of key-value pairs, where each key is a number in string format (required by JSON), such as `"0"`, `"1"`, etc. The double quotes cannot be omitted. This number corresponds to the user level. Each value is a [LevelPolicyObject](#levelpolicyobject).
45
+
46
+ ::: tip
47
+ Each inbound and outbound proxy can now set a user level. Xray will apply different local policies based on the actual user level.
48
+ :::
49
+
50
+ > `system`: [SystemPolicyObject](#systempolicyobject)
51
+
52
+ Xray system-level policies.
53
+
54
+ ### LevelPolicyObject
55
+
56
+ ```json
57
+ {
58
+ "handshake": 4,
59
+ "connIdle": 300,
60
+ "uplinkOnly": 2,
61
+ "downlinkOnly": 5,
62
+ "statsUserUplink": false,
63
+ "statsUserDownlink": false,
64
+ "bufferSize": 10240
65
+ }
66
+ ```
67
+
68
+ > `handshake`: number
69
+
70
+ Handshake time limit when establishing a connection. Unit is seconds. Default value is `4`. When an inbound proxy processes a new connection, if the time used during the handshake phase exceeds this time, the connection is interrupted.
71
+
72
+ > `connIdle`: number
73
+
74
+ Connection idle time limit. Unit is seconds. Default value is `300`. When an inbound/outbound processes a connection, if no data is transferred (including uplink and downlink data) within the `connIdle` time, the connection is interrupted.
75
+
76
+ > `uplinkOnly`: number
77
+
78
+ Time limit after the downlink connection is closed. Unit is seconds. Default value is `2`. When the server (such as a remote website) closes the downlink connection, the outbound proxy will interrupt the connection after waiting for the `uplinkOnly` time.
79
+
80
+ > `downlinkOnly`: number
81
+
82
+ Time limit after the uplink connection is closed. Unit is seconds. Default value is `5`. When the client (such as a browser) closes the uplink connection, the inbound proxy will interrupt the connection after waiting for the `downlinkOnly` time.
83
+
84
+ ::: tip
85
+ In HTTP browsing scenarios, `uplinkOnly` and `downlinkOnly` can be set to `0` to improve connection closing efficiency.
86
+ :::
87
+
88
+ > `statsUserUplink`: true | false
89
+
90
+ When set to `true`, enables uplink traffic statistics for all users of the current level.
91
+
92
+ > `statsUserDownlink`: true | false
93
+
94
+ When set to `true`, enables downlink traffic statistics for all users of the current level.
95
+
96
+ > `statsUserOnline`: true | false
97
+ > When set to `true`, enables online user count statistics for all users of the current level. (Online criteria: connection activity within 20 seconds).
98
+
99
+ > `bufferSize`: number
100
+
101
+ The internal buffer size for each request, in KB. Note that multiple requests may be carried on the same connection via multiplexing (e.g., when using mux.cool or gRPC). This means that even if they share an underlying connection, their buffer pools are independent.
102
+
103
+ When the internal buffer is larger than this value, the next write operation will only be performed after the internal buffer is sent out until it is less than or equal to this value.
104
+
105
+ Note that for a UDP request, if a write attempt is made while the buffer is full, the write operation will not be blocked but **discarded**. If set too low or to 0, it may cause unexpected bandwidth waste.
106
+
107
+ Default values:
108
+
109
+ - On ARM, MIPS, MIPSLE platforms, the default value is `0`.
110
+ - On ARM64, MIPS64, MIPS64LE platforms, the default value is `4`.
111
+ - On other platforms, the default value is `512`.
112
+
113
+ The default value can be set via the environment variable `XRAY_RAY_BUFFER_SIZE`. Note that the unit in the environment variable is MB (setting the environment variable to 1 is equivalent to setting the config to 1024).
114
+
115
+ ### SystemPolicyObject
116
+
117
+ ```json
118
+ {
119
+ "statsInboundUplink": false,
120
+ "statsInboundDownlink": false,
121
+ "statsOutboundUplink": false,
122
+ "statsOutboundDownlink": false
123
+ }
124
+ ```
125
+
126
+ > `statsInboundUplink`: true | false
127
+
128
+ When set to `true`, enables uplink traffic statistics for all inbound proxies.
129
+
130
+ > `statsInboundDownlink`: true | false
131
+
132
+ When set to `true`, enables downlink traffic statistics for all inbound proxies.
133
+
134
+ > `statsOutboundUplink`: true | false
135
+
136
+ When set to `true`, enables uplink traffic statistics for all outbound proxies.
137
+
138
+ > `statsOutboundDownlink`: true | false
139
+
140
+ When set to `true`, enables downlink traffic statistics for all outbound proxies.