MCPcopy Create free account
hub / github.com/ermak-dev/cloudpub / test_proxy_v2_header_ipv6

Function test_proxy_v2_header_ipv6

common/src/proxy_protocol.rs:173–203  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

171
172 #[test]
173 fn test_proxy_v2_header_ipv6() {
174 let client = SocketAddr::V6(SocketAddrV6::new(
175 Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 1),
176 54321,
177 0,
178 0,
179 ));
180 let server = SocketAddr::V6(SocketAddrV6::new(
181 Ipv6Addr::new(0x2001, 0xdb8, 0, 0, 0, 0, 0, 2),
182 25565,
183 0,
184 0,
185 ));
186
187 let header = build_proxy_v2_header(&client, &server);
188
189 // Check signature
190 assert_eq!(&header[0..12], &PROXY_V2_SIGNATURE);
191
192 // Check version + command
193 assert_eq!(header[12], 0x21); // v2 + PROXY
194
195 // Check address family + protocol
196 assert_eq!(header[13], 0x21); // AF_INET6 + STREAM
197
198 // Check address length
199 assert_eq!(&header[14..16], &36u16.to_be_bytes());
200
201 // Total header size for IPv6: 16 + 36 = 52 bytes
202 assert_eq!(header.len(), 52);
203 }
204
205 #[test]
206 fn test_proxy_v2_local_header() {

Callers

nothing calls this directly

Calls 1

build_proxy_v2_headerFunction · 0.85

Tested by

no test coverage detected