windows: clippy's suggestions in the service and client (collapsible ifs, next_back)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7565e62571
commit
757bebbb1d
6 files changed
+20
-21
No files matched your search
Generated
+1
@@ -4980,6 +4980,7 @@ dependencies = [
|
||||
"ps-ipc",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"windows-sys 0.61.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
||||
@@ -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 }
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in new issue
Block a user