Skip to content

vless ​

VLESS (sing-vmess's vless, as in sing-box 1.14.4): inbound and outbound, the xtls-rprx-vision flow, UDP as plain VLESS packets or XUDP, the server side of mux.cool, Xray's VLESS encryption and sing-mux multiplexing.

Crateours-mod-vless, modules/protocols/vless
Binary featuresvless-inbound, vless-outbound (vless enables both); mux-cool → ours-mod-vless/mux-cool; vlessenc → ours-mod-vless/vlessenc; mux-* → the feature of the same name of ours-mod-vless + the mux module (mux-xray: the mux.cool client)
Crate featuresmux (the mux block), mux-smux, mux-yamux, mux-h2, mux-xray, mux-brutal, mux-padding — enable mux and gate only the crate's own code (the binary's mux-* switch on ours-mod-mux), vlessenc (ours-vlessenc), mux-cool, tls (the tests' ours-mod-tls implementation), unstable-ktls (the tests' ours-mod-tls)

requires ​

dial, tls, transport; with the mux feature also mux (the REQUIRES constant depends on the feature). TLS clients and servers come from the factory tls publishes (ours_tls_options::Tls), the transport over QUIC (HTTP/3) — the variant quic of the point transport (ours_transport_api::Quic, from Extensions; without it — «a transport over QUIC needs the transport feature quic»); the multiplexers — the handles of the mux block (ours_api::mux); the crate calls ours-transport-api.

provides ​

  • Provide::Blocks: inbound — tls, transport (+ mux); outbound — tls, transport (+ mux), dial.
  • Provide::Inbound { key: "vless", decode: inbound::decode }, Provide::Outbound { key: "vless" }, the schemas inbounds.vless, outbounds.vless.

Syntax: vless.

Dependencies ​

ours-tls-options, ours-tls13 (the TLS 1.3 stream type), ours-transport-api, ours-vlessenc (ML-KEM-768 + X25519), ours-net-sys, ours-bufpool, ours-api, ours-codec, ours-json, ring, arc-swap.

Design ​

  • src/protocol.rs — the VLESS request and response (vless/protocol.go), addresses in VMess form.
  • src/conn.rs — the connection as a stream: the request/response before the first data, Vision by flow. Conn distinguishes bare TCP, TLS 1.3 of the tls module (ours_tls13::KernelStream, taken out of Stream::Spliced once per connection; in the process or in the kernel) and the rest; VlessStream implements Splice and lets splice through in a direction as soon as the protocol is done with it.
  • src/vision.rs — XTLS Vision framing: the first packets in padding; when the inner TLS 1.3 starts sending application data, the side says "direct" and from then on writes the records as they are, and the outer TLS does not encrypt them again. The direct boundary is always between whole TLS records: a write that begins with application data and cuts the last record gives to padding only whole records, and the remainder goes with the next write directly (Xray in such a case continues padding until a read coincides with record boundaries).
  • src/packet.rs — UDP over a stream: length-prefixed packets to one destination or XUDP (mux.cool frames with an address per packet); packets that arrived while the stream could not write go out as a batch.
  • src/mux.rs — the mux.cool server (the Mux command): TCP substreams and UDP sessions, any number per connection; the mux-cool feature.
  • src/connector.rs — the outbound's Connector for transports that reach servers by themselves (XHTTP's download from another server, HTTP/3 through the quic variant): it dials with the outbound's dialer and builds TLS as the outbound does.
  • src/inbound.rs, src/outbound.rs, src/options.rs. An outbound's multiplexing is the MuxClient::wrap of the block's ours_api::mux::Client (the mux feature): sing-mux or Xray's mux.cool client (MuxClient::cool, the block mux: {xray: …}, the mux-xray feature); the outbound opens a connection to v1.mux.cool with the Mux command without an address, as Xray does.

The hot path and kTLS ​

With ktls: {tx, rx} (the unstable-ktls feature) VLESS hands a direction over to the kernel when Vision has finished padding in it without switching to direct (poll_kernel_rx/poll_kernel_tx in conn.rs); after that the relay drives the connection as an ordinary socket through splice.

Reload ​

inbound::decode moves users and decryption out of the block's cold form: reload applies them in place (hot_changed, encryption.reload), the inbound keeps its sockets, and new connections are checked against the new users. Turning encryption on or off (vlessenc_enabled) rebuilds the inbound.

Limitations ​

The inbound's detour is rejected; in XUDP — only one session and only UDP; packetaddr with a domain is not supported.

Tests ​

modules/protocols/vless/tests/vless.rs — TCP and REALITY, with and without Vision, kTLS; unit tests in packet.rs, vision.rs, conn.rs, protocol.rs.

GPL-3.0-or-later