Skip to content

header-custom finalmask: Add UDP standalone handshake mode - #5945

Merged
RPRX merged 1 commit into
XTLS:mainfrom
fatyzzz:pr/finalmask-header-custom-udp-standalone-main
Apr 15, 2026
Merged

RPRX merged 1 commit into
XTLS:mainfrom
fatyzzz:pr/finalmask-header-custom-udp-standalone-main

Conversation

@fatyzzz

@fatyzzz fatyzzz commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • add standalone mode for UDP finalmask/header-custom
  • allow sending a detached UDP handshake datagram before the actual payload
  • keep existing per-packet UDP header-custom behavior unchanged unless mode: "standalone" is set

Why

Current UDP header-custom works as a per-packet header wrapper. That is enough for packet shaping, but not for cases where the handshake should be sent as a separate datagram before the real payload.

This PR adds that detached standalone handshake mode only for UDP header-custom. It does not change TCP behavior and does not add protocol-specific helpers.

Scope

  • add mode: "standalone" for UDP header-custom
  • send and consume detached standalone handshake datagrams before payload
  • preserve capture/reuse/metadata behavior in standalone mode
  • keep existing UDP header-custom behavior unchanged by default

Non-Goals

  • no new protocol-specific masks
  • no changes to TCP header-custom
  • no general programmable transport layer in this PR

Test Plan

  • go test ./common/serial -run 'TestTypedMessageRoundTripPreservesFinalmaskCustomUDPMode' -count=1
  • go test ./transport/internet/finalmask -run 'Test(UDPcustomStandaloneClientSendsDetachedHandshakeBeforePayload|UDPcustomStandaloneServerConsumesHandshakeAndAutoResponds|UDPcustomStandaloneStunLikeExchangeUsesSavedTxidAndSrcMetadata|UDPcustomStandaloneClientHandshakeSurvivesConcurrentReader|PacketConnReadWrite|UDPcustomStaticHeaderWireShape|UDPcustomServerRejectsMismatchedStaticHeader|TCPcustomStaticHandshakeRoundTrip|TCPcustomClientRejectsMismatchedServerSequence|ConnReadWrite)' -count=1
  • local live smoke via SOCKS5 UDP ASSOCIATE against standalone mode returned udp-pr3-standalone-newpr

@RPRX

RPRX commented Apr 15, 2026

Copy link
Copy Markdown
Member

我之前给 @LjhAUMEM 说把 UDP noise 并入 header-custom 他说麻烦,现在是不麻烦了吗

@LjhAUMEM

LjhAUMEM commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

这个也不是 noise 啊,自定义 handshake,原 freedom noise 又没有 handshake 的功能

又看了一下也是新起 conn 只是和 custom 写一个文件夹了,这不算并入吧

@fatyzzz

fatyzzz commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

这个也不是 noise 啊,自定义 handshake,原 freedom noise 又没有 handshake 的功能

This PR is not merging the old UDP noise into header-custom.

It only adds a standalone handshake mode for UDP header-custom: send one detached handshake datagram first, then send the real payload.

The old freedom noise did not have handshake semantics like capture/reuse, runtime metadata, or request/response correlation, so I do not think they are the same kind of change.

@LjhAUMEM

Copy link
Copy Markdown
Contributor

我之前给 @LjhAUMEM 说把 UDP noise 并入 header-custom 他说麻烦,现在是不麻烦了吗

因为原 freedom noise 允许长度随机,你要是说把这个长度随机特性砍掉移到 header-custom 那确实简单

@RPRX

RPRX commented Apr 15, 2026

Copy link
Copy Markdown
Member

共同点是 standalone no-user-payload UDP packets,不过先不动 noise 吧,那个承接着配置稳定转移的任务

@fatyzzz

fatyzzz commented Apr 15, 2026

Copy link
Copy Markdown
Contributor Author

Yes, noise itself is unchanged in this PR.

This PR only extends UDP header-custom with standalone detached handshake behavior. It touches the shared finalmask UDP wiring, but it does not modify or replace the existing noise feature.

@RPRX RPRX changed the title Finalmask header-custom: add UDP standalone handshake mode header-custom finalmask: Add UDP standalone handshake mode Apr 15, 2026
@RPRX
RPRX merged commit 05e259c into XTLS:main Apr 15, 2026
39 checks passed
Exclude0122 pushed a commit to Exclude0122/Xray-core that referenced this pull request Apr 19, 2026
Exclude0122 pushed a commit to Exclude0122/Xray-core that referenced this pull request Apr 19, 2026
wyusgw pushed a commit to wyusgw/Xray-core that referenced this pull request Sep 15, 2026
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.

3 participants