finalmask/fragment: implement CloseWrite to satisfy reality.CloseWriteConn (#6509)#6510
Closed
skvarovski wants to merge 1 commit into
Closed
finalmask/fragment: implement CloseWrite to satisfy reality.CloseWriteConn (#6509)#6510skvarovski wants to merge 1 commit into
skvarovski wants to merge 1 commit into
Conversation
…TLS#6509) After XTLS#6331 reversed the TCP mask wrapping order (slices.Backward), fragmentConn became the outermost finalmask wrapper for {fragment, sudoku} configs. The external github.com/xtls/reality library performs a hard type assertion 'raw.(CloseWriteConn)' (tls.go) on the connection passed to reality.Server, so a REALITY server inbound combined with finalmask fragment+sudoku panics on every client connection (crash-loop with Restart=always). Add CloseWrite(), mirroring sudoku/conn_tcp.go, so fragmentConn satisfies reality.CloseWriteConn. Additive and non-breaking.
skvarovski
force-pushed
the
fix/fragment-closewrite
branch
from
July 16, 2026 22:50
9de921a to
c64c910
Compare
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.
Fixes #6509.
Root cause
Since #6331 reversed the finalmask TCP mask wrapping order (
slices.Backward),fragmentConnis the outermost wrapper for{fragment, sudoku}configs. The externalgithub.com/xtls/realitylibrary performs a hard type assertion on the connection handed toreality.Server:fragmentConndoes not implementCloseWrite(), so any REALITY server inbound combined withfinalmaskcontainingfragmentpanics on every client connection:sudoku.wrappedConnalready implementsCloseWrite()(delegating to the underlying conn), which is why the panic only surfaced after #6331 madefragmentthe outer wrapper.Fix
Add
CloseWrite()tofragmentConn, mirroringsudoku/conn_tcp.go:Additive and non-breaking (+11 lines). Does not touch the wrapping order or the UDP path introduced by #6331.
Verification
Deployed to a production bridge and tested end-to-end (VLESS + XHTTP + REALITY + finalmask fragment+sudoku):