Skip to content

fix(control): udp short-write fix (#1030) - #3

Open
itoywh wants to merge 1 commit into
kdaefrom
pr/1030-udp-short-write
Open

itoywh wants to merge 1 commit into
kdaefrom
pr/1030-udp-short-write

Conversation

@itoywh

@itoywh itoywh commented Jul 20, 2026

Copy link
Copy Markdown
Owner

来源

从 daeuniverse/dae 官方 PR #1030 迁移至 itoywh/kdae。

功能

UDP endpoint WriteTo 的 short-write 判定从 n != len(b) 修正为 n < len(b)

代理 WriteTo 报告的字节数可能包含协议封装开销(如 shadowsocks AES-128-GCM + IPv4 会多 39 字节),导致 n 合法地大于 len(b)。UDP 数据报是原子传输的,只有 n < len(b) 才是真正的短写、值得 retire endpoint;n > len(b) 不应误判。

影响文件

control/udp_endpoint_pool.go(+ 单元测试)

Port daeuniverse/dae PR #1030 (fixes #1029): a proxy WriteTo may report the
on-wire byte count including protocol encapsulation overhead (e.g. shadowsocks
AES-128-GCM + IPv4 = +39), so n can legitimately exceed len(b). UDP datagrams
are atomic, so only n < len(b) is a genuine short write worth retiring the
endpoint over. Relaxing 'n != len(b)' -> 'n < len(b)' stops false-positive
endpoint retirement that manifested as udp4 flapping / QUIC jitter with
encapsulating outbounds (Shadowsocks/VMess packet-addr).

Success return is left as the on-wire n (not normalized to len(b)) to stay
byte-for-byte with upstream #1030 for future rebases.

Adds two regression tests (verbatim from #1030):
- TestUdpEndpointWriteTo_AcceptsProxyOverheadBytes: over-write stays alive
- TestUdpEndpointWriteTo_StillRetiresOnTruePartialWrite: true under-write retires
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant