Skip to content

Accept PROXY v2 headers with TLVs after the address block - #1962

Closed
HawkForge wants to merge 1 commit into
uNetworking:masterfrom
HawkForge:fix/proxy-v2-tlvs
Closed

HawkForge wants to merge 1 commit into
uNetworking:masterfrom
HawkForge:fix/proxy-v2-tlvs

Conversation

@HawkForge

Copy link
Copy Markdown

Fixes #1957. Thanks to @slavslavov for the detailed report.

A PROXY v2 payload is the address block followed by optional TLVs. ProxyParser::parse() rejected any payload longer than sizeof(proxy_addr) (36 bytes), and a rejected header looks like "need more data" to HttpParser, so the connection just hangs. HAProxy's send-proxy-v2 adds an ALPN TLV for ALPN clients, which puts every IPv6 client at 36 + 5 bytes, so they all hang behind HAProxy.

The parser now copies at most sizeof(proxy_addr) bytes of the payload and still consumes the whole 16 + len, so TLVs are skipped. The existing check that all 16 + len bytes have arrived stays as it is.

Adds tests/ProxyParser.cpp (wired into tests/Makefile): IPv6 and IPv4 headers with an ALPN TLV parse, report the right source address and port, and consume the TLV; a truncated header still waits for more data. The IPv6 case fails without the change. HttpParser.cpp also still builds and passes with -DUWS_WITH_PROXY.

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.

PROXY v2 parser rejects headers carrying TLVs, so IPv6 clients behind HAProxy hang

1 participant