Skip to content

shadowtls ​

ShadowTLS (sing-box's protocol/shadowtls on top of sing-shadowtls): a TLS handshake with a real server, which the client and this server only observe; then the connection itself — bare (v1), as application data records (v2) or as records with a running HMAC (v3).

Crateours-mod-shadowtls, modules/protocols/shadowtls
Binary featuresshadowtls-inbound, shadowtls-outbound (shadowtls enables both) (enables tls)
Crate featuresnone

requires ​

dial, tls — connections to the server; the TLS client (v3 — client_sealed, which signs the session ID). The handshake runs through ours_api::tls::connect_inner, which hands back the stream under TLS.

provides ​

  • Provide::Blocks { section: "outbounds", key: "shadowtls", blocks: ["tls", "dial"] }.
  • Provide::Inbound { key: "shadowtls", decode: inbound::decode } — its own decoder: the handshake server and the detour to an inbound; Provide::Outbound { key: "shadowtls" }; schemas.

Syntax: shadowtls.

Dependencies ​

ours-tls-options, ours-net-sys, ours-api, ours-codec, ours-json, hmac, sha1, sha2, rand_core + getrandom.

Design ​

  • src/outbound.rs — a connection to the ShadowTLS server regardless of the requested destination: another outbound uses it as its detour. No UDP.
  • src/inbound.rs — the client's handshake is proxied to the real TLS server until the client proves itself; then the connection goes to the inbound named in its detour. The handshake server is chosen by SNI (handshake_for_server_name, wildcard_sni: off/authed/all).
  • src/v2.rs — v2: proof by a hash of what the server sent in the handshake.
  • src/v3.rs — v3: the server signs and masks the real server's records; after the handshake every record is signed with an HMAC over everything sent.
  • src/frame.rs — whole TLS records by their 5-byte header.

Limitations ​

The inbound's netns is rejected.

Tests ​

No integration tests; unit tests in src/frame.rs and src/inbound.rs; fuzzing in fuzz/.

GPL-3.0-or-later