windows: the component manager, verified programs, a Wine test

components.json pins sing-box, XRay, Flowseal's zapret, bol-van's
winws2 bundle with nfqws2-keenetic's strategies, and tg-ws-proxy (built
with the release): release assets by archive hash, commit snapshots by
the hash of every file taken. The service installs them (admin only),
staged and swapped in, refusing archive paths that leave the directory,
and checks each program against the hashes recorded at install before
running it. stage-components does the same for building a release.

The state root is created with its protected descriptor in one call,
or, existing, checked through a handle that does not follow links.

tools/wine-e2e.sh runs the Windows build under Wine: the service, the
named pipe, impersonation, the component check, rendering and the
supervisor all work; Wine lacks an iphlpapi call sing-box needs, so
proxying itself needs real Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5.5 committed 2026-10-26 23:33:55 +03:00
1 parent b878dd93db
commit 68b496cafa
10 files changed
+709 -81

No files matched your search

+28 -5
View File
@@ -3,15 +3,37 @@
//! 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::collections::HashMap;
use std::path::{Path, PathBuf};
use std::sync::Mutex;
use std::time::SystemTime;
pub struct Components {
bin: PathBuf,
/// Programs verified, by path, with the size and time they had then.
verified: Mutex<HashMap<PathBuf, (u64, SystemTime)>>,
}
impl Components {
pub fn new(bin: PathBuf) -> Self {
Self { bin }
Self { bin, verified: Mutex::new(HashMap::new()) }
}
/// `find`, and for an installed one, the check that it is what was installed.
pub fn program(&self, component: &str, name: &str) -> anyhow::Result<PathBuf> {
let path = self
.find(component, name)
.ok_or_else(|| anyhow::anyhow!("{component} is not installed (proxy-ctl components install {component})"))?;
let dir = self.bin.join(component);
if path.starts_with(&dir) {
let meta = std::fs::metadata(&path)?;
let stamp = (meta.len(), meta.modified()?);
if self.verified.lock().unwrap().get(&path) != Some(&stamp) {
crate::install::verify(&dir, &path)?;
self.verified.lock().unwrap().insert(path.clone(), stamp);
}
}
Ok(path)
}
/// The program `name` (without `.exe`) of `component`. On Windows only the protected
@@ -30,14 +52,15 @@ impl Components {
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 sing_box(&self) -> anyhow::Result<PathBuf> {
self.program("sing-box", "sing-box")
}
pub fn xray(&self) -> Option<PathBuf> {
self.find("xray", "xray")
pub fn xray(&self) -> anyhow::Result<PathBuf> {
self.program("xray", "xray")
}
#[allow(dead_code)]
pub fn bin_dir(&self) -> &Path {
&self.bin
}