Skip to content

anytls ​

AnyTLS (sing-box's protocol/anytls on top of sing-anytls 0.0.11): TLS, the SHA-256 of the password and padding, then a session of framed streams. Every stream begins with the destination; UDP is UDP-over-TCP v2 inside a stream.

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

requires ​

dial, tls — connections to the server; TLS clients and servers.

provides ​

  • Provide::Blocks: inbound — tls; outbound — tls, dial.
  • Provide::Inbound/Provide::Outbound { key: "anytls" }, the schemas inbounds.anytls, outbounds.anytls.

Syntax: anytls.

Dependencies ​

ours-tls-options, ours-uot, ours-net-sys, ours-api, ours-codec, sha2, md-5, rand_core + getrandom, bytes, arc-swap.

Design ​

  • src/session.rs — the session (sing-anytls/session): "command, stream id, length" frames (ours_wire::anytls); the client's first packets are cut and padded according to the scheme.
  • src/padding.rs — the padding scheme: the TLS record sizes for the session's first packets.
  • src/outbound.rs — the client keeps sessions whose stream has ended and gives the next connection the newest one: one session carries one stream at a time (Pool).
  • src/inbound.rs — the server accepts any number of streams in a session.
  • src/options.rs.

Reload ​

Users reload in place, as in http.

Limitations ​

tcp.fast_open in an outbound's dial, and an inbound's detour and netns, are rejected.

Tests ​

modules/protocols/anytls/tests/anytls.rs — TCP and UDP through TLS, session reuse, a wrong password; unit tests in padding.rs.

GPL-3.0-or-later