Repository navigation
Conversation
|
dup #6103 |
|
Hi @Fangliding, thanks for taking a look. I'd like to respectfully clarify why I believe this is not a duplicate of #6103:
The two techniques are complementary rather than duplicating - which is exactly why byedpi ships them as separate modes ( Also worth noting: #6103 has been a draft since May, currently has merge conflicts, and hasn't been reviewed yet, while this PR is ready for review and includes real-wire verification (tcpdump: ttl 1/64 alternation, SACK holes on server ACKs, URG flag at the split boundary). Could you please reconsider - happy to answer any technical questions. If the concern is overlapping scope, I can split this into a feature issue for discussion instead. |
|
To be honest, I'm tired of seeing these such tricks, which are nothing more than working for a few months and then the firewall inventing a new reassembler. Perhaps it will consume more taxpayers' money to compensate for the decreased efficiency |
|
Thanks for the honest feedback - I understand the core team's position on arms-race tricks. One point for the record: this runs opt-in via a config field, adds zero maintenance surface when unused, and users currently run a separate byedpi process alongside Xray precisely for these modes - in-core would apply the trick only to the ClientHello and drop the second tool. That said, the call is yours; if the direction for the core is protocol-level solutions only, I respect that. The branch (aaaaxcept:feat/fragment-disorder) stays up for anyone who wants it as a patch. Thanks for reviewing. |
Motivation
Russian TSPU has evolved from simple SNI-based blocking to analyzing TCP-level handshake patterns, including shaping and dropping connections based on ClientHello analysis (#5332, #6293). Plain fragmentation alone no longer suffices.
What TSPU does now
The inspector no longer just reads the first ClientHello record in isolation. It reassembles the client hello from multiple TCP fragments, so merely cutting the hello into pieces with delays (the current
fragmentbehavior) is not enough: the censor waits for the neighboring segments, collects them into a complete picture, and still sees the SNI. Reports from the issues:fragmentmask alone is no longer sufficient against current TSPU behavior. Also noted: Roskomnadzor has been matching known TLS fingerprint lists, so plain fragment needs a next-level countermeasure.Prior art: byedpi (hufrea/byedpi)
--disorder/--disoobmodes, zapret and GoodbyeDPI, all of which converged on the same class of TCP-level tricks against the Russian censor. Only the concept is reused here, no code.How disorder defeats reassembly
The ClientHello is split into segments. Segments with odd index are sent with
TTL=1:disoobadditionally sends the first segment's boundary byte as TCP urgent data (MSG_OOB) with a fake marker value; the real byte follows in the normal stream. DPI implementations that mishandle urgent data choke on it, while ordinary receivers skip the urgent byte and see the byte-exact stream.This extends the existing finalmask
fragmentmask with amodefield:normal(default, current behavior byte-for-byte compatible),disorder,disoob. No new config knobs: TTL is fixed at 1, the urgent marker is fixed. Extending finalmask masks incrementally matches the maintainer's stated intent.Changes
transport/internet/finalmask/fragment/config.proto:enum Mode { NORMAL, DISORDER, DISOOB }, fieldmode = 13;config.pb.goregenerated withgo run ./infra/vprotogen(-mode checkpasses).transport/internet/finalmask/fragment/conn.go:Write()refactored into split (splitClientHello/splitRaw) + send (writeSegments) phases, so segments can be flagged before any byte goes out.markDisorderflags odd-index segments. Dying segments follow the ordersetTTL(1) -> write -> sleep -> setTTL(def): the write returns when the data reached the kernel send buffer, not the wire, so restoring the TTL before a hold time could silently win the race and send the doomed segment unharmed. The configured delay doubles as the hold time; with all-zero delays a 10 ms grace hold is applied (a config warning points this out). DISOOB sendsdata[:pos]with a fake byte atposviaMSG_OOB, then the real byte in the plain stream (byedpisend_oob()semantics).TCP_NODELAYis enabled for non-normal modes so the small writes actually leave as separate segments.Splice()returnsfalsefor non-normal modes so the splice fast path cannot bypass the masking.disorder_unix.go/disorder_windows.go/disorder_other.go(new, build-tagged): TTL viaIP_TTL/IPV6_UNICAST_HOPS(picked by remote address family) on unix-like,WSASendwithMSG_OOBon Windows, explicit not-supported error on plan9/js (fail loudly, no silent degradation).infra/conf/transport_finalmask.go:modeJSON field with case-insensitive parsing, unknown values rejected with a clear error, default staysnormal.fragment/conn_test.go(7 tests / 84 subtests over real loopback TCP, byte-exact stream integrity in all modes, split-count proof, server-side semantics, 64-combination sweep of hello sizes x split lengths x modes) andinfra/conf/transport_finalmask_fragment_test.go(JSON path viaStreamConfig,ToMemoryStreamConfigruntime init for every mode, invalid-mode errors).Verification
go test ./transport/... ./infra/conf/...clean;go vet,go run ./infra/vprotogen -mode check,go run ./infra/vformatclean on the touched files.ttl 1/ttl 64; server ACKs show SACK holes (e.g.sack 1 {13:19}after the killedseq 7:13segment); the missing segments are RTO-retransmitted with the restored default TTL and the handshake completes.Flags [P.U], urg 7at the split boundary) plus the same ttl=1 alternation; stream reassembles correctly.go test -raceclean on the fragment package.Limitations (by design)
--disorder/--disoobcurrently work in Russia. The retransmission adds roughly 200 ms-1 s to the first handshake only.