25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(ai): bypass proxies for loopback requests, fix IPv6 parsing
Rendegou95eb27dab1cf
diff --git a/crates/dbx-ai-provider/Cargo.toml b/crates/dbx-ai-provider/Cargo.tomlindex b23a5ffeb6..d7977f605d 100644--- a/crates/dbx-ai-provider/Cargo.toml+++ b/crates/dbx-ai-provider/Cargo.toml@@ -20,4 +20,5 @@ httpdate = "1"tempfile = "3"[dev-dependencies]+reqwest = { version = "0.12", default-features = false, features = ["system-proxy"] }tokio = { version = "1", features = ["test-util", "rt-multi-thread"] }diff --git a/crates/dbx-ai-provider/src/ai.rs b/crates/dbx-ai-provider/src/ai.rsindex ed53d47029..d63e05667f 100644--- a/crates/dbx-ai-provider/src/ai.rs+++ b/crates/dbx-ai-provider/src/ai.rs@@ -1944,6 +1944,7 @@ fn ai_endpoint_is_loopback(config: &AiConfig) -> bool {let Some(host) = url.host_str() else {return false;};+ let host = host.strip_prefix('[').and_then(|host| host.strip_suffix(']')).unwrap_or(host);host.eq_ignore_ascii_case("localhost") || host.parse::<IpAddr>().map(|addr| addr.is_loopback()).unwrap_or(false)}@@ -1952,7 +1953,10 @@ pub fn build_ai_http_client(config: &AiConfig, timeout_secs: u64) -> Result<reqwif config.skip_tls_verify {builder = builder.danger_accept_invalid_certs(true);}- if config.proxy_enabled && !config.proxy_url.trim().is_empty() && !ai_endpoint_is_loopback(config) {+ if ai_endpoint_is_loopback(config) {+ // Skipping an explicit proxy alone still allows environment and system proxies.+ builder = builder.no_proxy();+ } else if config.proxy_enabled && !config.proxy_url.trim().is_empty() {let proxy_url = normalize_ai_proxy_url(&config.proxy_url);let proxy = reqwest::Proxy::all(&proxy_url).map_err(|e| format!("Invalid AI proxy URL: {e}"))?;builder = builder.proxy(proxy);@@ -6386,6 +6390,29 @@ mod tests {build_ai_http_client(&config, 1).unwrap();}+ #[test]+ fn ai_http_client_identifies_loopback_endpoints() {+ for (endpoint, expected) in [+ ("http://localhost:3456/v1", true),+ ("http://LOCALHOST:3456/v1", true),+ ("http://127.0.0.1:3456/v1", true),+ ("http://127.12.34.56:3456/v1", true),+ ("http://[::1]:3456/v1", true),+ ("http://192.168.1.2:3456/v1", false),+ ("http://10.0.0.1:3456/v1", false),+ ("http://[fd00::1]:3456/v1", false),+ ("https://api.example.com/v1", false),+ ("http://localhost.example.com/v1", false),+ ("invalid endpoint", false),+ ] {+ let config: AiConfig = serde_json::from_value(serde_json::json!({+ "provider": "openai-compatible", "endpoint": endpoint+ }))+ .unwrap();+ assert_eq!(super::ai_endpoint_is_loopback(&config), expected, "{endpoint}");+ }+ }+#[test]fn ai_http_client_bypasses_proxy_for_loopback_endpoint() {let config = AiConfig {diff --git a/crates/dbx-ai-provider/tests/ai_http_proxy.rs b/crates/dbx-ai-provider/tests/ai_http_proxy.rsnew file mode 100644index 0000000000..7ac115f6c5--- /dev/null+++ b/crates/dbx-ai-provider/tests/ai_http_proxy.rs@@ -0,0 +1,184 @@+//! Requests run in fresh processes so proxy variables and discovery caches are isolated.+use dbx_ai_provider::ai::{build_ai_http_client, AiConfig};+use std::io::{Read, Write};+use std::net::{SocketAddr, TcpListener};+use std::process::Command;+use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};+use std::sync::Arc;+use std::thread;+use std::time::{Duration, Instant};++struct Mock {+ address: SocketAddr,+ hits: Arc<AtomicUsize>,+ stopped: Arc<AtomicBool>,+ worker: Option<thread::JoinHandle<()>>,+}++impl Mock {+ fn start(bind: &str, status: u16) -> std::io::Result<Self> {+ let listener = TcpListener::bind(bind)?;+ let address = listener.local_addr()?;+ listener.set_nonblocking(true)?;+ let hits = Arc::new(AtomicUsize::new(0));+ let stopped = Arc::new(AtomicBool::new(false));+ let worker_hits = hits.clone();+ let worker_stopped = stopped.clone();+ let worker = thread::spawn(move || {+ while !worker_stopped.load(Ordering::SeqCst) {+ match listener.accept() {+ Ok((mut stream, _)) => {+ stream.set_nonblocking(false).unwrap();+ stream.set_read_timeout(Some(Duration::from_secs(2))).unwrap();+ stream.set_write_timeout(Some(Duration::from_secs(2))).unwrap();+ let mut request = Vec::new();+ let mut buffer = [0; 1024];+ while !request.windows(4).any(|bytes| bytes == b"\r\n\r\n") {+ let length = stream.read(&mut buffer).unwrap();+ assert!(length > 0 && request.len() < 65536, "invalid mock request");+ request.extend_from_slice(&buffer[..length]);+ }+ worker_hits.fetch_add(1, Ordering::SeqCst);+ let body = if status == 200 { "model" } else { "proxy" };+ write!(+ stream,+ "HTTP/1.1 {status} Mock\r\nContent-Length: {}\r\nConnection: close\r\n\r\n{body}",+ body.len()+ )+ .unwrap();+ }+ Err(error) if error.kind() == std::io::ErrorKind::WouldBlock => {+ thread::sleep(Duration::from_millis(5));+ }+ Err(error) => panic!("mock accept failed: {error}"),+ }+ }+ });+ Ok(Self { address, hits, stopped, worker: Some(worker) })+ }+}++impl Drop for Mock {+ fn drop(&mut self) {+ self.stopped.store(true, Ordering::SeqCst);+ if let Some(worker) = self.worker.take() {+ let result = worker.join();+ if !thread::panicking() {+ result.unwrap();+ }+ }+ }+}++fn request(endpoint: &str, mode: &str, environment: &Mock, explicit: &str, expected: &Mock, status: u16) {+ let mut command = Command::new(std::env::current_exe().unwrap());+ command.args(["--ignored", "--exact", "proxy_request_child", "--nocapture"]);+ for key in+ ["HTTP_PROXY", "HTTPS_PROXY", "ALL_PROXY", "NO_PROXY", "http_proxy", "https_proxy", "all_proxy", "no_proxy"]+ {+ command.env_remove(key);+ }+ command.env("HTTP_PROXY", format!("http://{}", environment.address));+ command.env("HTTPS_PROXY", format!("http://{}", environment.address));+ command.env("ALL_PROXY", format!("http://{}", environment.address));+ command.env("DBX_PROXY_TEST_ENDPOINT", endpoint);+ command.env("DBX_PROXY_TEST_MODE", mode);+ command.env("DBX_PROXY_TEST_EXPLICIT", explicit);+ command.env("DBX_PROXY_TEST_PEER", expected.address.to_string());+ command.env("DBX_PROXY_TEST_STATUS", status.to_string());+ let mut child = command.spawn().unwrap();+ let deadline = Instant::now() + Duration::from_secs(20);+ loop {+ if let Some(result) = child.try_wait().unwrap() {+ assert!(result.success(), "child failed: {endpoint}, {mode}");+ break;+ }+ if Instant::now() > deadline {+ child.kill().unwrap();+ child.wait().unwrap();+ panic!("proxy test child timed out: {endpoint}, {mode}");+ }+ thread::sleep(Duration::from_millis(10));+ }+}++fn loopback_requests(mode: &str) {+ for host in ["127.0.0.1", "127.0.0.2", "localhost", "[::1]"] {+ let bind = if host == "localhost" { "127.0.0.1" } else { host };+ let model = match Mock::start(&format!("{bind}:0"), 200) {+ Ok(mock) => mock,+ Err(error)+ if host == "[::1]"+ && matches!(+ error.kind(),+ std::io::ErrorKind::AddrNotAvailable | std::io::ErrorKind::Unsupported+ ) =>+ {+ eprintln!("IPv6 loopback is unavailable: {error}");+ continue;+ }+ Err(error) => panic!("cannot bind model mock: {error}"),+ };+ let proxy = Mock::start("127.0.0.1:0", 502).unwrap();+ let endpoint = format!("http://{host}:{}/v1/models", model.address.port());+ let explicit = match mode {+ "valid" => format!("http://{}", proxy.address),+ "invalid" => "not a proxy url".to_owned(),+ _ => String::new(),+ };+ request(&endpoint, mode, &proxy, &explicit, &model, 200);+ assert_eq!(model.hits.load(Ordering::SeqCst), 1);+ assert_eq!(proxy.hits.load(Ordering::SeqCst), 0);+ }+}++#[test]+fn loopback_bypasses_automatic_proxy_when_disabled() {+ loopback_requests("disabled");+}++#[test]+fn loopback_bypasses_automatic_proxy_with_empty_explicit_proxy() {+ loopback_requests("empty");+}++#[test]+fn loopback_bypasses_valid_explicit_proxy() {+ loopback_requests("valid");+}++#[test]+fn loopback_ignores_invalid_explicit_proxy() {+ loopback_requests("invalid");+}++#[test]+fn public_endpoint_preserves_automatic_and_explicit_proxy_priority() {+ let automatic = Mock::start("127.0.0.1:0", 502).unwrap();+ let explicit = Mock::start("127.0.0.1:0", 502).unwrap();+ let endpoint = "http://dbx-proxy-regression.invalid/v1/models";+ request(endpoint, "disabled", &automatic, "", &automatic, 502);+ request(endpoint, "valid", &automatic, &format!("http://{}", explicit.address), &explicit, 502);+ assert_eq!(automatic.hits.load(Ordering::SeqCst), 1);+ assert_eq!(explicit.hits.load(Ordering::SeqCst), 1);+}++#[test]+#[ignore = "invoked only by the parent tests in a fresh proxy environment"]+fn proxy_request_child() {+ let endpoint = std::env::var("DBX_PROXY_TEST_ENDPOINT").unwrap();+ let mode = std::env::var("DBX_PROXY_TEST_MODE").unwrap();+ let config: AiConfig = serde_json::from_value(serde_json::json!({+ "provider": "openai-compatible", "endpoint": endpoint,+ "proxyEnabled": mode != "disabled", "proxyUrl": std::env::var("DBX_PROXY_TEST_EXPLICIT").unwrap()+ }))+ .unwrap();+ tokio::runtime::Builder::new_current_thread().enable_all().build().unwrap().block_on(async {+ let client = build_ai_http_client(&config, 5).unwrap();+ let response = client.get(&endpoint).send().await.unwrap();+ let expected_status: u16 = std::env::var("DBX_PROXY_TEST_STATUS").unwrap().parse().unwrap();+ assert_eq!(response.status().as_u16(), expected_status);+ assert_eq!(response.remote_addr().unwrap().to_string(), std::env::var("DBX_PROXY_TEST_PEER").unwrap());+ assert_eq!(response.text().await.unwrap(), if expected_status == 200 { "model" } else { "proxy" });+ });+}diff --git a/scripts/ai-proxy-12277/.gitignore b/scripts/ai-proxy-12277/.gitignorenew file mode 100644index 0000000000..a348e5040c--- /dev/null+++ b/scripts/ai-proxy-12277/.gitignore@@ -0,0 +1 @@+/__pycache__/diff --git a/scripts/ai-proxy-12277/Cargo.lock b/scripts/ai-proxy-12277/Cargo.locknew file mode 100644index 0000000000..2a9e882f45--- /dev/null+++ b/scripts/ai-proxy-12277/Cargo.lock@@ -0,0 +1,1548 @@+# This file is automatically @generated by Cargo.+# It is not intended for manual editing.+version = 4++[[package]]+name = "atomic-waker"+version = "1.1.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"++[[package]]+name = "base64"+version = "0.22.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"++[[package]]+name = "bitflags"+version = "2.13.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"++[[package]]+name = "bumpalo"+version = "3.20.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"++[[package]]+name = "bytes"+version = "1.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"++[[package]]+name = "cc"+version = "1.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f74872d07caf508b30a21f6836e7d7016a2eaf7d9ff4f48deaa58cd8a0407630"+dependencies = [+ "find-msvc-tools",+ "shlex",+]++[[package]]+name = "cfg-if"+version = "1.0.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600"++[[package]]+name = "cfg_aliases"+version = "0.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"++[[package]]+name = "chacha20"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c35e4b699c7e15ccbe7ee35c005e4fc0a278d22238a2857e6ce2dadeda1b06"+dependencies = [+ "cfg-if",+ "cpufeatures",+ "rand_core",+]++[[package]]+name = "core-foundation"+version = "0.9.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "core-foundation-sys"+version = "0.8.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"++[[package]]+name = "cpufeatures"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5ca28b0ae3115b884660db4118d803791fd6756b6e88f39c0f3f7859060d7566"+dependencies = [+ "libc",+]++[[package]]+name = "dbx-ai-provider"+version = "0.1.0"+dependencies = [+ "base64",+ "bytes",+ "dbx-platform",+ "futures",+ "httpdate",+ "log",+ "reqwest",+ "serde",+ "serde_json",+ "tempfile",+ "tokio",+ "uuid",+]++[[package]]+name = "dbx-ai-proxy-12277-proof"+version = "0.1.0"+dependencies = [+ "dbx-ai-provider",+ "hyper-util",+ "reqwest",+ "serde_json",+ "tokio",+ "windows-sys 0.61.2",+]++[[package]]+name = "dbx-platform"+version = "0.1.0"+dependencies = [+ "nix",+ "tokio",+]++[[package]]+name = "displaydoc"+version = "0.2.7"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "equivalent"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"++[[package]]+name = "errno"+version = "0.3.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"+dependencies = [+ "libc",+ "windows-sys 0.61.2",+]++[[package]]+name = "fastrand"+version = "2.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"++[[package]]+name = "find-msvc-tools"+version = "0.1.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "aedcfb3409746eddb02b9e19ebda1c3394f759a152e48ee875a0844d1b955484"++[[package]]+name = "form_urlencoded"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf"+dependencies = [+ "percent-encoding",+]++[[package]]+name = "futures"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-executor",+ "futures-io",+ "futures-sink",+ "futures-task",+ "futures-util",+]++[[package]]+name = "futures-channel"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"+dependencies = [+ "futures-core",+ "futures-sink",+]++[[package]]+name = "futures-core"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"++[[package]]+name = "futures-executor"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"+dependencies = [+ "futures-core",+ "futures-task",+ "futures-util",+]++[[package]]+name = "futures-io"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"++[[package]]+name = "futures-macro"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "futures-sink"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1944426bf7d03f1d14f708785e4b33efd750b36d48a157b836b3efc15ede8e1d"++[[package]]+name = "futures-task"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"++[[package]]+name = "futures-util"+version = "0.3.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"+dependencies = [+ "futures-channel",+ "futures-core",+ "futures-io",+ "futures-macro",+ "futures-sink",+ "futures-task",+ "memchr",+ "pin-project-lite",+ "slab",+]++[[package]]+name = "getrandom"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0"+dependencies = [+ "cfg-if",+ "js-sys",+ "libc",+ "wasi",+ "wasm-bindgen",+]++[[package]]+name = "getrandom"+version = "0.4.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"+dependencies = [+ "cfg-if",+ "js-sys",+ "libc",+ "r-efi",+ "rand_core",+ "wasm-bindgen",+]++[[package]]+name = "hashbrown"+version = "0.17.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"++[[package]]+name = "http"+version = "1.5.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0"+dependencies = [+ "bytes",+ "itoa",+]++[[package]]+name = "http-body"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ca2a8f2913ee65f60facd6a5905613afaa448497a0230cc41ce022d93290bc2c"+dependencies = [+ "bytes",+ "http",+]++[[package]]+name = "http-body-util"+version = "0.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23169fe34a5fbcdd3f3862e78fb9b6fccd5f02a6dc6f732547005d45631ce71c"+dependencies = [+ "bytes",+ "futures-core",+ "http",+ "http-body",+ "pin-project-lite",+]++[[package]]+name = "httparse"+version = "1.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87"++[[package]]+name = "httpdate"+version = "1.0.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"++[[package]]+name = "hyper"+version = "1.11.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "27b501faa50e7a26c3d3560ca625132f4078a17771f4810baf70475ae48cbe43"+dependencies = [+ "atomic-waker",+ "bytes",+ "futures-channel",+ "futures-core",+ "http",+ "http-body",+ "httparse",+ "itoa",+ "pin-project-lite",+ "smallvec",+ "tokio",+ "want",+]++[[package]]+name = "hyper-rustls"+version = "0.27.10"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "dfa8e654703247911e29c23fbeaa261834bd9bb74efba2f9acddc37bfb127f53"+dependencies = [+ "http",+ "hyper",+ "hyper-util",+ "rustls",+ "tokio",+ "tokio-rustls",+ "tower-service",+ "webpki-roots",+]++[[package]]+name = "hyper-util"+version = "0.1.20"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "96547c2556ec9d12fb1578c4eaf448b04993e7fb79cbaad930a656880a6bdfa0"+dependencies = [+ "base64",+ "bytes",+ "futures-channel",+ "futures-util",+ "http",+ "http-body",+ "hyper",+ "ipnet",+ "libc",+ "percent-encoding",+ "pin-project-lite",+ "socket2",+ "system-configuration",+ "tokio",+ "tower-service",+ "tracing",+ "windows-registry",+]++[[package]]+name = "icu_collections"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fa68d21081c4a05d5a901a1c62add574c77048b6a1c67be3b50ce0b60d4ca513"+dependencies = [+ "displaydoc",+ "potential_utf",+ "utf8_iter",+ "yoke",+ "zerofrom",+ "zerovec",+]++[[package]]+name = "icu_locale_core"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d56e28588da92eee5c3201a6eff33fabdd49b62269c8938d4ff050ce4d900deb"+dependencies = [+ "displaydoc",+ "litemap",+ "tinystr",+ "writeable",+ "zerovec",+]++[[package]]+name = "icu_normalizer"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "12f9cf5f235641ed274641dd81c3f28d870e276763d0797aeeab72317b1c646f"+dependencies = [+ "icu_collections",+ "icu_normalizer_data",+ "icu_properties",+ "icu_provider",+ "smallvec",+ "zerovec",+]++[[package]]+name = "icu_normalizer_data"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1563da1ed3e0b3bf3d74c9b85917ac9c56464d2f57242270c09c9e752f8021a0"++[[package]]+name = "icu_properties"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7e7ca276ad3145661a65914e6daf131ca5120cd3dcee8f8f3214b8875184a148"+dependencies = [+ "displaydoc",+ "icu_collections",+ "icu_locale_core",+ "icu_properties_data",+ "icu_provider",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "icu_properties_data"+version = "2.3.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e590f038c1464a96894fd6d10127e90a8be4509f56ff7ecef851b15cee0b7caa"++[[package]]+name = "icu_provider"+version = "2.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d27bbb9d3abbefac45d55f647c9de1d44aafcd1186eb91879afef17c396c3e73"+dependencies = [+ "displaydoc",+ "icu_locale_core",+ "writeable",+ "yoke",+ "zerofrom",+ "zerotrie",+ "zerovec",+]++[[package]]+name = "idna"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de"+dependencies = [+ "idna_adapter",+ "smallvec",+ "utf8_iter",+]++[[package]]+name = "idna_adapter"+version = "1.2.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714"+dependencies = [+ "icu_normalizer",+ "icu_properties",+]++[[package]]+name = "indexmap"+version = "2.14.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"+dependencies = [+ "equivalent",+ "hashbrown",+]++[[package]]+name = "ipnet"+version = "2.12.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"++[[package]]+name = "itoa"+version = "1.0.18"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"++[[package]]+name = "js-sys"+version = "0.3.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5"+dependencies = [+ "cfg-if",+ "futures-util",+ "wasm-bindgen",+]++[[package]]+name = "libc"+version = "0.2.190"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"++[[package]]+name = "linux-raw-sys"+version = "0.12.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53"++[[package]]+name = "litemap"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"++[[package]]+name = "log"+version = "0.4.34"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"++[[package]]+name = "lru-slab"+version = "0.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4050469837a6ff301cd14c1f8f24f88549e6d548f24f64e2148eb0f72cebc51f"++[[package]]+name = "memchr"+version = "2.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"++[[package]]+name = "mio"+version = "1.2.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"+dependencies = [+ "libc",+ "wasi",+ "windows-sys 0.61.2",+]++[[package]]+name = "nix"+version = "0.31.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf20d2fde8ff38632c426f1165ed7436270b44f199fc55284c38276f9db47c3d"+dependencies = [+ "bitflags",+ "cfg-if",+ "cfg_aliases",+ "libc",+]++[[package]]+name = "once_cell"+version = "1.21.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"++[[package]]+name = "percent-encoding"+version = "2.3.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220"++[[package]]+name = "pin-project-lite"+version = "0.2.17"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"++[[package]]+name = "potential_utf"+version = "0.1.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661"+dependencies = [+ "zerovec",+]++[[package]]+name = "proc-macro2"+version = "1.0.107"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "quinn"+version = "0.11.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4051e23e9185c255a7e33ef59cdbca87a22d359052eecd22fc6b901fb37d9d11"+dependencies = [+ "bytes",+ "cfg_aliases",+ "pin-project-lite",+ "quinn-proto",+ "quinn-udp",+ "rustc-hash",+ "rustls",+ "socket2",+ "thiserror",+ "tokio",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-proto"+version = "0.11.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0e750cca55fe4f0439a15d0bb529da9651e79993e8e72c61a899a36d462befbe"+dependencies = [+ "bytes",+ "getrandom 0.4.3",+ "lru-slab",+ "rand",+ "rand_pcg",+ "ring",+ "rustc-hash",+ "rustls",+ "rustls-pki-types",+ "slab",+ "thiserror",+ "tinyvec",+ "tracing",+ "web-time",+]++[[package]]+name = "quinn-udp"+version = "0.5.16"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "af66907df18639dcf4db56ca65490cabc4b27a97dbadd96f2926cca73298f016"+dependencies = [+ "cfg_aliases",+ "libc",+ "once_cell",+ "socket2",+ "tracing",+ "windows-sys 0.61.2",+]++[[package]]+name = "quote"+version = "1.0.47"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"+dependencies = [+ "proc-macro2",+]++[[package]]+name = "r-efi"+version = "6.0.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"++[[package]]+name = "rand"+version = "0.10.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "65c9fb96cbc91e3478eaae79a69fcd3f1ae4ad052e471fe6732fff548984b4af"+dependencies = [+ "chacha20",+ "getrandom 0.4.3",+ "rand_core",+]++[[package]]+name = "rand_core"+version = "0.10.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63b8176103e19a2643978565ca18b50549f6101881c443590420e4dc998a3c69"++[[package]]+name = "rand_pcg"+version = "0.10.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "caa0f4137e1c0a72f4c651489402276c8e8e1cf081f3b0ba156d2cbeef09e86a"+dependencies = [+ "rand_core",+]++[[package]]+name = "reqwest"+version = "0.12.28"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "eddd3ca559203180a307f12d114c268abf583f59b03cb906fd0b3ff8646c1147"+dependencies = [+ "base64",+ "bytes",+ "futures-core",+ "futures-util",+ "http",+ "http-body",+ "http-body-util",+ "hyper",+ "hyper-rustls",+ "hyper-util",+ "js-sys",+ "log",+ "percent-encoding",+ "pin-project-lite",+ "quinn",+ "rustls",+ "rustls-pki-types",+ "serde",+ "serde_json",+ "serde_urlencoded",+ "sync_wrapper",+ "tokio",+ "tokio-rustls",+ "tokio-util",+ "tower",+ "tower-http",+ "tower-service",+ "url",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "wasm-streams",+ "web-sys",+ "webpki-roots",+]++[[package]]+name = "ring"+version = "0.17.14"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7"+dependencies = [+ "cc",+ "cfg-if",+ "getrandom 0.2.17",+ "libc",+ "untrusted",+ "windows-sys 0.52.0",+]++[[package]]+name = "rustc-hash"+version = "2.1.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d"++[[package]]+name = "rustix"+version = "1.1.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d"+dependencies = [+ "bitflags",+ "errno",+ "libc",+ "linux-raw-sys",+ "windows-sys 0.61.2",+]++[[package]]+name = "rustls"+version = "0.23.45"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0d41d731c7d2f962d1ccc364cec258de3c0e93b38c2fb3ba97ac74513048d634"+dependencies = [+ "once_cell",+ "ring",+ "rustls-pki-types",+ "rustls-webpki",+ "subtle",+ "zeroize",+]++[[package]]+name = "rustls-pki-types"+version = "1.15.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96"+dependencies = [+ "web-time",+ "zeroize",+]++[[package]]+name = "rustls-webpki"+version = "0.103.15"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f3c3cf1d8b1e7d4927e2d154c3fcb02979afb9939629c62cd9048d4f07b60ac2"+dependencies = [+ "ring",+ "rustls-pki-types",+ "untrusted",+]++[[package]]+name = "rustversion"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f"++[[package]]+name = "ryu"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"++[[package]]+name = "serde"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba"+dependencies = [+ "serde_core",+ "serde_derive",+]++[[package]]+name = "serde_core"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"+dependencies = [+ "serde_derive",+]++[[package]]+name = "serde_derive"+version = "1.0.229"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "serde_json"+version = "1.0.151"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c841b55ecdae098c80dcae9cf767f6f8a0c2cdb3416bbef72181df4d0fe73f14"+dependencies = [+ "indexmap",+ "itoa",+ "memchr",+ "serde",+ "serde_core",+ "zmij",+]++[[package]]+name = "serde_urlencoded"+version = "0.7.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd"+dependencies = [+ "form_urlencoded",+ "itoa",+ "ryu",+ "serde",+]++[[package]]+name = "shlex"+version = "2.0.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"++[[package]]+name = "signal-hook-registry"+version = "1.4.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c4db69cba1110affc0e9f7bcd48bbf87b3f4fc7c61fc9155afd4c469eb3d6c1b"+dependencies = [+ "errno",+ "libc",+]++[[package]]+name = "slab"+version = "0.4.12"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"++[[package]]+name = "smallvec"+version = "1.16.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5b3dc8af474f516a851ff4bd12db780f948b9250ad37211e4eec0bccea54e01b"++[[package]]+name = "socket2"+version = "0.6.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c3d1e2c7f27f8d4cb10542a02c49005dbd6e93095799d6f3be745fae9f8fedd4"+dependencies = [+ "libc",+ "windows-sys 0.61.2",+]++[[package]]+name = "stable_deref_trait"+version = "1.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"++[[package]]+name = "subtle"+version = "2.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"++[[package]]+name = "syn"+version = "3.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"+dependencies = [+ "proc-macro2",+ "quote",+ "unicode-ident",+]++[[package]]+name = "sync_wrapper"+version = "1.0.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"+dependencies = [+ "futures-core",+]++[[package]]+name = "synstructure"+version = "0.14.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "system-configuration"+version = "0.7.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a13f3d0daba03132c0aa9767f98351b3488edc2c100cda2d2ec2b04f3d8d3c8b"+dependencies = [+ "bitflags",+ "core-foundation",+ "system-configuration-sys",+]++[[package]]+name = "system-configuration-sys"+version = "0.6.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"+dependencies = [+ "core-foundation-sys",+ "libc",+]++[[package]]+name = "tempfile"+version = "3.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"+dependencies = [+ "fastrand",+ "getrandom 0.4.3",+ "once_cell",+ "rustix",+ "windows-sys 0.61.2",+]++[[package]]+name = "thiserror"+version = "2.0.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"+dependencies = [+ "thiserror-impl",+]++[[package]]+name = "thiserror-impl"+version = "2.0.21"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "tinystr"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b1e27c91459209c2986af3dcf603a5a74a4368754ce37414f59acc971167f643"+dependencies = [+ "displaydoc",+ "zerovec",+]++[[package]]+name = "tinyvec"+version = "1.13.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee"++[[package]]+name = "tokio"+version = "1.53.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044"+dependencies = [+ "bytes",+ "libc",+ "mio",+ "pin-project-lite",+ "signal-hook-registry",+ "socket2",+ "tokio-macros",+ "windows-sys 0.61.2",+]++[[package]]+name = "tokio-macros"+version = "2.7.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "tokio-rustls"+version = "0.26.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "c9cc2678c2cdd569ef8215e2afd7954ada2ae20b4fdd2c5fe6139a3b02d105db"+dependencies = [+ "rustls",+ "tokio",+]++[[package]]+name = "tokio-util"+version = "0.7.19"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "494815d09bf52b5548659851081238f0ca39ff638363907596da739561c62c52"+dependencies = [+ "bytes",+ "futures-core",+ "futures-sink",+ "pin-project-lite",+ "tokio",+]++[[package]]+name = "tower"+version = "0.5.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ebe5ef63511595f1344e2d5cfa636d973292adc0eec1f0ad45fae9f0851ab1d4"+dependencies = [+ "futures-core",+ "futures-util",+ "pin-project-lite",+ "sync_wrapper",+ "tokio",+ "tower-layer",+ "tower-service",+]++[[package]]+name = "tower-http"+version = "0.6.11"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4cfcf7e2740e6fc6d4d688b4ef00650406bb94adf4731e43c096c3a19fe40840"+dependencies = [+ "bitflags",+ "bytes",+ "futures-util",+ "http",+ "http-body",+ "pin-project-lite",+ "tower",+ "tower-layer",+ "tower-service",+ "url",+]++[[package]]+name = "tower-layer"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"++[[package]]+name = "tower-service"+version = "0.3.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3"++[[package]]+name = "tracing"+version = "0.1.44"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"+dependencies = [+ "pin-project-lite",+ "tracing-core",+]++[[package]]+name = "tracing-core"+version = "0.1.36"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"+dependencies = [+ "once_cell",+]++[[package]]+name = "try-lock"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"++[[package]]+name = "unicode-ident"+version = "1.0.27"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"++[[package]]+name = "untrusted"+version = "0.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"++[[package]]+name = "url"+version = "2.5.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed"+dependencies = [+ "form_urlencoded",+ "idna",+ "percent-encoding",+ "serde",+]++[[package]]+name = "utf8_iter"+version = "1.0.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"++[[package]]+name = "uuid"+version = "1.27.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "97277d36b9c3ace13e58fa6e753f8b0bbbf302a18dd193240d70f9e29681059a"+dependencies = [+ "getrandom 0.4.3",+ "js-sys",+ "serde_core",+ "wasm-bindgen",+]++[[package]]+name = "want"+version = "0.3.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e"+dependencies = [+ "try-lock",+]++[[package]]+name = "wasi"+version = "0.11.1+wasi-snapshot-preview1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"++[[package]]+name = "wasm-bindgen"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409"+dependencies = [+ "cfg-if",+ "once_cell",+ "rustversion",+ "wasm-bindgen-macro",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-futures"+version = "0.4.79"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e"+dependencies = [+ "js-sys",+ "tokio",+ "wasm-bindgen",+]++[[package]]+name = "wasm-bindgen-macro"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535"+dependencies = [+ "quote",+ "wasm-bindgen-macro-support",+]++[[package]]+name = "wasm-bindgen-macro-support"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7"+dependencies = [+ "bumpalo",+ "proc-macro2",+ "quote",+ "syn",+ "wasm-bindgen-shared",+]++[[package]]+name = "wasm-bindgen-shared"+version = "0.2.129"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6"+dependencies = [+ "unicode-ident",+]++[[package]]+name = "wasm-streams"+version = "0.4.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "15053d8d85c7eccdbefef60f06769760a563c7f0a9d6902a13d35c7800b0ad65"+dependencies = [+ "futures-util",+ "js-sys",+ "wasm-bindgen",+ "wasm-bindgen-futures",+ "web-sys",+]++[[package]]+name = "web-sys"+version = "0.3.106"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "web-time"+version = "1.1.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb"+dependencies = [+ "js-sys",+ "wasm-bindgen",+]++[[package]]+name = "webpki-roots"+version = "1.0.9"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7dcd9d09a39985f5344844e66b0c530a33843579125f23e21e9f0f220850f22a"+dependencies = [+ "rustls-pki-types",+]++[[package]]+name = "windows-link"+version = "0.2.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"++[[package]]+name = "windows-registry"+version = "0.6.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "02752bf7fbdcce7f2a27a742f798510f3e5ad88dbe84871e5168e2120c3d5720"+dependencies = [+ "windows-link",+ "windows-result",+ "windows-strings",+]++[[package]]+name = "windows-result"+version = "0.4.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7781fa89eaf60850ac3d2da7af8e5242a5ea78d1a11c49bf2910bb5a73853eb5"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-strings"+version = "0.5.1"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "7837d08f69c77cf6b07689544538e017c1bfcf57e34b4c0ff58e6c2cd3b37091"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-sys"+version = "0.52.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"+dependencies = [+ "windows-targets",+]++[[package]]+name = "windows-sys"+version = "0.61.2"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"+dependencies = [+ "windows-link",+]++[[package]]+name = "windows-targets"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"+dependencies = [+ "windows_aarch64_gnullvm",+ "windows_aarch64_msvc",+ "windows_i686_gnu",+ "windows_i686_gnullvm",+ "windows_i686_msvc",+ "windows_x86_64_gnu",+ "windows_x86_64_gnullvm",+ "windows_x86_64_msvc",+]++[[package]]+name = "windows_aarch64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"++[[package]]+name = "windows_aarch64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"++[[package]]+name = "windows_i686_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"++[[package]]+name = "windows_i686_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"++[[package]]+name = "windows_i686_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"++[[package]]+name = "windows_x86_64_gnu"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"++[[package]]+name = "windows_x86_64_gnullvm"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"++[[package]]+name = "windows_x86_64_msvc"+version = "0.52.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"++[[package]]+name = "writeable"+version = "0.6.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc"++[[package]]+name = "yoke"+version = "0.8.3"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "709fe23a0424b6a435d82152b1bd3fdfb0833487d5fa90d05d42762a9891fef5"+dependencies = [+ "stable_deref_trait",+ "yoke-derive",+ "zerofrom",+]++[[package]]+name = "yoke-derive"+version = "0.8.4"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+ "synstructure",+]++[[package]]+name = "zerofrom"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272"+dependencies = [+ "zerofrom-derive",+]++[[package]]+name = "zerofrom-derive"+version = "0.1.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+ "synstructure",+]++[[package]]+name = "zeroize"+version = "1.9.0"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "e13c156562582aa81c60cb29407084cdb54c4164760106ab78e6c5b0858cf64e"++[[package]]+name = "zerotrie"+version = "0.2.5"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f"+dependencies = [+ "displaydoc",+ "yoke",+ "zerofrom",+]++[[package]]+name = "zerovec"+version = "0.11.8"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "bb0464e17806c1d976d5cba29399c7f08e516e279e2ba493f63123b5fca67dd8"+dependencies = [+ "yoke",+ "zerofrom",+ "zerovec-derive",+]++[[package]]+name = "zerovec-derive"+version = "0.11.6"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "34df6fc39dbd26ddc9c10e6a2984476e13acce22e64e4487636ef494369225da"+dependencies = [+ "proc-macro2",+ "quote",+ "syn",+]++[[package]]+name = "zmij"+version = "1.0.23"+source = "registry+https://github.com/rust-lang/crates.io-index"+checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"diff --git a/scripts/ai-proxy-12277/Cargo.toml b/scripts/ai-proxy-12277/Cargo.tomlnew file mode 100644index 0000000000..c32a3e2b0d--- /dev/null+++ b/scripts/ai-proxy-12277/Cargo.toml@@ -0,0 +1,17 @@+[package]+name = "dbx-ai-proxy-12277-proof"+version = "0.1.0"+edition = "2021"+publish = false++[workspace]++[dependencies]+dbx-ai-provider = { path = "../../crates/dbx-ai-provider" }+reqwest = { version = "=0.12.28", default-features = false, features = ["rustls-tls", "system-proxy"] }+hyper-util = "=0.1.20"+serde_json = "1"+tokio = { version = "1", features = ["rt", "macros"] }++[target.'cfg(windows)'.dependencies]+windows-sys = { version = "=0.61.2", features = ["Win32_System_Registry", "Win32_Foundation", "Win32_Security"] }diff --git a/scripts/ai-proxy-12277/README.md b/scripts/ai-proxy-12277/README.mdnew file mode 100644index 0000000000..edc095fff1--- /dev/null+++ b/scripts/ai-proxy-12277/README.md@@ -0,0 +1,222 @@+# Issue #12277:通过 aliyun 复现本地 AI 请求误走代理++2026-10-16 在 Windows 上直接调用+`dbx_ai_provider::ai::build_ai_http_client()` 完成修复前复现和修复后验证。+客户端构建显式启用 `reqwest/system-proxy`,固定 reqwest 0.12.28、hyper-util 0.1.20。+其他依赖由本目录独立的 Cargo.lock 固定,不修改主工作区依赖。++## 拓扑和生命周期++- `ssh aliyun` 在服务器内存中执行 `remote_mock.py`,不上传文件、不安装软件。+- 模型 mock 和返回 502 的代理 mock 均绑定服务器 `127.0.0.1` 随机端口。+- SSH 转发到 Windows `127.0.0.1` 和 `[::1]`,客户端请求地址仍是 loopback。+- 每个请求启动独立客户端进程,只向该进程传入代理环境变量。+- 每例同时记录 HTTP 状态、TCP peer、服务器命中角色/方法/路径。+- SSH stdin 关闭时 mock 退出;驱动程序在 finally 中关闭隧道和远端会话。++## 运行++在仓库根目录用 PowerShell 7 执行(需要可用的 Windows Rust 编译工具链):++```powershell+cargo build --offline --locked --manifest-path scripts\ai-proxy-12277\Cargo.toml --target-dir target\ai-proxy-12277+python scripts\ai-proxy-12277\run_proof.py+python scripts\ai-proxy-12277\run_proof.py --suite remaining+```++默认 `--expect fixed` 验证修复后的行为;在修复前代码上运行时,使用+`--expect baseline` 验证旧缺陷。两个套件分别是 13 例环境变量场景和 49 例补充场景。+新报告分别写入 `{fixed|baseline}-{environment|remaining}-results.json`,+不会覆盖下面列出的首轮历史报告。++本机 GNU 工具链需要额外的链接环境。本次构建前使用了仓库已有的+`target\sqlserver-7542-tools\rust-env.ps1`,这不是运行客户端所需条件。++## 修复前实际结果(历史证据)++运行时间、随机端口和逐例原始证据见+`target/ai-proxy-12277/proof-results.json`。++| 场景 | 状态 | 服务端实际命中 |+| --- | --- | --- |+| 清空进程代理环境变量,AI 代理关闭 | 200 | 模型 1,代理 0 |+| 设置 HTTP_PROXY 等,AI 代理关闭,IPv4 | 502 | 模型 0,代理 1 |+| 同上,开启 AI 显式代理但 loopback 跳过该配置 | 502 | 模型 0,代理 1 |+| 增加准确 NO_PROXY=127.0.0.1,localhost,::1 | 200 | 模型 1,代理 0 |+| NO_PROXY=127.* | 502 | 模型 0,代理 1 |+| NO_PROXY=127.0.0.0/8 | 200 | 模型 1,代理 0 |+| 设置代理环境变量,目标 localhost | 502 | 模型 0,代理 1 |+| 设置代理环境变量,目标 [::1] | 502 | 模型 0,代理 1 |+| IPv6 增加 NO_PROXY=::1 | 200 | 模型 1,代理 0 |+| 设置代理环境变量,POST stream=true | 502 | 模型 0,代理 1 |+| 同上,增加准确 NO_PROXY | 200 | 模型 1,代理 0,收到 SSE 数据 |+| 对照:reqwest builder.no_proxy(),保留代理环境变量 | 200 | 模型 1,代理 0 |+| 对照:公网域名配置显式代理 | 502 | 模型 0,代理 1 |++驱动程序退出码 0;13 个场景均符合预期。+其中预期 502 表示成功复现缺陷或验证可控代理路由,并不表示修复通过。++## 系统代理与完整 AI 入口补充验证(修复前)++`--suite remaining` 使用 Windows `RegOverridePredefKey` 将**当前测试进程**的+HKCU 映射到独立的临时易失性注册表键。底层 hyper-util 仍真实读取+`Software\Microsoft\Windows\CurrentVersion\Internet Settings` 中的+`ProxyEnable`、`ProxyServer` 和 `ProxyOverride`。其他进程读取原始注册表,+测试前后快照检查本机真实代理配置未改变。+API 的进程隔离与恢复语义见 [Microsoft 文档](https://learn.microsoft.com/en-us/windows/win32/api/winreg/nf-winreg-regoverridepredefkey)。++补充矩阵覆盖:++- 清空代理环境变量,仅使用 Windows 系统代理;禁用系统代理作对照。+- ProxyOverride 无绕过规则、`127.*`、准确地址、CIDR 和 localhost。+- IPv4/IPv6,流式/非流式,NO_PROXY 与系统绕过规则组合。+- 使用两个独立代理 mock 区分系统代理、环境代理和显式代理的优先级。+- DBX 完整 `list_models_core`、`test_connection_core`、`complete`、`stream` 入口;+ 每个入口验证系统代理 IPv4/IPv6 失败和直连成功、环境代理失败和直连成功。+- 成功的流式入口检查解析后的文字为 `ok`,且有 done chunk;非流式检查结果为 `ok`。++原始证据在 `target/ai-proxy-12277/remaining-results.json`,执行日志在+`target/ai-proxy-12277/remaining-run.log`。++补充矩阵实际运行 **49 例(25 例路由组合 + 24 例完整 AI 入口)**,+49 例均符合预期,驱动退出码 0。加上首轮 13 例,共记录 62 个场景。+此处“符合预期”包含成功复现缺陷,并不表示生产代码已修复。++| 补充验证 | 实际观察 |+| --- | --- |+| 环境变量为空,系统代理启用,ProxyOverride=127.* | 502,模型 0 次、系统代理 1 次 |+| 系统绕过规则为准确 IPv4、IPv6 或 IPv4 CIDR | 200,直达模型 |+| localhost 在系统绕过列表中 | 200;移除绕过后 502 |+| 系统代理关闭 | IPv4 和 IPv6 均直连 200 |+| 环境 NO_PROXY 准确匹配,保留系统代理 | IPv4 和 IPv6 均直连 200 |+| IPv4 配置显式代理,系统绕过准确匹配 | 显式代理被跳过,模型 200 |+| IPv6 配置显式代理,即使系统绕过准确匹配 | 仍命中显式代理,502 |+| 公网目标同时配置系统代理和显式代理 | 命中显式代理;没有显式代理时命中系统代理 |+| 同时配置环境代理和系统代理 | 命中环境代理 |+| 四个完整 AI 入口,系统代理无有效绕过或环境代理无 NO_PROXY | 均失败,命中代理,模型未命中 |+| 四个完整 AI 入口,准确系统绕过或准确 NO_PROXY | 均成功,返回模型列表、连接成功、聊天文字和完成事件 |++清理检查:三个远端随机端口均拒绝连接;`HKCU\Software` 下+`DBXIssue12277-*` 临时键剩余 0 个;真实系统代理配置前后快照一致。++## 修复前结论++修复前实现只跳过添加显式代理,没有在本地目标场景关闭自动代理发现。+AI 代理关闭不阻止本次请求采用环境变量代理;TCP peer 和远端命中记录共同证明了路由。+准确 NO_PROXY 和 no_proxy() 对照证明模型及 SSH 转发正常。++第一轮 13 例仅验证环境变量代理;补充矩阵验证 Windows 系统代理注册表读取路径。+本机实际 ProxyEnable 原始值为 0,没有更改真实 Internet Settings 或 Clash 配置。+只在专用命名空间创建临时注册表键,并在各测试进程退出前恢复映射、删除临时键。++另确认 IPv6 回环识别缺口:`reqwest::Url::host_str()` 对 IPv6 返回 `[::1]`,+原先的 `host.parse::<IpAddr>()` 不接受方括号,因此本地 IPv6 地址没有跳过显式代理。+即使系统 ProxyOverride 准确包含 `::1`,显式代理仍收到这类请求;+相同配置的 IPv4 请求会直连。原始结果同时记录 url_host 和实际命中代理角色。++模型列表入口先解码 JSON;遇到代理返回纯文本 502 时,错误可能表现为 JSON 解码失败,+而不是带 502 的错误文字。用服务端命中记录确认路由,避免仅按错误字符串判定。++## 修复内容与验收++- 解析 IPv6 主机时先去除配对方括号,再判断 IP 是否为回环地址。+- 回环目标在实际客户端构造时调用 `no_proxy()`,同时禁用环境、系统和显式代理。+- 非回环目标保留原有代理逻辑;未增加 DNS 查询或私网地址自动绕过。+- 永久回归测试使用独立子进程和本地模型/代理 mock;测试依赖显式启用 system-proxy。+ 检查响应状态、TCP peer、模型与代理命中次数。旧代码四组回环测试失败、公网对照通过。++修复后验收证据:++- `target/ai-proxy-12277/provider-tests-green.log`:provider 完整测试。+- `target/ai-proxy-12277/fixed-environment-results.json`:13 例环境变量场景。+- `target/ai-proxy-12277/fixed-remaining-results.json`:49 例系统代理及完整 AI 入口场景。+- `target/ai-proxy-12277/regression-red.log`:修复前回归失败记录。++修复后预期:全部回环请求直达模型,普通请求返回 200;四个完整 AI 入口返回正确数据。+公网代理对照仍返回 mock 的 502,并命中预期代理,这表示公网代理路由得到保留。+原有 `environment-over-system-priority` 场景的目标也是回环地址,修复后应直连,+不再用它断言环境代理优先级;公网环境/显式代理优先级由永久回归测试验证。++修复后实际运行结果:266 个单元测试和 5 组真实请求回归测试通过。+保留 4 个原有忽略测试;额外 1 个忽略项是由父测试显式启动的子进程入口。+阿里云两轮验收 **13/13 + 49/49 全部通过**,旧复现结果保持原样。+全部本地请求命中模型而非代理,四个完整 AI 入口均成功,公网代理对照保留原行为。+独立代码审查未发现正确性问题。++`target/ai-proxy-12277/fixed-cleanup-verification.json` 记录清理验收:+真实代理配置前后一致、临时注册表键为 0,远端 mock 和本地隧道端口均已关闭。++第一轮流式场景仅调用真实构造器;补充矩阵调用完整聊天流解析入口。+上述 62 例没有操作真实 Clash/TUN;后续真实 FlClash 验证见下节。++## 保持联网配置原样的真实 FlClash 验证++本机运行 FlClash.exe(PID 11604)和 FlClashCore.exe(PID 4756),+核心实际监听 `127.0.0.1:10433`。测试时真实 Windows `ProxyEnable=0`,+测试终端的 HTTP_PROXY/HTTPS_PROXY 指向该端口,NO_PROXY 原始值包含回环地址。++```powershell+python scripts\ai-proxy-12277\run_proof.py --suite real-clash --real-proxy http://127.0.0.1:10433+```++本次 30 例全部通过:++- 1 例强制经过真实代理的 reqwest 对照:TCP peer 为 `127.0.0.1:10433`,+ FlClash 将请求转发到模型,返回 200。此对照未调用 DBX 构造器。+- 12 例 DBX 实际请求:IPv4、localhost、IPv6 分别覆盖继承原始环境、+ 子进程代理指向真实 FlClash 且移除 NO_PROXY、显式代理、系统代理读取链路。+- 5 例补充组合:环境 NO_PROXY=127.*、系统无绕过规则的 IPv4/IPv6、+ 两种 IP 的 stream=true 请求。+- 12 例完整 AI 入口:模型列表、连接测试、普通聊天和流式聊天,分别覆盖+ 环境代理 IPv4、系统代理 IPv4、显式代理 IPv6,均返回正确内容。++修复后的普通请求 TCP peer 均是模型转发端口,而非真实 Clash 端口;+全部 DBX 请求均有且仅有一次模型命中。流式入口解析出 `ok` 和 done 事件。+系统代理场景只在测试进程中映射隔离注册表,启用后指向**真实 FlClash**,+未修改真实 Windows 代理开关。++测试没有退出/重启 FlClash,也没有切换节点、系统代理或 TUN。+前后快照确认 FlClash 进程及创建时间、10433 端口归属和真实代理配置一致。+远端服务、本地模型转发及临时注册表已清理。++证据:++- `target/ai-proxy-12277/fixed-real-clash-results.json`:30 例原始结果。+- `target/ai-proxy-12277/real-clash-state-before.json` 和 `real-clash-state-after.json`:状态快照。+- `target/ai-proxy-12277/real-clash-verification.json`:结果、配置一致性与清理验证。++边界:本机 FlClash 对强制代理对照返回 200,因此本轮未重现原反馈的 502;+验证的是修复后本地请求确实不经过实际运行的 Clash。+上述 30 例没有操作 DBX 桌面 GUI、真实模型、API Key 或数据库连接,也未验证 TUN 开关切换。++## Windows 桌面 GUI 验证(2026-10-17 至 2026-10-18)++使用包含修复的本地 Tauri 桌面构建,连接实际 Rust 后端和 Vite 开发前端,+数据目录与 WebView profile 均隔离到 `target/ai-proxy-12277/`。模型为本机 HTTP/SSE mock,+不使用真实 API Key;临时 SQLite 数据库仅提供 AI 助手要求的连接上下文。++- IPv4:`http://127.0.0.1:13937/v1`,关闭 AI 显式代理。+- IPv6:`http://[::1]:13938/v1`,启用 AI 显式代理并指向未监听的 `http://127.0.0.1:1`。+- 测试应用的 HTTP_PROXY/HTTPS_PROXY/ALL_PROXY 指向真实 FlClash `127.0.0.1:10433`,+ 移除该子进程的 NO_PROXY;没有修改全局环境或 FlClash 配置。+- 两组均通过 GUI 模型发现、连接测试、配置保存和 Ask 流式聊天;聊天显示+ `DBX_GUI_12277_OK: local model responded successfully.`。+- 模型请求日志与应用进程 socket 采样共同确认直连 `127.0.0.1:13937` / `::1:13938`。+ 应用后台更新检查也会连接代理,不能用整个应用是否出现 10433 连接判断 AI 请求路由。++构建命令为 `cargo build --offline -p dbx --no-default-features --features sqlite-bundled`。+该精简构建未启用 os-keyring,最初保存非空代理配置出现 KEY_PROVIDER_UNAVAILABLE;+为测试进程指定独立 DBX_SECRET_KEY_FILE 后保存成功,重启后 IPv6 配置与聊天验证通过。+另一次启动因缺少构建依赖的 DLL 搜索路径返回 0xC0000135,恢复构建环境 PATH 后正常启动。+这两项是测试构建环境处理,没有追加生产代码修改。++证据位于 `target/ai-proxy-12277/`:++- `gui-evidence/`:IPv4/IPv6 连接成功、模型列表、聊天回复截图及对应 UIA 文本。+- `gui-mock-requests.jsonl` 与 `gui-desktop-network.jsonl`:请求及实际 TCP 连接记录。+- `gui-verification.json`:结果汇总;`gui-cleanup.json`:清理检查。++测试应用、模型 mock、Vite 和监控进程已退出,1420/13937/13938 无残留监听,+真实 FlClash 10433 监听仍保留。跨日运行中不以 PID 恒定作为验收条件。+本轮没有切换系统代理、节点或 TUN,也没有使用真实模型;GUI 覆盖流式聊天,+非流式聊天仍由前述核心入口测试覆盖。diff --git a/scripts/ai-proxy-12277/remote_mock.py b/scripts/ai-proxy-12277/remote_mock.pynew file mode 100644index 0000000000..460dca23e7--- /dev/null+++ b/scripts/ai-proxy-12277/remote_mock.py@@ -0,0 +1,63 @@+"""Runs only for the lifetime of its SSH stdin; binds remote loopback only."""+import json+import sys+import threading+from http.server import BaseHTTPRequestHandler, HTTPServer++hits = []+lock = threading.Lock()+++class Handler(BaseHTTPRequestHandler):+ def log_message(self, *args):+ pass++ def respond(self):+ if self.path == '/_stats' and self.server.role == 'model':+ with lock:+ body = json.dumps(hits).encode()+ status, kind = 200, 'application/json'+ else:+ length = int(self.headers.get('Content-Length', '0'))+ payload = {}+ if length:+ raw = self.rfile.read(length)+ try:+ payload = json.loads(raw.decode())+ except (ValueError, UnicodeDecodeError):+ pass+ with lock:+ hits.append({'role': self.server.role, 'method': self.command, 'path': self.path})+ if self.server.role.startswith('proxy'):+ status, kind, body = 502, 'text/plain', b'dbx-12277 mock proxy: request incorrectly routed here'+ elif self.command == 'POST' and payload.get('stream'):+ status, kind, body = 200, 'text/event-stream', b'data: {"choices":[{"delta":{"content":"ok"}}]}\n\ndata: [DONE]\n\n'+ elif self.command == 'POST':+ status, kind = 200, 'application/json'+ body = b'{"id":"proof","object":"chat.completion","choices":[{"index":0,"message":{"role":"assistant","content":"ok"},"finish_reason":"stop"}]}'+ else:+ status, kind = 200, 'application/json'+ body = b'{"object":"list","data":[{"id":"local-repro","object":"model"}]}'+ self.send_response(status)+ self.send_header('Content-Type', kind)+ self.send_header('Content-Length', str(len(body)))+ self.end_headers()+ self.wfile.write(body)++ do_GET = respond+ do_POST = respond+++servers = []+for role in ('model', 'proxy', 'proxy-explicit'):+ server = HTTPServer(('127.0.0.1', 0), Handler)+ server.role = role+ threading.Thread(target=server.serve_forever, daemon=True).start()+ servers.append(server)+print(json.dumps({s.role: s.server_port for s in servers}), flush=True)+try:+ sys.stdin.read()+finally:+ for server in servers:+ server.shutdown()+ server.server_close()diff --git a/scripts/ai-proxy-12277/run_proof.py b/scripts/ai-proxy-12277/run_proof.pynew file mode 100644index 0000000000..56570f29bb--- /dev/null+++ b/scripts/ai-proxy-12277/run_proof.py@@ -0,0 +1,258 @@+"""Windows driver: SSH-hosted mocks, loopback forwards, fresh DBX process per case."""+import base64+import argparse+import datetime+import json+import os+from pathlib import Path+import socket+import subprocess+import time+import urllib.request+import urllib.parse++HERE = Path(__file__).resolve().parent+ROOT = HERE.parent.parent+BINARY = ROOT / 'target/ai-proxy-12277/debug/dbx-ai-proxy-12277-proof.exe'+PROXY_KEYS = {'http_proxy', 'https_proxy', 'all_proxy', 'no_proxy'}+opener = urllib.request.build_opener(urllib.request.ProxyHandler({}))+++def free_port(family=socket.AF_INET):+ with socket.socket(family) as sock:+ sock.bind(('::1' if family == socket.AF_INET6 else '127.0.0.1', 0))+ return sock.getsockname()[1]+++def stats(port):+ with opener.open('http://127.0.0.1:{}/_stats'.format(port), timeout=5) as response:+ return json.load(response)+++def main():+ parser = argparse.ArgumentParser()+ parser.add_argument('--suite', choices=['environment', 'remaining', 'real-clash'], default='environment')+ parser.add_argument('--expect', choices=['baseline', 'fixed'], default='fixed')+ parser.add_argument('--real-proxy', help='Existing local Clash HTTP proxy; never changes Clash configuration')+ args = parser.parse_args()+ suite = args.suite+ import winreg+ settings_path = r'Software\Microsoft\Windows\CurrentVersion\Internet Settings'+ def registry_snapshot():+ values = {}+ with winreg.OpenKey(winreg.HKEY_CURRENT_USER, settings_path) as key:+ for name in ('ProxyEnable', 'ProxyServer', 'ProxyOverride', 'AutoConfigURL'):+ try:+ values[name] = winreg.QueryValueEx(key, name)+ except FileNotFoundError:+ values[name] = None+ return values+ original_settings = registry_snapshot()+ real_peer = None+ if suite == 'real-clash':+ real_url = urllib.parse.urlsplit(args.real_proxy or '')+ if real_url.scheme != 'http' or real_url.hostname != '127.0.0.1' or not real_url.port or real_url.username:+ parser.error('--real-proxy must be an existing unauthenticated http://127.0.0.1:PORT listener')+ if args.expect != 'fixed':+ parser.error('real-clash suite validates fixed behavior only')+ real_peer = '127.0.0.1:{}'.format(real_url.port)+ encoded = base64.b64encode((HERE / 'remote_mock.py').read_bytes()).decode('ascii')+ command = 'python3 -u -c "import base64;exec(base64.b64decode(\'{}\'))"'.format(encoded)+ remote = subprocess.Popen(+ ['ssh', '-T', '-o', 'BatchMode=yes', '-o', 'ConnectTimeout=10', 'aliyun', command],+ stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True, encoding='utf-8')+ tunnel = None+ try:+ line = remote.stdout.readline()+ if not line:+ raise RuntimeError('remote mock startup failed: ' + remote.stderr.read())+ ports = json.loads(line)+ model_port, proxy_port, ipv6_port, explicit_port = free_port(), free_port(), free_port(socket.AF_INET6), free_port()+ tunnel = subprocess.Popen([+ 'ssh', '-N', '-T', '-o', 'BatchMode=yes', '-o', 'ExitOnForwardFailure=yes',+ '-o', 'ConnectTimeout=10',+ '-L', '127.0.0.1:{}:127.0.0.1:{}'.format(model_port, ports['model']),+ '-L', '127.0.0.1:{}:127.0.0.1:{}'.format(proxy_port, ports['proxy']),+ '-L', '[::1]:{}:127.0.0.1:{}'.format(ipv6_port, ports['model']),+ '-L', '127.0.0.1:{}:127.0.0.1:{}'.format(explicit_port, ports['proxy-explicit']),+ 'aliyun'], stdin=subprocess.DEVNULL, stdout=subprocess.PIPE, stderr=subprocess.PIPE)+ for _ in range(100):+ if tunnel.poll() is not None:+ raise RuntimeError('SSH tunnel failed: ' + tunnel.stderr.read().decode())+ try:+ stats(model_port)+ break+ except (OSError, ValueError):+ time.sleep(0.1)+ else:+ raise RuntimeError('SSH tunnel did not become ready')+ endpoint = 'http://127.0.0.1:{}/v1'.format(model_port)+ ipv6_endpoint = 'http://[::1]:{}/v1'.format(ipv6_port)+ proxy = 'http://127.0.0.1:{}'.format(proxy_port)+ explicit_proxy = 'http://127.0.0.1:{}'.format(explicit_port)+ clean_env = {k: v for k, v in os.environ.items() if k.lower() not in PROXY_KEYS and not k.startswith('DBX_PROOF_')}+ proxy_env = dict(clean_env, HTTP_PROXY=proxy, HTTPS_PROXY=proxy, ALL_PROXY=proxy)+ cases = [+ ('baseline-no-env-proxy', endpoint, 'default', clean_env, '', 200, 'model'),+ ('proxy-disabled-ipv4', endpoint, 'default', proxy_env, '', 502, 'proxy'),+ ('explicit-proxy-skipped-ipv4', endpoint, 'explicit', proxy_env, 'invalid proxy url', 502, 'proxy'),+ ('exact-no-proxy-ipv4', endpoint, 'default', dict(proxy_env, NO_PROXY='127.0.0.1,localhost,::1'), '', 200, 'model'),+ ('windows-style-wildcard-env', endpoint, 'default', dict(proxy_env, NO_PROXY='127.*'), '', 502, 'proxy'),+ ('cidr-no-proxy-ipv4', endpoint, 'default', dict(proxy_env, NO_PROXY='127.0.0.0/8'), '', 200, 'model'),+ ('proxy-disabled-localhost', endpoint.replace('127.0.0.1', 'localhost'), 'default', proxy_env, '', 502, 'proxy'),+ ('proxy-disabled-ipv6', ipv6_endpoint, 'default', proxy_env, '', 502, 'proxy'),+ ('exact-no-proxy-ipv6', ipv6_endpoint, 'default', dict(proxy_env, NO_PROXY='::1'), '', 200, 'model'),+ ('stream-proxy-disabled', endpoint, 'stream', proxy_env, '', 502, 'proxy'),+ ('stream-exact-no-proxy', endpoint, 'stream', dict(proxy_env, NO_PROXY='127.0.0.1'), '', 200, 'model'),+ ('no-proxy-builder-control', endpoint, 'direct-control', proxy_env, '', 200, 'model'),+ ('public-explicit-proxy-control', 'http://dbx-repro.invalid/v1', 'explicit', clean_env, proxy, 502, 'proxy'),+ ]+ if suite == 'remaining':+ system_env = dict(clean_env, DBX_PROOF_SYSTEM_PROXY='127.0.0.1:{}'.format(proxy_port))+ wildcard = dict(system_env, DBX_PROOF_PROXY_OVERRIDE='localhost;127.*;10.*;172.16.*;<local>')+ exact = dict(system_env, DBX_PROOF_PROXY_OVERRIDE='localhost;127.0.0.1;::1')+ localhost_endpoint = endpoint.replace('127.0.0.1', 'localhost')+ cases = [+ ('system-no-bypass-ipv4', endpoint, 'default', system_env, '', 502, 'proxy'),+ ('system-wildcard-ipv4', endpoint, 'default', wildcard, '', 502, 'proxy'),+ ('system-exact-ipv4', endpoint, 'default', exact, '', 200, 'model'),+ ('system-cidr-ipv4', endpoint, 'default', dict(system_env, DBX_PROOF_PROXY_OVERRIDE='127.0.0.0/8'), '', 200, 'model'),+ ('system-wildcard-localhost', localhost_endpoint, 'default', wildcard, '', 200, 'model'),+ ('system-no-bypass-localhost', localhost_endpoint, 'default', system_env, '', 502, 'proxy'),+ ('system-no-bypass-ipv6', ipv6_endpoint, 'default', system_env, '', 502, 'proxy'),+ ('system-exact-ipv6', ipv6_endpoint, 'default', exact, '', 200, 'model'),+ ('system-stream-wildcard', endpoint, 'stream', wildcard, '', 502, 'proxy'),+ ('system-stream-exact', endpoint, 'stream', exact, '', 200, 'model'),+ ('system-disabled-ipv4', endpoint, 'default', dict(system_env, DBX_PROOF_SYSTEM_ENABLED='0'), '', 200, 'model'),+ ('system-disabled-ipv6', ipv6_endpoint, 'default', dict(system_env, DBX_PROOF_SYSTEM_ENABLED='0'), '', 200, 'model'),+ ('system-no-proxy-env-ipv4', endpoint, 'default', dict(wildcard, NO_PROXY='127.0.0.1'), '', 200, 'model'),+ ('system-no-proxy-env-ipv6', ipv6_endpoint, 'default', dict(system_env, NO_PROXY='::1'), '', 200, 'model'),+ ('system-no-proxy-builder-control', endpoint, 'direct-control', wildcard, '', 200, 'model'),+ ('system-explicit-loopback-ipv4', endpoint, 'explicit', system_env, explicit_proxy, 502, 'proxy'),+ ('system-explicit-loopback-localhost', localhost_endpoint, 'explicit', system_env, explicit_proxy, 502, 'proxy'),+ ('system-explicit-loopback-ipv6', ipv6_endpoint, 'explicit', system_env, explicit_proxy, 502, 'proxy-explicit'),+ ('system-exact-explicit-ipv4', endpoint, 'explicit', exact, explicit_proxy, 200, 'model'),+ ('system-exact-explicit-ipv6', ipv6_endpoint, 'explicit', exact, explicit_proxy, 502, 'proxy-explicit'),+ ('explicit-only-ipv4', endpoint, 'explicit', dict(system_env, DBX_PROOF_SYSTEM_ENABLED='0'), explicit_proxy, 200, 'model'),+ ('explicit-only-ipv6', ipv6_endpoint, 'explicit', dict(system_env, DBX_PROOF_SYSTEM_ENABLED='0'), explicit_proxy, 502, 'proxy-explicit'),+ ('system-public-proxy', 'http://dbx-repro.invalid/v1', 'default', system_env, '', 502, 'proxy'),+ ('system-public-explicit-priority', 'http://dbx-repro.invalid/v1', 'explicit', system_env, explicit_proxy, 502, 'proxy-explicit'),+ ('environment-over-system-priority', endpoint, 'default', dict(system_env, HTTP_PROXY=explicit_proxy), '', 502, 'proxy-explicit'),+ ]+ for mode in ('core-models', 'core-test', 'core-complete', 'core-stream'):+ for label, url, env, ok, role in [+ ('system-wildcard', endpoint, wildcard, False, 'proxy'),+ ('system-exact', endpoint, exact, True, 'model'),+ ('system-ipv6-no-bypass', ipv6_endpoint, system_env, False, 'proxy'),+ ('system-ipv6-exact', ipv6_endpoint, exact, True, 'model'),+ ('environment-proxy', endpoint, proxy_env, False, 'proxy'),+ ('environment-no-proxy', endpoint, dict(proxy_env, NO_PROXY='127.0.0.1'), True, 'model'),+ ]:+ cases.append((mode + '-' + label, url, mode, env, '', ok, role))+ if suite == 'real-clash':+ real_env = dict(clean_env, HTTP_PROXY=args.real_proxy, HTTPS_PROXY=args.real_proxy, ALL_PROXY=args.real_proxy)+ inherited_env = {k: v for k, v in os.environ.items() if not k.startswith('DBX_PROOF_')}+ system_env = dict(clean_env, DBX_PROOF_SYSTEM_PROXY=real_peer,+ DBX_PROOF_PROXY_OVERRIDE=(original_settings.get('ProxyOverride') or [''])[0])+ cases = [('real-clash-forced-proxy-control', endpoint, 'proxy-control', clean_env, args.real_proxy, None, 'real-clash')]+ urls = [('ipv4', endpoint), ('localhost', endpoint.replace('127.0.0.1', 'localhost')), ('ipv6', ipv6_endpoint)]+ for label, url in urls:+ cases.extend([+ ('real-clash-inherited-' + label, url, 'default', inherited_env, '', 200, 'model'),+ ('real-clash-env-no-bypass-' + label, url, 'default', real_env, '', 200, 'model'),+ ('real-clash-explicit-' + label, url, 'explicit', real_env, args.real_proxy, 200, 'model'),+ ('real-clash-system-reader-' + label, url, 'default', system_env, '', 200, 'model'),+ ])+ cases.extend([+ ('real-clash-env-wildcard', endpoint, 'default', dict(real_env, NO_PROXY='127.*'), '', 200, 'model'),+ ('real-clash-system-no-bypass-ipv4', endpoint, 'default', dict(system_env, DBX_PROOF_PROXY_OVERRIDE=''), '', 200, 'model'),+ ('real-clash-system-no-bypass-ipv6', ipv6_endpoint, 'default', dict(system_env, DBX_PROOF_PROXY_OVERRIDE=''), '', 200, 'model'),+ ('real-clash-stream-ipv4', endpoint, 'stream', real_env, '', 200, 'model'),+ ('real-clash-stream-ipv6', ipv6_endpoint, 'stream', real_env, '', 200, 'model'),+ ])+ for mode in ('core-models', 'core-test', 'core-complete', 'core-stream'):+ for label, url, env in [+ ('env-ipv4', endpoint, real_env),+ ('system-ipv4', endpoint, system_env),+ ('explicit-ipv6', ipv6_endpoint, dict(real_env, DBX_PROOF_EXPLICIT='1')),+ ]:+ cases.append(('real-clash-' + mode + '-' + label, url, mode, env, args.real_proxy, True, 'model'))+ results = []+ for name, url, mode, env, explicit, expected_status, expected_role in cases:+ if args.expect == 'fixed' and mode != 'proxy-control' and url in (endpoint, ipv6_endpoint, endpoint.replace('127.0.0.1', 'localhost')):+ expected_status = True if mode.startswith('core-') else 200+ expected_role = 'model'+ before = len(stats(model_port))+ proc = subprocess.run([str(BINARY), url, mode, explicit], env=env,+ capture_output=True, text=True, encoding='utf-8', timeout=20)+ if proc.returncode or proc.stderr:+ result = {'process_exit': proc.returncode, 'stderr': proc.stderr, 'stdout': proc.stdout}+ else:+ result = json.loads(proc.stdout)+ hits = stats(model_port)[before:]+ result.update(case=name, endpoint=url, hits=hits)+ result['registry_fixture'] = {k: v for k, v in env.items() if k.startswith('DBX_PROOF_')}+ result['proxy_environment'] = {k: v for k, v in env.items() if k.lower() in PROXY_KEYS}+ result['expected_status_or_success'] = expected_status+ result['expected_role'] = expected_role+ transport_ok = len(hits) == 1 and hits[0]['role'] == expected_role+ if mode == 'proxy-control':+ # Prove the real listener was used. Its policy may forward or reject loopback.+ result['observed_expected'] = result.get('peer') == real_peer and isinstance(result.get('status'), int)+ result['observed_expected'] &= (len(hits) == 1 and hits[0]['role'] == 'model') if result.get('status') == 200 else len(hits) == 0+ elif mode.startswith('core-'):+ result['observed_expected'] = result.get('ok') == expected_status and transport_ok+ if expected_status and result.get('ok') is True:+ if mode == 'core-models':+ result['observed_expected'] &= result['result'][0]['id'] == 'local-repro'+ elif mode == 'core-test':+ result['observed_expected'] &= result['result']['success'] is True+ elif mode == 'core-complete':+ result['observed_expected'] &= result['result']['text'] == 'ok'+ else:+ chunks = result['result']['chunks']+ result['observed_expected'] &= ''.join(chunk['delta'] for chunk in chunks) == 'ok' and any(chunk['done'] for chunk in chunks)+ else:+ # Model listing decodes JSON before checking HTTP status, so+ # a plain-text 502 can surface as a decode error instead.+ result['observed_expected'] &= bool(result.get('error'))+ else:+ expected_peer = ('[::1]:{}'.format(ipv6_port) if url == ipv6_endpoint else '127.0.0.1:{}'.format(model_port)) if expected_role == 'model' else '127.0.0.1:{}'.format(explicit_port if expected_role == 'proxy-explicit' else proxy_port)+ result['observed_expected'] = result.get('status') == expected_status and transport_ok and result.get('peer') == expected_peer+ results.append(result)+ print(json.dumps(result, ensure_ascii=False), flush=True)+ report = {+ 'time_utc': datetime.datetime.now(datetime.timezone.utc).isoformat(),+ 'remote': 'aliyun', 'remote_ports': ports,+ 'local_model_port': model_port, 'local_proxy_port': proxy_port,+ 'real_system_proxy_modified': False,+ 'system_proxy_snapshot_before': original_settings,+ 'system_proxy_snapshot_after': registry_snapshot(),+ 'suite': suite,+ 'expectation': args.expect,+ 'real_proxy': args.real_proxy if suite == 'real-clash' else None,+ 'note': 'Real Clash suite uses the already-running local proxy without changing its configuration. System scenarios use actual Windows registry reader with process-local HKCU remapping. No GUI interaction or TUN toggling.',+ 'results': results,+ }+ output = ROOT / ('target/ai-proxy-12277/{}-{}-results.json'.format(args.expect, suite))+ output.write_text(json.dumps(report, ensure_ascii=False, indent=2), encoding='utf-8')+ if not all(result['observed_expected'] for result in results):+ raise RuntimeError('At least one result differs from the expected baseline; inspect ' + str(output))+ if registry_snapshot() != original_settings:+ raise RuntimeError('Real Internet Settings unexpectedly changed')+ print('REPORT=' + str(output), flush=True)+ finally:+ if tunnel is not None:+ tunnel.terminate()+ tunnel.wait(timeout=10)+ if remote.stdin:+ remote.stdin.close()+ try:+ remote.wait(timeout=10)+ except subprocess.TimeoutExpired:+ remote.terminate()+ remote.wait(timeout=10)+++if __name__ == '__main__':+ main()diff --git a/scripts/ai-proxy-12277/src/main.rs b/scripts/ai-proxy-12277/src/main.rsnew file mode 100644index 0000000000..20f3756597--- /dev/null+++ b/scripts/ai-proxy-12277/src/main.rs@@ -0,0 +1,76 @@+use dbx_ai_provider::ai::{build_ai_http_client, AiConfig};++mod registry;++async fn core_call(config: AiConfig, mode: &str) -> serde_json::Value {+ use dbx_ai_provider::ai::{complete, list_models_core, stream, test_connection_core, AiCompletionRequest};+ let request: AiCompletionRequest = serde_json::from_value(serde_json::json!({+ "config": config, "systemPrompt": "", "messages": [{"role":"user","content":"hello"}],+ "maxTokens": 16+ }))+ .unwrap();+ let result = match mode {+ "core-models" => list_models_core(&config).await.map(|models| serde_json::json!(models)),+ "core-test" => test_connection_core(&config).await.map(|result| serde_json::json!(result)),+ "core-complete" => complete(&request).await.map(|text| serde_json::json!({"text":text})),+ "core-stream" => {+ let chunks = std::sync::Mutex::new(Vec::new());+ let cancelled = tokio::sync::Notify::new();+ stream("issue-12277-proof", &request, &cancelled, |chunk| chunks.lock().unwrap().push(chunk))+ .await+ .map(|_| serde_json::json!({"chunks":chunks.into_inner().unwrap()}))+ }+ _ => unreachable!(),+ };+ match result {+ Ok(value) => serde_json::json!({"ok":true,"result":value}),+ Err(error) => serde_json::json!({"ok":false,"error":error}),+ }+}++#[tokio::main(flavor = "current_thread")]+async fn main() -> Result<(), Box<dyn std::error::Error>> {+ let sandbox = registry::RegistrySandbox::from_env()?;+ let args: Vec<String> = std::env::args().collect();+ let endpoint = &args[1];+ let mode = &args[2];+ let config: AiConfig = serde_json::from_value(serde_json::json!({+ "provider": "openai-compatible",+ "endpoint": endpoint,+ "proxyEnabled": mode == "explicit" || std::env::var("DBX_PROOF_EXPLICIT").as_deref() == Ok("1"),+ "proxyUrl": args.get(3).map(String::as_str).unwrap_or(""),+ "model": "local-repro", "maxRetries": 0, "enableThinking": false+ }))?;+ if mode.starts_with("core-") {+ let result = core_call(config, mode).await;+ drop(sandbox);+ println!("{result}");+ return Ok(());+ }+ let client = if mode == "direct-control" {+ reqwest::Client::builder().no_proxy().timeout(std::time::Duration::from_secs(8)).build()?+ } else if mode == "proxy-control" {+ reqwest::Client::builder()+ .proxy(reqwest::Proxy::all(&args[3])?)+ .timeout(std::time::Duration::from_secs(8))+ .build()?+ } else {+ build_ai_http_client(&config, 8)?+ };+ let response = if mode == "stream" {+ client+ .post(format!("{endpoint}/chat/completions"))+ .json(&serde_json::json!({"model":"local-repro","stream":true,"messages":[]}))+ .send()+ .await?+ } else {+ client.get(format!("{endpoint}/models")).send().await?+ };+ let status = response.status().as_u16();+ let peer = response.remote_addr().map(|addr| addr.to_string());+ let body = response.text().await?;+ drop(sandbox);+ let url = reqwest::Url::parse(endpoint)?;+ println!("{}", serde_json::json!({"status":status,"peer":peer,"body":body,"url_host":url.host_str()}));+ Ok(())+}diff --git a/scripts/ai-proxy-12277/src/registry.rs b/scripts/ai-proxy-12277/src/registry.rsnew file mode 100644index 0000000000..81257ef843--- /dev/null+++ b/scripts/ai-proxy-12277/src/registry.rs@@ -0,0 +1,112 @@+//! Redirect HKCU only inside this proof process, using a disposable volatile key.+use std::{io, ptr};+use windows_sys::Win32::System::Registry::*;++fn wide(value: &str) -> Vec<u16> {+ value.encode_utf16().chain(Some(0)).collect()+}++fn checked(status: u32) -> io::Result<()> {+ if status == 0 {+ Ok(())+ } else {+ Err(io::Error::from_raw_os_error(status as i32))+ }+}++pub struct RegistrySandbox {+ key: HKEY,+ path: Vec<u16>,+ redirected: bool,+}++impl RegistrySandbox {+ pub fn from_env() -> io::Result<Option<Self>> {+ let Ok(proxy) = std::env::var("DBX_PROOF_SYSTEM_PROXY") else {+ return Ok(None);+ };+ let stamp = std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).unwrap().as_nanos();+ let path = wide(&format!("Software\\DBXIssue12277-{}-{stamp}", std::process::id()));+ let mut sandbox = Self { key: ptr::null_mut(), path, redirected: false };+ unsafe {+ checked(RegCreateKeyExW(+ HKEY_CURRENT_USER,+ sandbox.path.as_ptr(),+ 0,+ ptr::null(),+ REG_OPTION_VOLATILE,+ KEY_ALL_ACCESS,+ ptr::null(),+ &mut sandbox.key,+ ptr::null_mut(),+ ))?;+ }+ let settings_path = wide("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings");+ let mut settings = ptr::null_mut();+ unsafe {+ checked(RegCreateKeyExW(+ sandbox.key,+ settings_path.as_ptr(),+ 0,+ ptr::null(),+ REG_OPTION_VOLATILE,+ KEY_ALL_ACCESS,+ ptr::null(),+ &mut settings,+ ptr::null_mut(),+ ))?;+ let setup = (|| -> io::Result<()> {+ let enabled =+ if std::env::var("DBX_PROOF_SYSTEM_ENABLED").as_deref() == Ok("0") { 0_u32 } else { 1_u32 };+ checked(RegSetValueExW(+ settings,+ wide("ProxyEnable").as_ptr(),+ 0,+ REG_DWORD,+ enabled.to_le_bytes().as_ptr(),+ 4,+ ))?;+ for (name, value) in [+ ("ProxyServer", proxy),+ ("ProxyOverride", std::env::var("DBX_PROOF_PROXY_OVERRIDE").unwrap_or_default()),+ ] {+ let data = wide(&value);+ checked(RegSetValueExW(+ settings,+ wide(name).as_ptr(),+ 0,+ REG_SZ,+ data.as_ptr().cast(),+ (data.len() * 2) as u32,+ ))?;+ }+ Ok(())+ })();+ RegCloseKey(settings);+ setup?;+ checked(RegOverridePredefKey(HKEY_CURRENT_USER, sandbox.key))?;+ }+ sandbox.redirected = true;+ Ok(Some(sandbox))+ }+}++impl Drop for RegistrySandbox {+ fn drop(&mut self) {+ unsafe {+ if self.redirected {+ if let Err(error) = checked(RegOverridePredefKey(HKEY_CURRENT_USER, ptr::null_mut())) {+ eprintln!("registry mapping restore failed: {error}");+ return;+ }+ }+ if !self.key.is_null() {+ RegCloseKey(self.key);+ // Exact unique proof key only; never the user's Internet Settings key.+ if let Err(error) = checked(RegDeleteTreeW(HKEY_CURRENT_USER, self.path.as_ptr())) {+ eprintln!("temporary registry key cleanup failed: {error}");+ }+ }+ }+ }+}