Fix ME proxy config parser to support IPv6 addresses

The getProxyConfigV6 endpoint returns addresses in [ipv6]:port format,
but the regex only matched IPv4 host:port, causing IPv6 ME map to be empty.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Igor 2026-02-18 10:28:43 +03:00
parent 0b36e14d6e
commit 0f40771223
1 changed files with 2 additions and 1 deletions

View File

@ -48,7 +48,8 @@ pub async fn fetch_proxy_config(url: &str) -> Result<ProxyConfigData> {
.await .await
.map_err(|e| crate::error::ProxyError::Proxy(format!("fetch_proxy_config read failed: {e}")))?; .map_err(|e| crate::error::ProxyError::Proxy(format!("fetch_proxy_config read failed: {e}")))?;
let re_proxy = Regex::new(r"proxy_for\s+(-?\d+)\s+([^\s:]+):(\d+)\s*;").unwrap(); // Matches both IPv4 `host:port` and IPv6 `[host]:port` formats
let re_proxy = Regex::new(r"proxy_for\s+(-?\d+)\s+\[?([^\]\s]+)\]?:(\d+)\s*;").unwrap();
let re_default = Regex::new(r"default\s+(-?\d+)\s*;").unwrap(); let re_default = Regex::new(r"default\s+(-?\d+)\s*;").unwrap();
let mut map: HashMap<i32, Vec<(IpAddr, u16)>> = HashMap::new(); let mut map: HashMap<i32, Vec<(IpAddr, u16)>> = HashMap::new();