Repository navigation
Conversation
Member
|
Client finished 最后一个字节要先按住不发,等一个 RTT 等目标服务端响应, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For XTLS/Xray-core#6121
This implements the fix described in XTLS/Xray-core#6121 (comment) ("直到读到正确的 client finished 之前都交给 target 来响应"). It is offered as a ready, tested version of that design; feel free to take it as is or use it as a reference.
The problem. A censor captures a ClientHello and replays it twice, each time followed by the same invalid record:
Any difference between the two answers identifies the server.
The fix. While REALITY waits for the Client Finished, the client's conn is a
guardConn(new fileguard.go):With a valid client, the target sees ChangeCipherSpec and the Client Finished minus its last byte, then a close. Before, it saw a close after the ClientHello.
Also: the first goroutine now reads
hs.c.connbeforemutex.Unlock().hs.c.connis temporarily the guard, and it was read without the lock.Test. The tester replays a captured ClientHello as A and B and sends each of the 20 probes from VLESS-cracker's
characteristic.txt, with 2 rounds per probe. It runs on loopback, with v26.11.9-main Xray built against REALITY4bb46b2with and without this change. The table counts probes whose answers differ between A and B:crypto/tls(net/http)s_server -alpn h2,http/1.1The two OpenSSL mismatches are the ones reported in the issue:
15 03 03 00 02 03 00and15 03 03 00 02 01 FF. Go answers with an alert, OpenSSL with FIN. With this change, A answers FIN like the target.guard_test.gocovers which bytes are held back and released: partial headers, several records in one read, a zero-length record, and the hand-over.go test -race ./...passes.Not covered.
hs.handshake()withpadding: -136, because of its X25519-only key share and a different record layout, both before and after this change.中文:按 RPRX 在 #6121 的方案实现:在读到正确的 Client Finished 之前,客户端发来的数据同时转发给 target(每个 REALITY 尚未处理完的记录保留最后一个字节,保证正确的 Finished 永远不会完整到达 target)。如果 REALITY 拒绝了某个记录,或者 target 先有响应,REALITY 不发送自己的 alert,把剩余字节交给 target 并转为双向转发,客户端收到的就是 target 自己的响应(alert / FIN / 超时)。测试中 OpenSSL target 的两个已知差异探针(
15 03 03 00 02 03 00、15 03 03 00 02 01 FF)由 2/20 降为 0/20,Go target 保持 0/20,正常客户端不受影响。