Expand description
PROXY protocol v1/v2 parser for extracting the real client address from load balancers, CDNs, or other proxies that prepend the PROXY protocol header to TCP connections.
§Protocol overview
- v1 (text):
PROXY TCP4 192.168.1.1 192.168.1.2 12345 80\r\n - v2 (binary): 12-byte signature + version/command + family/transport + length + addresses
This module also provides PrefixedStream, a wrapper around TcpStream that
prepends buffered bytes (the leftover data after the PROXY header) so the
rest of the connection can be read normally.
Structs§
- Prefixed
Stream - A wrapper around a
TcpStreamthat prepends buffered bytes. - Proxy
Protocol Header - Parsed result of a PROXY protocol header.
Functions§
- parse_
proxy_ protocol - Parse the PROXY protocol header from the beginning of a TCP stream.