diff --git a/windows/Cargo.lock b/windows/Cargo.lock index c9ac0ad..5c4c6bb 100644 --- a/windows/Cargo.lock +++ b/windows/Cargo.lock @@ -4980,6 +4980,7 @@ dependencies = [ "ps-ipc", "serde_json", "tokio", + "windows-sys 0.61.2", ] [[package]] diff --git a/windows/crates/ps-client/src/edits.rs b/windows/crates/ps-client/src/edits.rs index ed6f50d..58d8eca 100644 --- a/windows/crates/ps-client/src/edits.rs +++ b/windows/crates/ps-client/src/edits.rs @@ -25,7 +25,7 @@ pub fn link_tag(link: &str) -> String { return t; } } - let host = link.split("://").nth(1).unwrap_or("").split(['@']).last().unwrap_or("").split([':', '/', '?', '#']).next().unwrap_or(""); + let host = link.split("://").nth(1).unwrap_or("").split(['@']).next_back().unwrap_or("").split([':', '/', '?', '#']).next().unwrap_or(""); let t = ps_core::links::subscription::slugify_tag(host); if t.is_empty() { "outbound".into() } else { t } } diff --git a/windows/crates/ps-service/src/api.rs b/windows/crates/ps-service/src/api.rs index dc4ffc3..1e421e6 100644 --- a/windows/crates/ps-service/src/api.rs +++ b/windows/crates/ps-service/src/api.rs @@ -237,13 +237,10 @@ pub async fn handle(req: Request, peer: &Peer, shared: &Shared) -> Response { Request::ConfigSet { mut config, base } => { let mut s = shared.lock().await; - if let Some(base) = base { - if base != s.store.revision { - return Response::err(format!( - "the configuration changed since revision {base} (now {}): read it again", - s.store.revision - )); - } + if let Some(base) = base + && base != s.store.revision + { + return Response::err(format!("the configuration changed since revision {base} (now {}): read it again", s.store.revision)); } unredact(&mut config, s.cfg()); let new: Config = match serde_json::from_value(config) { diff --git a/windows/crates/ps-service/src/install.rs b/windows/crates/ps-service/src/install.rs index dc14d55..b7603bd 100644 --- a/windows/crates/ps-service/src/install.rs +++ b/windows/crates/ps-service/src/install.rs @@ -20,10 +20,10 @@ pub async fn archive(src: &Source, routes: &[fetch::Route], cache: &Path) -> Res std::fs::create_dir_all(cache)?; let key = hex(src.url.as_bytes()); let cached = cache.join(&key[..32]); - if let Ok(data) = std::fs::read(&cached) { - if src.sha256.as_ref().is_none_or(|want| hex(&data) == *want) { - return Ok(data); - } + if let Ok(data) = std::fs::read(&cached) + && src.sha256.as_ref().is_none_or(|want| hex(&data) == *want) + { + return Ok(data); } let mut last = None; for route in routes { diff --git a/windows/crates/ps-service/src/paths.rs b/windows/crates/ps-service/src/paths.rs index 2d1fe84..b01e558 100644 --- a/windows/crates/ps-service/src/paths.rs +++ b/windows/crates/ps-service/src/paths.rs @@ -181,7 +181,7 @@ mod secure { }; let path = wide(root.as_os_str()); // SAFETY: NUL-terminated path; attrs outlives the call. - if unsafe { CreateDirectoryW(path.as_ptr(), &mut attrs) } != 0 { + if unsafe { CreateDirectoryW(path.as_ptr(), &attrs) } != 0 { return Ok(()); } // SAFETY: plain call. diff --git a/windows/crates/ps-service/src/service.rs b/windows/crates/ps-service/src/service.rs index 0dc173e..f3d0718 100644 --- a/windows/crates/ps-service/src/service.rs +++ b/windows/crates/ps-service/src/service.rs @@ -82,15 +82,16 @@ impl Service { // The helpers' own connections go out directly under the TUN, as upstream's socket // marks send them: the sidecar's would loop back into sing-box, the relay's too. let mut direct = Vec::new(); - if cfg.proxy.backend == Backend::Hybrid { - if let Ok(x) = self.comps.xray() { - direct.push(x.to_string_lossy().into_owned()); - } + if cfg.proxy.backend == Backend::Hybrid + && let Ok(x) = self.comps.xray() + { + direct.push(x.to_string_lossy().into_owned()); } - if cfg.tg_ws_proxy.enable && cfg.tg_ws_proxy.bypass_transparent_proxy { - if let Ok(p) = self.comps.program("tg-ws-proxy", "python/python") { - direct.push(p.to_string_lossy().into_owned()); - } + if cfg.tg_ws_proxy.enable + && cfg.tg_ws_proxy.bypass_transparent_proxy + && let Ok(p) = self.comps.program("tg-ws-proxy", "python/python") + { + direct.push(p.to_string_lossy().into_owned()); } let (zd, zi) = crate::zapret::direct_sync(cfg, &paths.bin()); Env {