(proxy_str: &str)
| 327 | } |
| 328 | |
| 329 | fn parse_proxy_addr(proxy_str: &str) -> Result<SocketAddr, anyhow::Error> { |
| 330 | let addr = if let Ok(addr) = SocketAddr::from_str(proxy_str) { |
| 331 | addr |
| 332 | } else if let Ok(ip) = IpAddr::from_str(proxy_str) { |
| 333 | SocketAddr::new(ip, DEFAULT_PROXY_PORT) |
| 334 | } else { |
| 335 | return Err(anyhow!("Could not parse proxy value: {proxy_str}")); |
| 336 | }; |
| 337 | |
| 338 | if addr.is_ipv6() { |
| 339 | return Err(anyhow!( |
| 340 | "IPv6 proxy addresses are not supported by bitreq (got `{proxy_str}`); \ |
| 341 | use an IPv4 address instead" |
| 342 | )); |
| 343 | } |
| 344 | |
| 345 | Ok(addr) |
| 346 | } |
| 347 | |
| 348 | #[test] |
| 349 | fn test_parse_proxy_addr() { |
no outgoing calls