(header: ProxyHeader)
| 183 | use proxy_protocol::{version1 as v1, version2 as v2, ProxyHeader}; |
| 184 | |
| 185 | fn extract_v4(header: ProxyHeader) -> (std::net::SocketAddrV4, std::net::SocketAddrV4) { |
| 186 | match header { |
| 187 | ProxyHeader::Version1 { |
| 188 | addresses: |
| 189 | v1::ProxyAddresses::Ipv4 { |
| 190 | source, |
| 191 | destination, |
| 192 | }, |
| 193 | .. |
| 194 | } => (source, destination), |
| 195 | ProxyHeader::Version2 { |
| 196 | addresses: |
| 197 | v2::ProxyAddresses::Ipv4 { |
| 198 | source, |
| 199 | destination, |
| 200 | }, |
| 201 | .. |
| 202 | } => (source, destination), |
| 203 | other => panic!("expected ipv4 header, got {other:?}"), |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | #[tokio::test] |
| 208 | async fn parses_v1_ipv4() { |
no outgoing calls
no test coverage detected