transports.mdx 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. ---
  2. title: Transports & Security
  3. description: Every transport 3x-ui exposes — TCP, mKCP, WebSocket, gRPC, HTTPUpgrade, XHTTP, Hysteria, XDRIVE, MASQUE — with their settings, plus FinalMask obfuscation, sockopt, TLS/REALITY, XTLS-Vision, and VLESS encryption.
  4. icon: Network
  5. ---
  6. A **transport** decides how packets are carried between client and server, a
  7. **security** layer decides how they're encrypted and disguised, and **FinalMask**
  8. can obfuscate what's left. The panel only offers valid combinations; this page
  9. lists every transport's settings and the rules the panel enforces.
  10. ## Transports
  11. Pick the transport (the inbound's `network`) in the inbound/outbound form. Each
  12. network writes its own settings key on the wire (`tcpSettings`, `kcpSettings`, …).
  13. | Transport | Settings key | When to use it |
  14. | --------------- | --------------------- | ---------------------------------------------------------------------- |
  15. | **TCP (Raw)** | `tcpSettings` | Lowest overhead. The basis for REALITY + XTLS-Vision and fallbacks; optional HTTP/1.1 header camouflage. |
  16. | **mKCP** | `kcpSettings` | Reliable protocol over **UDP** — trades bandwidth for lower latency on lossy links. Carries no TLS/REALITY. |
  17. | **WebSocket** | `wsSettings` | Works through CDNs and HTTP reverse proxies; very compatible. |
  18. | **gRPC** | `grpcSettings` | HTTP/2-based; multiplexes well and proxies cleanly through Nginx. |
  19. | **HTTPUpgrade** | `httpupgradeSettings` | CDN-friendly HTTP/1.1 `Upgrade`; lighter than full WebSocket. |
  20. | **XHTTP** | `xhttpSettings` | Modern stream-multiplexed HTTP transport; CDN-friendly and REALITY-capable. |
  21. | **Hysteria** | `hysteriaSettings` | QUIC-based transport — only for the **Hysteria2** protocol. |
  22. | **XDRIVE** | `xdriveSettings` | Tunnels the stream through files in shared cloud storage (Google Drive, a local folder or any HTTP storage API). |
  23. | **MASQUE** | `masqueSettings` | CONNECT-IP over HTTP/3 or HTTP/2 — only for the **MASQUE** protocol. See [MASQUE](/docs/config/masque). |
  24. <Callout type="info">
  25. **WireGuard** and **Tunnel** (dokodemo-door) inbounds expose no transport
  26. selector — their stream carries only security/sockopt. Earlier panels also
  27. exposed a raw **HTTP/2 (`http`)** transport; it has been superseded by **XHTTP**
  28. and is no longer selectable.
  29. </Callout>
  30. ### TCP (Raw) — `tcpSettings`
  31. | Field | Default | Meaning |
  32. | ------------------------------ | ------- | ----------------------------------------------------------------------- |
  33. | `acceptProxyProtocol` | `false` | Accept the PROXY protocol from an upstream proxy so the real client IP is preserved. |
  34. | `header.type` | `none` | `none`, or `http` for HTTP/1.1 camouflage. |
  35. | `header.request` / `response` | — | When `type: http`: method, path, version and a header map that mimic a normal HTTP exchange. |
  36. ### mKCP — `kcpSettings`
  37. | Field | Default | Meaning |
  38. | ------------------ | ----------- | ---------------------------------------------------------------- |
  39. | `mtu` | `1350` | Maximum transmission unit, in bytes (576–1460). |
  40. | `tti` | `20` | Transmission time interval, in ms (10–100). Lower = more responsive, more overhead. |
  41. | `uplinkCapacity` | `5` | Upload bandwidth budget, in **MB/s**. |
  42. | `downlinkCapacity` | `20` | Download bandwidth budget, in **MB/s**. |
  43. | `cwndMultiplier` | `1` | Congestion-window multiplier; raise to push harder on good links. |
  44. | `maxSendingWindow` | `2097152` | Upper bound on in-flight packets. |
  45. <Callout type="info">
  46. mKCP can't carry TLS or REALITY. To disguise it, add a **FinalMask** UDP mask —
  47. the `mkcp-legacy` mask reproduces the classic header obfuscation that older Xray
  48. stored in `kcpSettings.header`/`seed` (those fields no longer exist here).
  49. </Callout>
  50. ### WebSocket — `wsSettings`
  51. | Field | Default | Meaning |
  52. | --------------------- | ------- | ---------------------------------------------------------------- |
  53. | `path` | `/` | Request path — route on it when several services share one host. |
  54. | `host` | _(none)_| `Host` header override (useful behind a CDN). |
  55. | `headers` | `{}` | Extra request headers. |
  56. | `heartbeatPeriod` | `0` | Seconds between keepalive pings; `0` disables them. |
  57. | `acceptProxyProtocol` | `false` | Accept the PROXY protocol from an upstream. |
  58. ### gRPC — `grpcSettings`
  59. | Field | Default | Meaning |
  60. | ------------- | ------- | --------------------------------------------------------- |
  61. | `serviceName` | _(none)_| gRPC service path; acts like a secret route. |
  62. | `authority` | _(none)_| `:authority` pseudo-header override. |
  63. | `multiMode` | `false` | Multiplex several streams over one connection. |
  64. ### HTTPUpgrade — `httpupgradeSettings`
  65. | Field | Default | Meaning |
  66. | --------------------- | ------- | --------------------------------------------- |
  67. | `path` | `/` | Request path. |
  68. | `host` | _(none)_| `Host` header override. |
  69. | `headers` | `{}` | Extra request headers. |
  70. | `acceptProxyProtocol` | `false` | Accept the PROXY protocol from an upstream. |
  71. HTTPUpgrade is a one-shot HTTP/1.1 `Upgrade` with no WebSocket framing — there's
  72. no heartbeat field.
  73. ### XHTTP — `xhttpSettings`
  74. XHTTP (SplitHTTP) has a large field set; the panel fills sensible defaults. The
  75. ones you'll usually touch:
  76. | Field | Default | Meaning |
  77. | ---------------------- | ----------- | ---------------------------------------------------------------------- |
  78. | `path` | `/` | Request path. |
  79. | `host` | _(none)_ | `Host` header override. |
  80. | `mode` | `auto` | `auto`, `packet-up`, `stream-up`, or `stream-one`. `packet-up` is the most CDN-compatible; `stream-*` are lower latency. |
  81. | `xPaddingBytes` | `100-1000` | Random padding range that blurs packet sizes. |
  82. | `scMaxBufferedPosts` | `30` | Server-side buffer for uploaded POSTs. |
  83. | `scStreamUpServerSecs` | `20-80` | Stream-up server window (dash range). |
  84. | `xmux` (`enableXmux`) | _(off)_ | Connection multiplexing — `maxConcurrency` `16-32`, `maxConnections` `6`, … Turn on for high concurrency. |
  85. Session-ID fields (`sessionIDPlacement`, `sessionIDKey`, `sessionIDTable`,
  86. `sessionIDLength`) and the `scMin/MaxEachPostBytes` knobs are advanced; leave them
  87. empty unless you're matching a specific upstream.
  88. ### Hysteria — `hysteriaSettings`
  89. Only valid when the protocol is **Hysteria2**.
  90. | Field | Default | Meaning |
  91. | ---------------- | ------- | ----------------------------------------------------------------------- |
  92. | `version` | `2` | Hysteria protocol version. |
  93. | `auth` | _(none)_| Shared authentication string. |
  94. | `udpIdleTimeout` | `60` | Seconds (2–600) before idle UDP sessions are dropped. |
  95. | `masquerade` | — | Disguise as an HTTP/3 server: `type` `proxy`/`file`/`string` with `url`/`dir`/`content`, plus `headers` and `statusCode`. |
  96. ### XDRIVE — `xdriveSettings`
  97. XDRIVE carries the stream as files in a folder both ends can reach: the server polls
  98. that folder instead of accepting connections on its port. Both sides must use the
  99. **same** service, folder and secrets, so the JSON subscription ships them to every
  100. client; XDRIVE inbounds get no share link or Clash entry.
  101. | Field | Default | Meaning |
  102. | -------------- | -------------- | ----------------------------------------------------------------------- |
  103. | `service` | `Google Drive` | `Google Drive`, `local` (a folder on disk) or `template` (any HTTP storage API). |
  104. | `remoteFolder` | — | Folder that holds the session files. |
  105. | `secrets` | — | Google Drive: ClientID, ClientSecret, RefreshToken — exactly three, in that order. Template: values read as `{secret0}`, `{secret1}`, …. |
  106. | `template` | — | Template service only: the storage API's `auth`, `put`, `get`, `list` and `delete` operations. |
  107. | tuning | core defaults | `segmentBytes` (512 KiB), `flushIntervalMs` (20), `pollIntervalMs`/`maxPollIntervalMs` (50/500), `eagerWindowMs` (2000), `holeTimeoutMs` (30000), `sessionTtlSeconds` (300), `concurrency` (8). |
  108. The optional **Front address/port** (the stream-level `address`/`port`) is a domain
  109. front the storage API is dialed through; TLS still names the API host. XDRIVE has
  110. no TLS/REALITY layer of its own — its traffic is the storage API's HTTPS.
  111. ## FinalMask — late-layer obfuscation
  112. **FinalMask** wraps traffic **after** the transport and security layers, so it can
  113. disguise transports that don't carry TLS (like mKCP) or add a second skin on top of
  114. TLS. Masks are configured per direction:
  115. - **TCP masks** — `fragment`, `sudoku`, `header-custom`, `xmc` (disguises the
  116. stream as Minecraft protocol traffic; requires a password, with optional
  117. hostname and player usernames).
  118. - **UDP masks** — `salamander`, `mkcp-legacy`, `header-custom`, `xdns`, `xicmp`,
  119. `noise`, `sudoku`, `realm`. (`mkcp-legacy` reproduces the old mKCP header
  120. obfuscation.)
  121. - **QUIC params** — congestion control (`reno`, `bbr`, `brutal`, `force-brutal`),
  122. Brutal up/down rates, `udpHop` (rotate the QUIC port across a range to dodge
  123. port blocking), and receive-window tuning.
  124. FinalMask replaces the per-transport `header`/`seed` obfuscation that older Xray
  125. builds exposed.
  126. ## sockopt — low-level socket options
  127. `sockopt` rides alongside any transport and tunes the underlying socket. The most
  128. useful fields:
  129. | Field | Default | Meaning |
  130. | --------------------- | ------- | ---------------------------------------------------------------- |
  131. | `tcpFastOpen` | `false` | Enable TCP Fast Open. |
  132. | `tcpcongestion` | `bbr` | Congestion control: `bbr`, `cubic`, or `reno`. |
  133. | `tproxy` | `off` | Transparent proxy mode: `off`, `redirect`, or `tproxy`. |
  134. | `domainStrategy` | `AsIs` | How addresses resolve (`UseIP`, `ForceIPv4`, …). |
  135. | `dialerProxy` | _(none)_| Chain this outbound's dialing through another outbound tag. |
  136. | `interface` | _(none)_| Bind to a specific network interface. |
  137. | `mark` | `0` | SO_MARK for policy routing (`0` = unset). |
  138. Numeric fields left at `0` are omitted on the wire so Xray keeps OS defaults.
  139. Advanced entries (`happyEyeballs`, `customSockopt[]`, keepalive timers) are
  140. available for special cases.
  141. ## Security
  142. The security layer is one of **`none`**, **`tls`**, or **`reality`**, with these
  143. eligibility rules:
  144. | Security | Eligible transports | Eligible protocols |
  145. | ----------- | -------------------------------------------- | --------------------------------------------------- |
  146. | **TLS** | `tcp`, `ws`, `grpc`, `httpupgrade`, `xhttp` | VLESS, VMess, Trojan, Shadowsocks (Hysteria2 is always TLS) |
  147. | **REALITY** | `tcp`, `grpc`, `xhttp` | VLESS, Trojan |
  148. mKCP and Hysteria don't take a separate TLS/REALITY layer — mKCP runs plaintext
  149. (obfuscate with FinalMask), and Hysteria is QUIC/TLS by design. REALITY disguises
  150. your server as a real TLS site and needs no certificate — see
  151. [REALITY](/docs/config/reality).
  152. ## XTLS-Vision flow
  153. The `xtls-rprx-vision` flow is fast and DPI-resistant. It's available for
  154. **VLESS** when either:
  155. - the transport is raw **TCP** with **TLS** or **REALITY** security (classic
  156. XTLS-Vision), or
  157. - the transport is **XHTTP** with VLESS encryption enabled (see below).
  158. Set the flow on the VLESS **client**, not the inbound. With classic Vision on
  159. TCP, the panel can also offer a **Vision seed** once a client uses the flow.
  160. ## VLESS encryption (ML-KEM)
  161. VLESS supports post-quantum **encryption** (ML-KEM / `mlkem768x25519`), stored in
  162. the inbound's `decryption` (server) and clients' `encryption` (for link
  163. generation). When enabled, it unlocks the Vision flow over XHTTP. Generate the
  164. keys from the panel's VLESS settings.
  165. ## Shadowsocks ciphers
  166. Shadowsocks inbounds support both classic ciphers and **Shadowsocks-2022**
  167. (method names starting with `2022-blake3-`). Most ciphers are multi-user;
  168. `2022-blake3-chacha20-poly1305` is single-user.
  169. <Callout type="info">
  170. Transports and security must match on both ends. The client's share link
  171. encodes them (`type=ws`, `security=reality`, `flow=xtls-rprx-vision`, …) —
  172. decode any link with the [share-link inspector](/docs/config/share-links).
  173. </Callout>