Skip to content

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 ​

WhatReferenceVerdict
The vmess inbound and outboundsing-box, Xraymissing: the most frequent protocol in subscriptions that we skip
The naive inbound and outboundsing-boxrarely needed: the outbound needs a Chromium stack in the reference
The snell inbound and outboundsing-box 1.14rarely needed: Surge's closed protocol
The ssh outboundsing-boxrarely needed
The tor outboundsing-boxrarely needed: pulls in a tor client
The bridge outbound, the cloudflared inboundsing-box 1.14rarely needed
The tailscale, openconnect, openvpn endpointssing-box 1.14 (the endpoints section)rarely needed; wireguard exists, see below
Xray's wireguard inbound and outboundXray— (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.30rarely 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.5rarely needed
The (old) wireguard outbounda stub in sing-box, removedjunk: replaced by the endpoint
ShadowsocksRa stub in sing-box, removed in 1.6junk
The dns outboundremoved in sing-box 1.12junk: we have to: hijack-dns
selector, urltest, block as an outboundsing-box— (design: groups, to: block, see design.md)
Xray dokodemo-door/tunnelXray— (the direct inbound does it)
Xray freedom, blackhole, loopbackXrayrarely needed: loopback; freedom and blackhole are direct and to: block
Xray reverse: bridge/portal and reverse on a VLESS user and outboundXray (infra/conf/vless.go)rarely needed

Shared inbound fields ​

WhatStatusWhereVerdict
detour: an inbound that accepts someone else's connectionpartial: shadowsocks, socks, trojan, vless; the reference also has http, mixed (TCPInjectableInbound), ours — this inbound cannot be a detourInbound::inject in modules/protocols/*/src/inbound.rs, crates/proto/src/socks/inbound.rsmissing
detour of a UDP flowdifferent: 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 detourInbound::inject_packet; tests/e2e/scenarios/detour (ours only)—
netns on tproxydifferent: 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 namespacelibs/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).

WhatStatusWhereVerdict
An HTTP/1 requestpresent: an empty 200, Server: Caddy, Date, Content-Length: 0, keep-alive; checked against Caddy 2.11.9decoy.rs (http)—
Not HTTPpresent: 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.2decoy.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 answersdecoy.rs—
Waiting for the next requestdifferent: no longer than listener.first_request (60 s) from accepting the connection; Caddy keeps an idle connection for 5 mindecoy.rs (within)rarely needed
A head longer than 64 KiBdifferent: 431 at 64 KiB, Go — at 1 MiBdecoy.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 encodingdecoy.rs (h2), libs/h2rarely needed
The decision thresholdpresent: 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 answermodules/protocols/{trojan,vless,anytls}/src/inbound.rs—
A wrong password from our own clientdifferent: 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 UDPmodules/system/dispatch/src/lib.rs (server_hint)—
A transport stream in which the protocol refusedpresent: closed the regular way for the transport: WebSocket close, END_STREAMConn::refuse—
Without TLS (vless, anytls over bare TCP)different: the same HTTP answer and FIN; sing-box sends RSTdecoy.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 ​

