haproxy: use correct ip version on client supplied address

When a user supplies an IP address to use for the HAPROXY protocol,
the IP version reported must be deduced from the address and has
no relation to the IP version used for the upstream connection.

Add test3220 to verify.

Fixes #21340
Reported-by: Fiona Klute
Closes #21341
This commit is contained in:
Stefan Eissing 2026-04-16 13:44:13 +02:00 committed by Daniel Stenberg
parent 021a87cf81
commit 70281e39be
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 86 additions and 10 deletions

View file

@ -31,6 +31,9 @@ When this parameter is set to a valid IPv4 or IPv6 numerical address in its
printable ASCII string version, the library sends this as the client address
in the HAProxy PROXY protocol v1 header at beginning of the connection.
The client address is reported upstream as the source *and* destination address
of the non-existing client connection (since 8.20.0).
This option is an alternative to CURLOPT_HAPROXYPROTOCOL(3) as that one cannot
use a specified address.