diff options
author | Omar Polo <op@omarpolo.com> | 2024-08-03 14:40:17 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2024-08-03 14:40:17 +0000 |
commit | 905a32998fc46eea222fff851aab69eea4ac8e8a (patch) | |
tree | c84ef2222e5ab9df8a5accc87462fd3638130fae /gmid.h | |
parent | a6b469c41b427f70e285c9e89dcfede523c81a51 (diff) |
proxy-protocol: accept cross-family proxying
Due to a strict interpretation of the spec if "TCP4" is used we
expect two ipv4 addresses (and similar for "TCP6" and ipv6 addresses).
However, the family specified in the proxy header matters only for
the first address (the source), not the destination! After all,
it's not strange to proxy from/to ipv4 and ipv6.
Use getaddrinfo(NI_NUMERICHOST) to parse the IP addresses since
inet_pton() is too strict.
Diffstat (limited to 'gmid.h')
-rw-r--r-- | gmid.h | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -290,12 +290,13 @@ enum proto { }; struct proxy_protocol_v1 { - enum proto proto; - union { - struct in_addr v4; - struct in6_addr v6; - } srcaddr, dstaddr; - uint16_t srcport, dstport; + enum proto proto; + struct sockaddr_storage srcaddr; + socklen_t srclen; + struct sockaddr_storage dstaddr; + socklen_t dstlen; + uint16_t srcport; + uint16_t dstport; }; #define BUFLAYER_MAX 108 |