ProtocolWhatStatusWhereVerdict
http inboundset_system_proxynocrates/proto/src/http/inbound.rsplatform: not needed on a router
http, mixed inbounddomain_resolvernothe same placemissing
mixed inboundSOCKS over TLSno: SOCKS over TLS on a mixed inbound is not supported (works in the reference)modules/protocols/mixed/src/lib.rsmissing: the SOCKS side serves only bare TCP
socks inbounddomain_resolvernocrates/proto/src/socks/inbound.rsmissing: together with http
http inbound and outboundHTTP/2, HTTP/3, UDP through CONNECT-UDPno: only HTTP/1.1 CONNECTcrates/proto/src/http/inbound.rs, modules/protocols/http/src/outbound.rsmissing (sing-box 1.15): there the outbound uses HTTP/2 by default and falls back to 1.1
socks outboundUDP through SOCKS4no (the protocol cannot do it)modules/protocols/socks/src/outbound.rs—
shadowsocks inboundmanaged (SSM API)no: managed: not implemented yetmodules/protocols/shadowsocks/src/inbound.rsrarely needed: needs the ssm-api service
shadowsocks inbounddestinations (relay)no: destinations: relay is not implemented yetthe same placerarely needed
shadowsocks inbound and outboundmethod: aes-192-gcmno: 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-gcmmodules/protocols/shadowsocks/src/method.rs—
trojan, vless inboundfallbacks (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 inboundfallback by ALPN under TLS 1.2no: the negotiated ALPN is visible only with TLS 1.3, under 1.2 the rules without alpn applymodules/system/tls/src/lib.rs (TcpTls::alpn_protocol)rarely needed
vless inbound/outboundVision over a transport without VLESS Encryptionno (as in Xray)modules/protocols/vless/src/inbound.rs, outbound.rs—
vlesspacketaddr with a domain destinationno (as in the reference)modules/protocols/vless/src/packet.rs, outbound.rs—
vless outboundencryption.cipher other than aes-256-gcm/chacha20-poly1305nomodules/protocols/vless/src/outbound.rs—
anytls outbounddial.tcp.fast_openno (as in the reference)modules/protocols/anytls/src/outbound.rs—
hysteria2 inbound and outboundrealm (and the realm service)nomodules/protocols/hysteria2/src/inbound.rs, outbound.rsrarely needed
hysteria2 outbounda Chrome-like handshake (ChromeParrot): datagrams after the handshakedifferent: our first 1-RTT packet is quinn's PMTUD probe (~1350 bytes), the reference's is a short ACK; Initial and Handshake matchcrates/quic/src/chrome.rs, the quinn forkrarely needed
hysteria2 inbound and outboundbbr_profile: accounting for losses during ramp-up, ACK aggregation, protection against overestimationno: quinn's BBR has none of these knobs; the gains and the ramp-up length are as in the referencelibs/quinn-ext/src/congestion.rs—
hysteria2 inboundmasquerade: {type: file}: several Range ranges, If-None-Match/If-Match/If-Range, types from /etc/mime.typesno: several ranges — the whole file, the type — Go's built-in table and signaturesmodules/protocols/hysteria2/src/masquerade.rs—
hysteria2 inboundthe server's HTTP/3: SETTINGS, date and content-length in masquerade answers — as in quic-godifferent: 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 apartlibs/quinn-ext/src/h3.rs, modules/protocols/hysteria2/src/masquerade.rs—
hysteria2 inboundmasquerade: {type: proxy} over HTTP/2 to an https siteno: always HTTP/1.1modules/protocols/hysteria2/src/masquerade.rs—
shadowtls inboundv1/v2 with TLS 1.3 on the handshake serverno (as in the reference)modules/protocols/shadowtls/src/inbound.rs—
direct outboundoverride_address, override_portno (removed in the reference too)crates/config/src/options/direct.rsjunk: there is do: options
directdetour in a "direct context" (DNS, NTP)no (as in the reference)modules/protocols/direct/src/lib.rs—
tun inboundstack: gvisor, mixeddifferent: the stack is always the system one; ICMP echo is answered in place, not routed by the rulesmodules/protocols/tun/src/stack.rs—
tun inboundbatched 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 limitationsmodules/protocols/tun/src/stack.rs (run), nat.rs, lib.rs (FLAGS)missing: ours_wireguard::offload can already do the vnet header
tun inboundroute_address_set, route_exclude_address_setno: not implemented yet — needs extracting ip_cidr from router's rule-sets and updating by themmodules/protocols/tun/src/settings.rsmissing
tun inboundnetnsno: not implemented yetthe same placemissing: together with netns on listeners
tun inboundpre-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 handshakemodules/protocols/tun/src/redirect.rsrarely needed
tun inbounddns_mode: native (the interface's DNS in systemd-resolved)no: accepted with a warning; hijack capture existsmodules/protocols/tun/src/lib.rsrarely needed: a router has no resolved
tun inboundDocker rules with auto_redirectno; OpenWrt fw4 rules existmodules/protocols/tun/src/redirect.rsrarely needed
tun inboundAndroid fields (include_package, exclude_package, include_android_user), platformno: the error is for Android only (the reference does not apply them on Linux)modules/protocols/tun/src/config.rs—
tun inboundudp_timeoutdifferent: listener.udp.timeout, as for the other inboundsthe same place—
wireguard endpointsystem: false (the gVisor stack)different: always TUN and the kernel stack, like system: true; system is read and has no effectmodules/protocols/wireguard/src/lib.rs—
wireguard endpointmode: kernel|userspace|autobeyond 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 powersmodules/protocols/wireguard/src/kernel.rs—
wireguard endpointawg, ciphersbeyond 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 onlymodules/protocols/wireguard/src/options.rs, src/awg.rs, libs/wireguard/src/ciphers.rs—
wireguard endpointconfig_filebeyond 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 endpointlisten: 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 addressesmodules/protocols/wireguard/src/listen.rs—
wireguard endpointpublic_endpoint, a peer's namebeyond the reference: the address handed out to clients (auto — the WAN) and the peer's name for humans; they do not affect operationmodules/protocols/wireguard/src/options.rs—
wireguard endpointroutes to the peers' allowed_ipsbeyond the reference: added to main with the metric 0x7fff0000 (below any system ones) — replies through the tunnel pass a loose rp_filtermodules/protocols/wireguard/src/tun.rs—
wireguard endpointaccepting the peers' connectionsdifferent: 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 hostmodules/protocols/wireguard/src/nat.rs, kernel.rs—
wireguard endpointworkers, on_demandno: read and have no effectmodules/protocols/wireguard/src/lib.rs—
wireguard endpointdetour (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 itselfmodules/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:

BlockOursIn sing-boxVerdict
mux on inbound and outboundvless, trojan, shadowsocksplus vmessmissing: together with vmess
transportvless, trojanplus vmessmissing: together with vmess
tls on shadowsocks/socksnono—

Beyond the reference ​

The mtproto inbound: a Telegram MTProto proxy with an ee secret, see mtproto.

GPL-3.0-or-later