Repository navigation
XMC finalmask: Bound padding schedules; Fix delay placement; Stop compressing frames - #7423
Conversation
0ec2360 to
a3b8842
Compare
The startup padding schedule runs inside the login handshake, and its pauses used time.Sleep: a connection closed during a configured pause kept its handshake goroutine asleep, and a schedule whose pauses add up to more than the two-minute handshake deadline could never finish. A configured schedule also had no upper bound on its turn count, so one handshake could be told to send an arbitrary amount of padding. - Padding pauses are now timers that also watch a per-connection done channel, which Close closes, so a closed connection stops the schedule at once. - A configured schedule is rejected when it has more than 256 turns, more than 64 MiB of turns in total, or more than the handshake timeout minus ten seconds of pauses in total. - An explicit empty "paddings" array (or "noPadding": true) now disables padding instead of falling back to the preset; an absent field keeps the preset. The new no_padding proto field carries that across the wire because an unset repeated field cannot express it. - The proto comment states how the delay range is split: the side that sends a turn samples [delay_min, delay_max], and the peer only knows delay_min. This commit was produced with AI assistance (DeepSeek Harness).
A configured padding turn carried a pause that was applied after the turn, so the last turn of a schedule paused even though nothing followed it: with `delay: "300"` on the final turn the first proxied packet went out 300 ms later while both ends otherwise waited for nothing. Measured through a relay, the same configuration also made the pause look like it belonged to the previous turn. The pause now leads into the turn it is configured on: it is spent before that turn's bytes, which puts a captured gap on the turn that follows it, and the last turn is no longer followed by a pause. The peer, which sends nothing for that turn, spends the same pause at the same place so both timelines stay in phase. The value each end waits is unchanged and now stated in the proto comment: the side that sends a turn samples [delay_min, delay_max], the peer spends exactly delay_min (the peer waits the minimum, not "at least" it), so a range only jitters the sending side and delay_min == delay_max reproduces a captured gap. Tests pin the event order for both roles, the absence of a trailing pause, and that only the sending side samples the range. This commit was produced with AI assistance (DeepSeek Harness).
Two decisions in this branch were only described in the pull request, where nobody reading the code will find them: - A configured "paddings" list is the complete schedule. The built-in preset also carries a Play-state join tail, and that tail runs only with the preset, so a user who captured their own login decides the whole shape. - A peer cannot be checked for arriving early: the turns are ordinary Minecraft packets that carry nothing to compare an early arrival against, the startup reader drains them while the local schedule writes, and a stalled peer is bounded by the configured pause limit instead. Record both next to the code and the proto/JSON fields, and pin the replacement with a test that compares a configured schedule on both ends against the preset. This commit was produced with AI assistance (DeepSeek Harness).
After `Set Compression` the writer deflated every body at or above the negotiated threshold, and that covered exactly the two things XMC writes: padding, whose zeros deflated about 300 times, and proxied bytes, which are already compressed or encrypted. It also cost real throughput: on a local Fabric 26.1 server at the default threshold of 256, uploading 32 MiB through XMC ran at 19.2-20.9 MB/s with the compressing writer and at 46.9-52.1 MB/s without it, while the compressed body was no smaller than the original. What a padded turn declares is its size on the wire, so deflating it removed the shape the turn exists for: two 64 KiB client-to-server turns went out as 889 bytes in total, and a real server could not tell them from ordinary traffic of that size. Vanilla accepts the uncompressed variant of the framing at any size - `Data Length = 0` means the body follows as is, without the threshold check that only applies to deflated bodies - so the writer now always uses it. The reader is unchanged and still inflates whatever the peer sends, since a real server keeps compressing its own packets. Verified end to end against a real Fabric 26.1 server (protocol 775, online-mode through a local Yggdrasil API and authlib-injector) with `network-compression-threshold=256`, through a byte-counting relay in front of the server: - the same two 64 KiB turns now put 131,519 bytes on the wire instead of 889; - the built-in preset and a configured schedule both log in and reach the tunnel, and 32 MiB downloads keep their sha256; - the server accepts the uncompressed bodies above the threshold, including padding frames of 32 KiB and tunnel frames of 24 KiB. The server-side Fabric mod no longer has to ask for `network-compression-threshold=65536` once this lands. This commit was produced with AI assistance (DeepSeek Harness).
a3b8842 to
8f64bf0
Compare
本地 E2E 复测(2026-11-18)在 current head 1. Xray XMC 客户端 ↔ Xray XMC 服务端(legacy)
2. 真实 Minecraft 26.1(协议 775)+ 服务端模组环境:Fabric 26.1 开发服, 为完成真实登录,本地 E2E 客户端临时合并了草案 #7416(仅测试用,未改动本 PR 分支)。同样是两轮 64 KiB c2s padding:
32 MiB 下载 sha256 一致(约 12.3 MB/s);32 MiB 上传 sha256 一致。结论:真实服务端 补充(与本 PR 无关):模组的 256-payload 转发队列在回环网络上遇到“刚登录就立即 32 MiB 上行”时可能先溢出;用 以上数据由 AI 编码代理复跑整理。 Local E2E re-run (2026-11-18)Re-ran on current head 1. Xray XMC client ↔ Xray XMC server (legacy)
2. Real Minecraft 26.1 (protocol 775) + server-side modFabric 26.1 dev server, For the real login the local E2E client merged draft #7416 on top (test-only; the PR branch itself is unchanged). Same two 64 KiB c2s padding turns:
32 MiB download sha256 OK (~12.3 MB/s); 32 MiB upload sha256 OK. So after the real server's Side note (not caused by this PR): the mod's 256-payload relay queue can overflow on loopback when a client immediately uploads 32 MiB right after login; Numbers reproduced and summarized with AI assistance. |
|
@RPRX 你看看这个还有问题吗,因为我没权限重新跑CI,麻烦重新跑一下,然后这边找个时间合并 |
|
虽然我提出了 #7402 (comment) 但其实还有一个问题是,如果 the last one 之后确实需要 delay 呢?你测一下真实 MC 有没有 |
晚上有空我看看。 |
|
@RPRX 结论先说:MC 协议本身没有 padding,也没有任何"延迟/时序"字段;真机上 join 收尾的最后一个包之后也没有停顿——同一个 tick 里就会发 MC 协议到底是什么
"最后一个包之后"在真机上 查了 26.1 官方客户端(反编译),
所以 对 #7423
结论:这个 PR 不需要为"最后一个之后的 delay"改模型。 参考:Packets#Packet_format、FAQ 登录序列、Player Loaded、Keep Alive DeepSeek-V4.1-Flash的分析 你自己判断看看,如果需要,我可以开PR,尝试模仿20T的速率 |
一句话结论不做“进 Play 的强行伪装”,也不靠纯 pad 硬糊。走“真协议 + 假节奏”:登录和 Configuration 阶段按 MC 协议真走一遍(Client Info、Known Packs、Registry、Tags、Finish),客户端不回最后的确认包,于是停在 Configuration——不建玩家、不发区块。缺的两样东西用 pad 补:进服的体量、之后的 20 次/秒心跳。真客户端如果把确认包回了,就按 vanilla 原来的位置(白名单检查处)把它踢掉。 抓包(26.3,第三方登录,加密)
第三方登录通道名
拿公会服务器正常数据抓包让DeepSeek-V4.1-Flash分析的,虽然这里没什么人懂MC,但这条评论可能有用 |
Follow-up to #7402, rebased onto
mainafter both #7402 and #7430 merged: this is no longer a stacked draft, the diff is four commits, and it also settles the delay question and the compression side effect that #7402 left behind.Bound padding schedules and cancel their pauses on Close (unchanged from the draft). Padding pauses are timers that watch a per-connection
donechannel; a configured schedule is rejected above 256 turns, 64 MiB of turns, or the handshake deadline minus ten seconds of pauses; an explicit emptypaddingsarray (or"noPadding": true) disables padding, and an absent field keeps the preset.Pause before a padding turn and never after the last one. A configured
delayused to be applied after its turn, so the last turn of a schedule paused even though nothing followed it: withdelay: "300"on the final turn the first proxied packet went out 300 ms later, while both ends otherwise waited for nothing. The pause now leads into the turn it is configured on - a captured gap is written on the turn that follows it - and the last turn is not followed by a pause. Which value each end waits is unchanged and now stated in the proto comment: the side that sends the turn samples[delay_min, delay_max], the peer spends exactlydelay_min(it waits the minimum, not "at least" it), so a range jitters only the sending side anddelay_min == delay_maxreproduces a captured gap.State what a configured padding list replaces. Two decisions only lived in the pull request: a configured list is the complete schedule, so the preset's Play-state join tail runs only with the preset; and a peer cannot be checked for arriving early, because the turns are ordinary Minecraft packets that carry nothing to compare an early arrival against, with the pause bound covering a stalled peer. Both are now next to the code and pinned by a test.
Never compress the frames XMC writes. After
Set Compressionthe writer deflated everything at or above the threshold, which is exactly the padding (zeros, ~300:1) and the proxied bytes (already compressed or encrypted): the padded shape disappeared and the CPU work bought nothing. The writer now always sends the uncompressed variant, which vanilla accepts at any size (Data Length = 0is not subject to the threshold check), and the reader still inflates what a real server sends.#7430 landed while this was open and added a startup reader that drains the peer's padding independently while the local schedule writes. That is why point 3 no longer says the peer's turns stay in the stream for the next reader: they are read and dropped by that reader, while the pause limit still bounds a stalled peer. This branch is rebased onto #7430, and the two changes coexist - the reader drains, and the schedule still spends
delay_minon the peer's turn. The handshake test that #7430 added now builds its schedule through this branch'spaddingScheduleFromConfiginstead of passing[]*Paddingto the constructors.Tests
New coverage: pause placement for both roles and the absence of a trailing pause; which end samples the range and which spends the minimum; a configured list replacing the whole preset on both ends; the writer never compressing (zero-filled and random bodies, 1 B to 64 KiB) while the reader still accepts deflated bodies, chunked writes and multiple frames per write.
End-to-end, real server, compression on
Local Fabric 26.1 server (protocol 775) with the server-side mod,
online-mode=truethrough a local Yggdrasil API and authlib-injector,network-compression-threshold=256(the default), and a byte-counting relay in front of the server. The client side is this branch with the Yggdrasil draft #7416 merged locally for the real login.The built-in preset and a configured schedule both log in and reach the tunnel, and the server accepts the uncompressed bodies above the threshold (padding frames of 32 KiB, tunnel frames of 24 KiB). A configured
delayof 600 ms on two turns adds 1.2 s to the login as expected, so the final turn's pause is spent where it belongs.With this, the server-side mod no longer needs to ask for
network-compression-threshold=65536to keep padding frames intact; that requirement and its warning can be dropped after this lands.This PR was produced with AI assistance (DeepSeek Harness).