///|
fn main {
let header = @proxyproto.ProxyHeader::new(
V2,
Proxy,
Inet,
Stream,
Ipv4({
source_address: @proxyproto.parse_ipv4_text("192.0.2.1").unwrap(),
destination_address: @proxyproto.parse_ipv4_text("198.51.100.2").unwrap(),
source_port: 50000,
destination_port: 443,
}),
[],
).unwrap()
let tls = Bytes::from_array([
b'\x16', b'\x03', b'\x03', b'\x00', b'\x05', b'h', b'e', b'l', b'l', b'o',
])
let wire = @proxyproto.bytes_concat(
@proxyproto.encode_v2(header).unwrap(),
tls,
)
let frame = @proxyproto.decode_v2(wire, @proxyproto.DecodePolicy::v2_only()).unwrap()
if !@proxyproto.bytes_equal_constant_time(frame.remaining, tls) {
abort("TLS bytes changed")
}
println("TLS preamble preserved")
}