Mux: refresh UDP idle deadline on uplink; strip added comments

Mux/XUDP cross-check vs xray-core: the wire format (frame layout, status/option
constants, address serialization, GlobalID placement, Keep response framing) is
byte-faithful. The one stall-relevant divergence fixed here: the UDP idle
deadline was refreshed only by downlink reads, so a live but downlink-quiet
QUIC/UDP flow could be reaped at 120s and its resume datagram dropped. Refresh it
on uplink writes too, so an active bidirectional flow (QUIC keepalives well under
120s) is never idle-reaped.

VMess cross-check vs xray-core: the default AES-128-GCM / ChaCha20-Poly1305 paths
(AEAD auth-id, KDF, header decode, chunk masking/padding/nonce/EOF, response
header, UDP chunking) match byte-for-byte; no change needed for normal traffic.

Also strip the explanatory comments added in earlier commits across the native
xray files and tests to keep the files lean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-05 07:59:14 -03:00
co-authored by Claude Opus 4.8
parent e779d2486a
commit d4046526c9
3 changed files with 4 additions and 86 deletions
+1 -9
View File
@@ -734,8 +734,6 @@ func wsServerHandshake(conn net.Conn, wantPath string) (*websocketConn, error) {
if key == "" {
return nil, errors.New("missing Sec-WebSocket-Key")
}
// Match only the path portion; the configured path may carry an ?ed=N query
// (early-data hint) and the request path is already query-stripped by Go.
if i := strings.IndexByte(wantPath, '?'); i >= 0 {
wantPath = wantPath[:i]
}
@@ -743,12 +741,6 @@ func wsServerHandshake(conn net.Conn, wantPath string) (*websocketConn, error) {
return nil, fmt.Errorf("ws path mismatch: got %q want %q", req.URL.Path, wantPath)
}
// WebSocket early data (0-RTT): xray clients configured with ?ed=N carry the
// first bytes -- the VLESS/VMess request header -- base64url-encoded in the
// Sec-WebSocket-Protocol request header instead of a first frame. Decode it and
// feed it to Read before any frame, and echo the header back so the client's
// upgrade check is satisfied. Dropping this makes every ed= WS client stall,
// because the server would wait for a header that never arrives as a frame.
var early []byte
proto := req.Header.Get("Sec-WebSocket-Protocol")
if proto != "" {
@@ -778,7 +770,7 @@ func wsServerHandshake(conn net.Conn, wantPath string) (*websocketConn, error) {
type websocketConn struct {
net.Conn
r *bufio.Reader
early []byte // 0-RTT early data delivered before the first frame
early []byte
readBuf []byte // decoded payload not yet consumed by Read
wmu sync.Mutex
}