tuic.mdx 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. ---
  2. title: TUIC
  3. description: Set up a TUIC inbound in 3x-ui — QUIC congestion control, 0-RTT handshakes, and multi-user authentication.
  4. icon: Zap
  5. ---
  6. **TUIC** (v5) is a proxy protocol built directly on top of the **QUIC** (HTTP/3) transport
  7. layer. It uses 0-RTT handshakes, connection multiplexing without head-of-line blocking,
  8. and custom congestion control algorithms to maintain stable connections over lossy or
  9. unstable networks.
  10. <Callout type="info">
  11. Like MTProto, TUIC runs as a **managed sidecar process** (`tuic-server` 1.0.0,
  12. written in Rust) rather than inside Xray-core. The panel manages the binary
  13. lifecycle, generates configurations, monitors process health, and tracks
  14. inbound traffic and client online presence.
  15. </Callout>
  16. ## Key settings
  17. ### Server & QUIC parameters
  18. | Field | Description |
  19. | --- | --- |
  20. | **Port** | UDP port for incoming client QUIC connections. |
  21. | **Certificate & Key** | Full TLS certificate chain and private key. QUIC mandates TLS encryption; self-signed certificates or valid Let's Encrypt / ACME certs are supported. |
  22. | **SNI** | Server Name Indication matching your TLS certificate domain name. |
  23. | **Congestion Control** | QUIC congestion control algorithm: `bbr` (recommended for high throughput), `cubic`, or `new_reno`. |
  24. | **ALPN** | Application-Layer Protocol Negotiation tokens (default: `h3`). |
  25. | **UDP Relay Mode** | Packet encapsulation mode: `native` (QUIC datagrams, recommended) or `quic`. |
  26. | **Zero-RTT Handshake** | Enables 0-RTT connection resumption to eliminate initial handshake round-trips for returning clients. |
  27. | **Authentication Timeout** | Maximum time (seconds) allowed for client authentication before disconnecting (default: `3s`). |
  28. | **Max Idle Time** | Inactivity timeout (seconds) before closing idle QUIC connections (default: `15s`). |
  29. | **Max Packet Size** | Maximum UDP relay packet size in bytes (default: `1500`). |
  30. ## Set it up in the panel
  31. <Steps>
  32. <Step>
  33. ### Add an inbound
  34. Create a new inbound and choose protocol **TUIC**. Assign a UDP port (e.g. `8443` or `443`).
  35. </Step>
  36. <Step>
  37. ### Select TLS certificate
  38. Provide the certificate file path and private key file path (or paste their contents). Make sure the configured SNI matches the certificate domain.
  39. </Step>
  40. <Step>
  41. ### Configure QUIC options
  42. The panel fills recommended defaults (`bbr`, `h3`, `native` UDP relay). Adjust timeouts or enable **Zero-RTT Handshake** if desired.
  43. </Step>
  44. <Step>
  45. ### Add clients
  46. Each client requires an **Email** identifier, a **UUID** (token), and a **Password**. The panel automatically generates secure random credentials when creating clients.
  47. </Step>
  48. <Step>
  49. ### Export and connect
  50. Copy the client's share link (`tuic://…`) or open the **QR modal** to download a ready-to-use **Clash / Mihomo YAML** configuration.
  51. </Step>
  52. </Steps>
  53. ## Client support & configuration
  54. TUIC v5 is supported by modern proxy clients including **Clash Verge Rev**, **Mihomo**, **Flclash**, **sing-box**, and **v2rayN**.
  55. ### Clash / Mihomo configuration
  56. The panel provides automatic YAML export for Clash/Mihomo in the client QR modal:
  57. ```yaml title="clash-tuic.yaml"
  58. proxies:
  59. - name: "3x-ui-tuic"
  60. type: tuic
  61. server: vpn.example.com
  62. port: 8443
  63. uuid: 8a47f2b1-5e8c-4a3d-9b1e-7f6c5d4a3b2a
  64. password: secure-random-password
  65. alpn:
  66. - h3
  67. sni: vpn.example.com
  68. congestion-controller: bbr
  69. udp-relay-mode: native
  70. reduce-rtt: false
  71. skip-cert-verify: false
  72. ```
  73. ### Share link format
  74. TUIC share links use standard URI formatting:
  75. ```text
  76. tuic://<uuid>:<password>@<host>:<port>?congestion_control=bbr&alpn=h3&sni=vpn.example.com&udp_relay_mode=native&allow_insecure=0#Remark
  77. ```
  78. ## Architecture & Notes
  79. <Callout type="info">
  80. - **Standalone sidecar**: The panel ships pre-compiled `tuic-server` musl binaries on Linux (amd64, arm64, armv7, 386) and executable for Windows.
  81. - **Traffic accounting & limits**: The panel owns the inbound's public UDP port with a small relay and runs `tuic-server` behind it on a loopback port, so the inbound's upload and download bytes are counted exactly on every OS and enforced at the **inbound level** (`inbounds.total`); `tuic-server` therefore logs `127.0.0.1` as every client's address. Because upstream `tuic-server` does not provide an internal per-user metrics API, individual client traffic limits (`totalGB`) are not supported for TUIC clients. Client access can be controlled via expiration timestamps (`expiryTime`) and manual enable/disable toggles.
  82. - **Online status & "start after first use"**: The panel detects a client's activity from the sidecar's Info log lines (they carry the client UUID), so those features need the inbound's log level at `info` or `debug`; `warn` and `error` silence them.
  83. - **Client updates & connections**: Because upstream `tuic-server` lacks dynamic user reload APIs, client modifications (adding, updating, or disabling clients) restart the sidecar process and momentarily reset active connections.
  84. - **Deployment**: Because TUIC operates via a host sidecar process, TUIC inbounds are panel-local (main instance).
  85. </Callout>