aboutsummaryrefslogtreecommitdiff
path: root/gmid.h
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2024-08-03 14:40:17 +0000
committerOmar Polo <op@omarpolo.com>2024-08-03 14:40:17 +0000
commit905a32998fc46eea222fff851aab69eea4ac8e8a (patch)
treec84ef2222e5ab9df8a5accc87462fd3638130fae /gmid.h
parenta6b469c41b427f70e285c9e89dcfede523c81a51 (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.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/gmid.h b/gmid.h
index 3a28c29..d68e0e3 100644
--- a/gmid.h
+++ b/gmid.h
@@ -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