English
Protocols
The reference: include/registry.go of sing-box v1.14.4 and Xray's proxy/. Ours: the modules modules/protocols/*, the build list — app/ours/src/modules.rs. A type that is in no module is the error unknown inbound type `x` .
Missing types
| What | Reference | Verdict |
|---|---|---|
The vmess inbound and outbound | sing-box, Xray | missing: the most frequent protocol in subscriptions that we skip |
The naive inbound and outbound | sing-box | rarely needed: the outbound needs a Chromium stack in the reference |
The snell inbound and outbound | sing-box 1.14 | rarely needed: Surge's closed protocol |
The ssh outbound | sing-box | rarely needed |
The tor outbound | sing-box | rarely needed: pulls in a tor client |
The bridge outbound, the cloudflared inbound | sing-box 1.14 | rarely needed |
The tailscale, openconnect, openvpn endpoints | sing-box 1.14 (the endpoints section) | rarely needed; wireguard exists, see below |
Xray's wireguard inbound and outbound | Xray | — (there is the wireguard endpoint in sing-box form) |
The masque-client, masque-server endpoints (CONNECT-IP, RFC 9484) | sing-box 1.15-alpha.7; the masque outbound and transport in Xray v26.9.30 | rarely needed: needs an L3 stack, as for tun |
The tailcat inbound and outbound (WireGuard over DERP without the Tailscale control plane) | sing-box 1.15-alpha.5 | rarely needed |
The (old) wireguard outbound | a stub in sing-box, removed | junk: replaced by the endpoint |
| ShadowsocksR | a stub in sing-box, removed in 1.6 | junk |
The dns outbound | removed in sing-box 1.12 | junk: we have to: hijack-dns |
selector, urltest, block as an outbound | sing-box | — (design: groups, to: block, see design.md) |
Xray dokodemo-door/tunnel | Xray | — (the direct inbound does it) |
Xray freedom, blackhole, loopback | Xray | rarely needed: loopback; freedom and blackhole are direct and to: block |
Xray reverse: bridge/portal and reverse on a VLESS user and outbound | Xray (infra/conf/vless.go) | rarely needed |
Shared inbound fields
| What | Status | Where | Verdict |
|---|---|---|---|
detour: an inbound that accepts someone else's connection | partial: shadowsocks, socks, trojan, vless; the reference also has http, mixed (TCPInjectableInbound), ours — this inbound cannot be a detour | Inbound::inject in modules/protocols/*/src/inbound.rs, crates/proto/src/socks/inbound.rs | missing |
detour of a UDP flow | different: the reference has no UDPInjectableInbound and drops the flow (inbound detour is not UDP injectable); ours hands it to shadowsocks and direct, the others say this inbound cannot be a UDP detour | Inbound::inject_packet; tests/e2e/scenarios/detour (ours only) | — |
netns on tproxy | different: every UDP reply socket (one per flow destination address) is created by a separate thread that entered the namespace; auto_nft with netns is an error: the rules are installed in the process's own namespace | libs/net-sys/src/tproxy.rs, crates/relay/src/tproxy.rs | — |
Answering a foreign client on inbounds with TLS
The trojan, vless and anytls inbounds without fallbacks and REALITY answer a connection that passed TLS but turned out not to be their client the way Caddy 2 without a site for this name does (Go's crypto/tls and net/http — the closest to our stack). sing-box in N.CloseOnHandshakeFailure silently sends close_notify and RST — no web server closes a connection like that, and a probe recognizes the proxy by it. An intentional difference: the code is crates/proto/src/decoy.rs, the check is tests/e2e/bin/tls_close.py in the trojan, anytls, tls-fragment scenarios for ours only (skipped on sing-box).
| What | Status | Where | Verdict |
|---|---|---|---|
| An HTTP/1 request | present: an empty 200, Server: Caddy, Date, Content-Length: 0, keep-alive; checked against Caddy 2.11.9 | decoy.rs (http) | — |
| Not HTTP | present: Go net/http's 400 Bad Request: at the end of the first line, at the end of the connection or when the time for a request runs out; then close_notify and FIN, on TLS 1.3 and 1.2 | decoy.rs (read_head) | — |
Alt-Svc: h3=":443" | no: Caddy sends it by default, but there is no HTTP/3 on this port; this is how Caddy with protocols h1 h2 answers | decoy.rs | — |
| Waiting for the next request | different: no longer than listener.first_request (60 s) from accepting the connection; Caddy keeps an idle connection for 5 min | decoy.rs (within) | rarely needed |
| A head longer than 64 KiB | different: 431 at 64 KiB, Go — at 1 MiB | decoy.rs (TOO_LARGE) | rarely needed |
HTTP/2 (ALPN h2) | different: a 200 response with server, content-length, date over our own h2; Go sends its SETTINGS right after the handshake, we — only when the protocol has already refused (earlier is impossible: it would break the stream for a real client); SETTINGS has no HEADER_TABLE_SIZE, on a broken preface — GOAWAY, while Go closes silently; HPACK — our own encoding | decoy.rs (h2), libs/h2 | rarely needed |
| The decision threshold | present: Trojan and AnyTLS — the first read (as in sing-box), VLESS — the first byte of the version or a UUID no user has; the data read before the decision goes to the answer | modules/protocols/{trojan,vless,anytls}/src/inbound.rs | — |
| A wrong password from our own client | different: a Trojan client with someone else's password gets 400 as the destination's data, as behind fallbacks to a web server; the hint "closed before any reply" remains only for UDP | modules/system/dispatch/src/lib.rs (server_hint) | — |
| A transport stream in which the protocol refused | present: closed the regular way for the transport: WebSocket close, END_STREAM | Conn::refuse | — |
Without TLS (vless, anytls over bare TCP) | different: the same HTTP answer and FIN; sing-box sends RST | decoy.rs | — |
A Shadowsocks request that does not open
sing-shadowsocks reads the 2022 request header with a single Read: a valid request split across TCP segments is refused, and any garbage is reset at once. Ours reads the header whole, however it is segmented, and so has to wait for the rest of a short one; a request that does not open (garbage, a replayed salt, a header of an unknown user) is then not reset either, but read and dropped until the peer closes or listener.first_request.timeout passes, and closed with FIN as a silent client is. Otherwise the number of bytes at which the server reacts would identify it to a probe. The same holds for the legacy AEAD methods. The code is modules/protocols/shadowsocks/src/inbound.rs (serve), the check is garbage_of_any_length_is_closed_at_the_deadline in modules/protocols/shadowsocks/tests/loopback.rs.
By protocol
| Protocol | What | Status | Where | Verdict |
|---|---|---|---|---|
http inbound | set_system_proxy | no | crates/proto/src/http/inbound.rs | platform: not needed on a router |
http, mixed inbound | domain_resolver | no | the same place | missing |
mixed inbound | SOCKS over TLS | no: SOCKS over TLS on a mixed inbound is not supported (works in the reference) | modules/protocols/mixed/src/lib.rs | missing: the SOCKS side serves only bare TCP |
socks inbound | domain_resolver | no | crates/proto/src/socks/inbound.rs | missing: together with http |
http inbound and outbound | HTTP/2, HTTP/3, UDP through CONNECT-UDP | no: only HTTP/1.1 CONNECT | crates/proto/src/http/inbound.rs, modules/protocols/http/src/outbound.rs | missing (sing-box 1.15): there the outbound uses HTTP/2 by default and falls back to 1.1 |
socks outbound | UDP through SOCKS4 | no (the protocol cannot do it) | modules/protocols/socks/src/outbound.rs | — |
shadowsocks inbound | managed (SSM API) | no: managed: not implemented yet | modules/protocols/shadowsocks/src/inbound.rs | rarely needed: needs the ssm-api service |
shadowsocks inbound | destinations (relay) | no: destinations: relay is not implemented yet | the same place | rarely needed |
shadowsocks inbound and outbound | method: aes-192-gcm | no: unsupported method: aes-192-gcm; ring has no AES-192, and keeping it would need a second, slower AES-GCM for a method nobody picks over aes-128-gcm/aes-256-gcm | modules/protocols/shadowsocks/src/method.rs | — |
trojan, vless inbound | fallbacks (Xray), fallback/fallback_for_alpn (sing-box, trojan) | different: one set of Xray rules (name, alpn, path, xver) for both inbounds, in YAML — fallbacks; the connection goes through routing, as in sing-box (Xray dials dest itself), so dest is only host:port or a port, there are no unix sockets and no serve-ws-none; an ALPN without its own rule goes to the rule without alpn (sing-box closes the connection for trojan) | crates/proto/src/fallback.rs, modules/protocols/{trojan,vless}/src/inbound.rs | — |
trojan, vless inbound | fallback by ALPN under TLS 1.2 | no: the negotiated ALPN is visible only with TLS 1.3, under 1.2 the rules without alpn apply | modules/system/tls/src/lib.rs (TcpTls::alpn_protocol) | rarely needed |
vless inbound/outbound | Vision over a transport without VLESS Encryption | no (as in Xray) | modules/protocols/vless/src/inbound.rs, outbound.rs | — |
vless | packetaddr with a domain destination | no (as in the reference) | modules/protocols/vless/src/packet.rs, outbound.rs | — |
vless outbound | encryption.cipher other than aes-256-gcm/chacha20-poly1305 | no | modules/protocols/vless/src/outbound.rs | — |
anytls outbound | dial.tcp.fast_open | no (as in the reference) | modules/protocols/anytls/src/outbound.rs | — |
hysteria2 inbound and outbound | realm (and the realm service) | no | modules/protocols/hysteria2/src/inbound.rs, outbound.rs | rarely needed |
hysteria2 outbound | a Chrome-like handshake (ChromeParrot): datagrams after the handshake | different: our first 1-RTT packet is quinn's PMTUD probe (~1350 bytes), the reference's is a short ACK; Initial and Handshake match | crates/quic/src/chrome.rs, the quinn fork | rarely needed |
hysteria2 inbound and outbound | bbr_profile: accounting for losses during ramp-up, ACK aggregation, protection against overestimation | no: quinn's BBR has none of these knobs; the gains and the ramp-up length are as in the reference | libs/quinn-ext/src/congestion.rs | — |
hysteria2 inbound | masquerade: {type: file}: several Range ranges, If-None-Match/If-Match/If-Range, types from /etc/mime.types | no: several ranges — the whole file, the type — Go's built-in table and signatures | modules/protocols/hysteria2/src/masquerade.rs | — |
hysteria2 inbound | the server's HTTP/3: SETTINGS, date and content-length in masquerade answers — as in quic-go | different: the QUIC transport parameters and the QPACK encoding are quinn's and our own, not quic-go's: a probe reading them will tell the server apart | libs/quinn-ext/src/h3.rs, modules/protocols/hysteria2/src/masquerade.rs | — |
hysteria2 inbound | masquerade: {type: proxy} over HTTP/2 to an https site | no: always HTTP/1.1 | modules/protocols/hysteria2/src/masquerade.rs | — |
shadowtls inbound | v1/v2 with TLS 1.3 on the handshake server | no (as in the reference) | modules/protocols/shadowtls/src/inbound.rs | — |
direct outbound | override_address, override_port | no (removed in the reference too) | crates/config/src/options/direct.rs | junk: there is do: options |
direct | detour in a "direct context" (DNS, NTP) | no (as in the reference) | modules/protocols/direct/src/lib.rs | — |
tun inbound | stack: gvisor, mixed | different: the stack is always the system one; ICMP echo is answered in place, not routed by the rules | modules/protocols/tun/src/stack.rs | — |
tun inbound | batched reading (BatchRead), the vnet header and offload (TSO, TCP/UDP GRO) | no: a packet per read/write, the device without IFF_VNET_HDR, the TCP table (TcpNat) under one mutex for all shards; see limitations | modules/protocols/tun/src/stack.rs (run), nat.rs, lib.rs (FLAGS) | missing: ours_wireguard::offload can already do the vnet header |
tun inbound | route_address_set, route_exclude_address_set | no: not implemented yet — needs extracting ip_cidr from router's rule-sets and updating by them | modules/protocols/tun/src/settings.rs | missing |
tun inbound | netns | no: not implemented yet | the same place | missing: together with netns on listeners |
tun inbound | pre-matching of auto_redirect through nfqueue (auto_redirect_nfqueue, auto_redirect_reset_mark) | no: the fields are accepted, a refusal by a rule comes after the handshake | modules/protocols/tun/src/redirect.rs | rarely needed |
tun inbound | dns_mode: native (the interface's DNS in systemd-resolved) | no: accepted with a warning; hijack capture exists | modules/protocols/tun/src/lib.rs | rarely needed: a router has no resolved |
tun inbound | Docker rules with auto_redirect | no; OpenWrt fw4 rules exist | modules/protocols/tun/src/redirect.rs | rarely needed |
tun inbound | Android fields (include_package, exclude_package, include_android_user), platform | no: the error is for Android only (the reference does not apply them on Linux) | modules/protocols/tun/src/config.rs | — |
tun inbound | udp_timeout | different: listener.udp.timeout, as for the other inbounds | the same place | — |
wireguard endpoint | system: false (the gVisor stack) | different: always TUN and the kernel stack, like system: true; system is read and has no effect | modules/protocols/wireguard/src/lib.rs | — |
wireguard endpoint | mode: kernel|userspace|auto | beyond the reference: kernel — the wireguard/amneziawg module through generic netlink, capturing the peers' connections through nftables tproxy; auto — kernel if the module is present and the configuration is within its powers | modules/protocols/wireguard/src/kernel.rs | — |
wireguard endpoint | awg, ciphers | beyond the reference: awg — AmneziaWG 3.1 (its subsets — 1.x and 2.0) in userspace and through the amneziawg module; a peer's persistent_keepalive_interval accepts an N-M range; ciphers — the transport ciphers (ChaCha20-Poly1305, AES-GCM-128/256), negotiated as in the AmneziaWG AES-GCM extension (janeblower/amneziawg-go), userspace only | modules/protocols/wireguard/src/options.rs, src/awg.rs, libs/wireguard/src/ciphers.rs | — |
wireguard endpoint | config_file | beyond the reference: a wg/awg file ([Interface], [Peer], the AWG keys and Ciphers) is the source of everything it expresses; matching endpoint fields have no effect, with a warning; PostUp and the like are skipped with a warning; a peer has a name (# Name =) | modules/protocols/wireguard/src/conf.rs | — |
wireguard endpoint | listen: auto|all|<interface>|<address> | beyond the reference; auto by default — only the WAN addresses (default routes, both families, follows changes), in sing-box — all addresses; without a default route — all addresses with a warning. The restriction is the nftables table inet ours-wg-listen-<interface>, the socket listens on all addresses | modules/protocols/wireguard/src/listen.rs | — |
wireguard endpoint | public_endpoint, a peer's name | beyond the reference: the address handed out to clients (auto — the WAN) and the peer's name for humans; they do not affect operation | modules/protocols/wireguard/src/options.rs | — |
wireguard endpoint | routes to the peers' allowed_ips | beyond the reference: added to main with the metric 0x7fff0000 (below any system ones) — replies through the tunnel pass a loose rp_filter | modules/protocols/wireguard/src/tun.rs | — |
wireguard endpoint | accepting the peers' connections | different: in userspace — rewriting to the endpoint's listener in the process itself (like sing-tun's system stack), ICMP to foreign addresses is dropped; in kernel — nftables tproxy, requests to the host's addresses go straight to the host | modules/protocols/wireguard/src/nat.rs, kernel.rs | — |
wireguard endpoint | workers, on_demand | no: read and have no effect | modules/protocols/wireguard/src/lib.rs | — |
wireguard endpoint | detour (the dial block) | different: userspace only (in auto — with a message); the endpoint's socket listens on loopback, every peer with an address has its own loopback socket that forwards datagrams through the outbound's packet connection; a peer without an address is reachable only if it came through the outbound itself | modules/protocols/wireguard/src/detour.rs | — |
QUIC
Hysteria, TUIC, and Hysteria2 run on quinn in ours and on quic-go in sing-box. Standard quinn connections use rustls. ChromeParrot is available for the Hysteria2 client and can be disabled with disable_chrome_parrot.
Protocol blocks
Which blocks a protocol accepts is declared by its module (Provide::Blocks in modules/protocols/*/src/lib.rs). Compared with the reference:
| Block | Ours | In sing-box | Verdict |
|---|---|---|---|
mux on inbound and outbound | vless, trojan, shadowsocks | plus vmess | missing: together with vmess |
transport | vless, trojan | plus vmess | missing: together with vmess |
tls on shadowsocks/socks | no | no | — |
Beyond the reference
The mtproto inbound: a Telegram MTProto proxy with an ee secret, see mtproto.