Skip to content

socks: Preserve buffered payload after handshake - #114

Open
Snowy117 wants to merge 1 commit into
SagerNet:devfrom
Snowy117:fix/socks-handshake-buffered-payload
Open

Snowy117 wants to merge 1 commit into
SagerNet:devfrom
Snowy117:fix/socks-handshake-buffered-payload

Conversation

@Snowy117

@Snowy117 Snowy117 commented Oct 6, 2026

Copy link
Copy Markdown

Fixes #113 by wrapping the connection with bufio.NewCachedConn, just like the HTTP inbound:

if reader.Buffered() > 0 {
buffer := buf.NewSize(reader.Buffered())
_, err = buffer.ReadFullFrom(reader, reader.Buffered())
if err != nil {
return err
}
requestConn = bufio.NewCachedConn(conn, buffer)
} else {
requestConn = conn
}
handler.NewConnectionEx(ctx, requestConn, source, destination, onClose)

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.

socks握手时的bufio会吞掉客户端流水线发送的首段payload,进而导致UoT v2客户端的每条流都会失败

1 participant