sing-box icon indicating copy to clipboard operation
sing-box copied to clipboard

Protocol proposal: TSUNAMI (AnyTLS-derived, HTTPS-fronted multiplexed proxy)

Open RavenholmAlpha opened this issue 1 month ago • 1 comments

Protocol

TSUNAMI is an AnyTLS-derived multiplexed proxy protocol whose default transport is HTTPS fronting: the tunnel is carried in a signed HTTP/2 POST (or an HTTP/1.1 WebSocket upgrade), and unauthenticated requests are answered by a decoy website (built-in page, or a reverse proxy to a local or remote cover site).

  • Wire specification: https://github.com/RavenholmAlpha/sing-tsunami/blob/main/PROTOCOL.md
  • Reference implementation: https://github.com/RavenholmAlpha/tsunami (MIT, public)
  • Protocol library: https://github.com/RavenholmAlpha/sing-tsunami, tagged v0.1.1, GPL-3.0-or-later (MIT-derived portions are attributed in NOTICE). It is a separate module, like sing-anytls / sing-vmess, so it can be updated independently.

Why a new protocol instead of extending AnyTLS

  • The transport is fundamentally different: TSUNAMI sessions live inside authenticated HTTPS requests, which lets the server present a normal website to unauthenticated probes and hide the tunnel behind generic HTTPS. AnyTLS runs directly over TLS, so this cannot be expressed as an AnyTLS option.
  • Padding is a different system (v2): per-stream epochs, a separate control rule, directional client/server rules, exact-size pad-to segments, and a padding-v2 capability flag so old clients are never sent syntax they cannot parse. AnyTLS uses a session-oriented scheme with a different syntax.
  • Settings/version negotiation and the site-camouflage behavior differ; TSUNAMI peers are not wire-compatible with AnyTLS peers.
  • Development of the AnyTLS reference implementation has slowed, while TSUNAMI is already deployed and evolving independently.

Implementation status

I have a prepared branch against testing with the sing-box adapter (not opened as a PR yet):

  • option/tsunami.go, protocol/tsunami/{inbound,outbound}.go, constant/proxy.go, include/registry.go
  • docs pages for inbound/outbound in English and Chinese, plus index/nav entries
  • outbound: TLS/uTLS dialer, optional HTTP/2 or WebSocket fronting, session multiplexing, UoT client
  • inbound: TLS server, ALPN-based dispatch (h2 / http/1.1 / raw), per-stream routing, decoy site handler, v2-gated padding scheme push
  • local checks: builds with release/DEFAULT_BUILD_TAGS_OTHERS + release/LDFLAGS, golangci-lint clean on the new packages, go mod tidy clean
  • interop: verified against the native tsunami-server / tsunami-client in both directions (raw TLS, h2 fronting, WebSocket fronting, decoy page, 5 MiB payload integrity)

Branch: https://github.com/RavenholmAlpha/sing-box/tree/tsunami-testing

Example outbound:

{
  "type": "tsunami",
  "server": "example.com",
  "server_port": 443,
  "password": "secret",
  "tls": { "enabled": true, "server_name": "example.com", "utls": { "enabled": true, "fingerprint": "chrome" } },
  "fronting": { "enabled": true, "path": "/assets/update", "secret": "front-secret" }
}

Example inbound:

{
  "type": "tsunami",
  "listen_port": 443,
  "users": [ { "name": "alice", "password": "secret" } ],
  "tls": { "enabled": true, "certificate_path": "/path/fullchain.pem", "key_path": "/path/privkey.pem" },
  "fronting": { "enabled": true, "path": "/assets/update", "site": { "mode": "local", "upstream": "http://127.0.0.1:8080" } }
}

Questions

  • Is adding this protocol acceptable in principle?
  • Do you prefer the library to stay at github.com/RavenholmAlpha/sing-tsunami, or to be copied/transferred to the SagerNet org (as sing-anytls was)?
  • Any required tests or scope limits for the first PR? I can add adapter-level tests, or split fronting/raw mode into follow-ups.
  • License is currently GPL-3.0-or-later; happy to adjust before opening the PR.

Thanks!

RavenholmAlpha avatar Oct 31 '26 09:10 RavenholmAlpha

Status update: the implementation is ready as a single commit on a branch based on testing (e5d91fa79):

  • Branch: https://github.com/RavenholmAlpha/sing-box/tree/tsunami-testing
  • Commit: 2bc03f303 (16 files, +926 lines; depends on github.com/RavenholmAlpha/sing-tsunami v0.1.1)
  • Patch (for git am): - Creating gist 0001-feat-add-TSUNAMI-inbound-and-outbound-protocol.patch ✓ Created public gist 0001-feat-add-TSUNAMI-inbound-and-outbound-protocol.patch https://gist.github.com/RavenholmAlpha/a4117c0371b0ad166a15c5580b053ec0

Checks done: builds with release/DEFAULT_BUILD_TAGS_OTHERS + release/LDFLAGS; golangci-lint and staticcheck clean on the new packages; go mod tidy clean; interop verified against the native server/client (raw TLS, h2 fronting, WebSocket fronting, both directions, decoy page, 5 MiB payload integrity). The public wire specification is in the library repo: https://github.com/RavenholmAlpha/sing-tsunami/blob/main/PROTOCOL.md

I tried to open the PR directly, but this repository currently limits pull request creation to collaborators. If the direction is acceptable, could you let me know the preferred way to submit it: invite me as a collaborator for the PR, pull the branch directly, or take the patch from the gist? I am happy to adjust scope, tests, licensing (currently GPL-3.0-or-later) or move the library into the SagerNet org if that is preferred.

RavenholmAlpha avatar Oct 31 '26 09:10 RavenholmAlpha