ps-ipc: line-delimited JSON over a named pipe whose ACL admits SYSTEM, Administrators and (with userControl) the interactive user; the caller is identified by impersonation, never by what it claims. A Unix socket stands in off Windows. ps-service (proxy-suite-service.exe): a Windows service, or --console. Keeps the configuration with revisions, runtime state and generated secrets; renders, checks with sing-box check before replacing what runs, and supervises the backends (restart with backoff, start limit, logs in a ring and a file, a Job Object on Windows). Enforces scopes, admin-only edits and secret redaction that round-trips. Fetches subscriptions and rule sets through the proxy or directly with upstream's redirect rules, on timers. ps-ctl (proxy-ctl.exe): status, restart, logs [-f], config get/set/ validate, and proxy on/off, outbounds, pin, mode, subs, rules, rulesets, tun and config. An end-to-end test runs it all offline: a sing-box Shadowsocks server, the service, proxy-ctl adding the outbound, a page fetched through the local proxy. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.1 KiB
Rust
40 lines
1.1 KiB
Rust
//! Where the backend programs are.
|
|
//!
|
|
//! The service installs each into `bin\<component>\` (the component manager); a program
|
|
//! found there wins. Elsewhere (development on Linux) the one on PATH is taken.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
|
|
pub struct Components {
|
|
bin: PathBuf,
|
|
}
|
|
|
|
impl Components {
|
|
pub fn new(bin: PathBuf) -> Self {
|
|
Self { bin }
|
|
}
|
|
|
|
/// The program `name` (without `.exe`) of `component`.
|
|
pub fn find(&self, component: &str, name: &str) -> Option<PathBuf> {
|
|
let file = if cfg!(windows) { format!("{name}.exe") } else { name.to_owned() };
|
|
let installed = self.bin.join(component).join(&file);
|
|
if installed.is_file() {
|
|
return Some(installed);
|
|
}
|
|
let path = std::env::var_os("PATH")?;
|
|
std::env::split_paths(&path).map(|dir| dir.join(&file)).find(|p| p.is_file())
|
|
}
|
|
|
|
pub fn sing_box(&self) -> Option<PathBuf> {
|
|
self.find("sing-box", "sing-box")
|
|
}
|
|
|
|
pub fn xray(&self) -> Option<PathBuf> {
|
|
self.find("xray", "xray")
|
|
}
|
|
|
|
pub fn bin_dir(&self) -> &Path {
|
|
&self.bin
|
|
}
|
|
}
|