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
+17
-18
No files matched your search
Generated
+1
@@ -4980,6 +4980,7 @@ dependencies = [
|
|||||||
"ps-ipc",
|
"ps-ipc",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ pub fn link_tag(link: &str) -> String {
|
|||||||
return t;
|
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);
|
let t = ps_core::links::subscription::slugify_tag(host);
|
||||||
if t.is_empty() { "outbound".into() } else { t }
|
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 } => {
|
Request::ConfigSet { mut config, base } => {
|
||||||
let mut s = shared.lock().await;
|
let mut s = shared.lock().await;
|
||||||
if let Some(base) = base {
|
if let Some(base) = base
|
||||||
if base != s.store.revision {
|
&& base != s.store.revision
|
||||||
return Response::err(format!(
|
{
|
||||||
"the configuration changed since revision {base} (now {}): read it again",
|
return Response::err(format!("the configuration changed since revision {base} (now {}): read it again", s.store.revision));
|
||||||
s.store.revision
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
unredact(&mut config, s.cfg());
|
unredact(&mut config, s.cfg());
|
||||||
let new: Config = match serde_json::from_value(config) {
|
let new: Config = match serde_json::from_value(config) {
|
||||||
|
|||||||
@@ -20,11 +20,11 @@ pub async fn archive(src: &Source, routes: &[fetch::Route], cache: &Path) -> Res
|
|||||||
std::fs::create_dir_all(cache)?;
|
std::fs::create_dir_all(cache)?;
|
||||||
let key = hex(src.url.as_bytes());
|
let key = hex(src.url.as_bytes());
|
||||||
let cached = cache.join(&key[..32]);
|
let cached = cache.join(&key[..32]);
|
||||||
if let Ok(data) = std::fs::read(&cached) {
|
if let Ok(data) = std::fs::read(&cached)
|
||||||
if src.sha256.as_ref().is_none_or(|want| hex(&data) == *want) {
|
&& src.sha256.as_ref().is_none_or(|want| hex(&data) == *want)
|
||||||
|
{
|
||||||
return Ok(data);
|
return Ok(data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let mut last = None;
|
let mut last = None;
|
||||||
for route in routes {
|
for route in routes {
|
||||||
match fetch::get(&src.url, route, 512 * 1024 * 1024).await {
|
match fetch::get(&src.url, route, 512 * 1024 * 1024).await {
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ mod secure {
|
|||||||
};
|
};
|
||||||
let path = wide(root.as_os_str());
|
let path = wide(root.as_os_str());
|
||||||
// SAFETY: NUL-terminated path; attrs outlives the call.
|
// 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(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
// SAFETY: plain call.
|
// SAFETY: plain call.
|
||||||
|
|||||||
@@ -82,16 +82,17 @@ impl Service {
|
|||||||
// The helpers' own connections go out directly under the TUN, as upstream's socket
|
// 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.
|
// marks send them: the sidecar's would loop back into sing-box, the relay's too.
|
||||||
let mut direct = Vec::new();
|
let mut direct = Vec::new();
|
||||||
if cfg.proxy.backend == Backend::Hybrid {
|
if cfg.proxy.backend == Backend::Hybrid
|
||||||
if let Ok(x) = self.comps.xray() {
|
&& let Ok(x) = self.comps.xray()
|
||||||
|
{
|
||||||
direct.push(x.to_string_lossy().into_owned());
|
direct.push(x.to_string_lossy().into_owned());
|
||||||
}
|
}
|
||||||
}
|
if cfg.tg_ws_proxy.enable
|
||||||
if cfg.tg_ws_proxy.enable && cfg.tg_ws_proxy.bypass_transparent_proxy {
|
&& cfg.tg_ws_proxy.bypass_transparent_proxy
|
||||||
if let Ok(p) = self.comps.program("tg-ws-proxy", "python/python") {
|
&& let Ok(p) = self.comps.program("tg-ws-proxy", "python/python")
|
||||||
|
{
|
||||||
direct.push(p.to_string_lossy().into_owned());
|
direct.push(p.to_string_lossy().into_owned());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
let (zd, zi) = crate::zapret::direct_sync(cfg, &paths.bin());
|
let (zd, zi) = crate::zapret::direct_sync(cfg, &paths.bin());
|
||||||
Env {
|
Env {
|
||||||
zapret_direct: ps_core::config::RouteMatch { domains: zd, ips: zi, ..Default::default() },
|
zapret_direct: ps_core::config::RouteMatch { domains: zd, ips: zi, ..Default::default() },
|
||||||
|
|||||||
Reference in new issue
Block a user