[FIXED] PROXY v1 parsing may discard client bytes#7962
Conversation
If the parser read past the \r\n of a PROXY protocol v1 header, then the remaining bytes, if any, would be dropped. That left the connection desynchronized before normal client parsing saw CONNECT. `readProxyProtoHeader` now returns the remaining bytes, to be read by the next protocol parsing step. Signed-off-by: Daniele Sciascia <daniele@nats.io>
|
@claude review |
|
Claude finished @sciascid's task in 1m 45s —— View job Claude's Review
SummaryThis is a clean, focused fix for a real protocol-level data loss bug. The root cause is correctly identified: Fix Correctness
The buffer loop is correct. remaining = append(remaining, line[i+2:]...)
line = line[:i]
goto foundCRLFUsing
The one-line change from V2 path ( V2 always returns UNKNOWN command ( if parts[0] == proxyProtoV1Unknown {
return nil, remaining, nil
}
Test CoverageTwo targeted improvements:
The updated lock discipline in the end-to-end test is also a minor improvement – Minor Observations (non-blocking)
LGTM. The fix is minimal, correct, and well-tested. |
If the parser read past the \r\n of a PROXY protocol v1 header, then the remaining bytes, if any, would be dropped. That left the connection desynchronized before normal client parsing saw CONNECT.
readProxyProtoHeadernow returns the remaining bytes, to be read by the next protocol parsing step.Signed-off-by: Daniele Sciascia daniele@nats.io