windows: the dark theme's off and disabled controls readable; upgrades with tunnels up
Dark theme: a switch that is off has a lighter track (#737373, was #404040 under a near-black thumb), radio buttons, checkboxes and text fields a lighter edge (#525252); a disabled button's text is the muted colour itself rather than half of it (widgets::Inactive). The title bar is set again a moment after Windows' appearance changes, as GPUI resets it to Windows' own. Upgrades: a running system-wide AmneziaWG tunnel is stopped while the release's newer amneziawg replaces bin\amneziawg, and started again; WinDivert's driver is let go of before zapret or zapret2 is replaced. The fetched setup program goes once the update it brought is running. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
5bd47f7676
commit
d33f05c62c
19 files changed
+101
-21
No files matched your search
@@ -293,6 +293,21 @@ pub fn state(_iface: &str) -> String {
|
||||
"windows-only".into()
|
||||
}
|
||||
|
||||
/// The tunnels this suite registered that run, stopped: their interface names.
|
||||
pub fn stop_running(paths: &Paths) -> Vec<String> {
|
||||
registered(paths)
|
||||
.into_iter()
|
||||
.filter(|iface| state(iface) == "active")
|
||||
.filter(|iface| match stop(iface) {
|
||||
Ok(()) => true,
|
||||
Err(e) => {
|
||||
tracing::warn!("stopping the AmneziaWG tunnel {iface}: {e:#}");
|
||||
false
|
||||
}
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// Every tunnel this suite registered, stopped and deleted: on uninstall.
|
||||
#[cfg_attr(not(windows), allow(dead_code))]
|
||||
pub fn remove_all(paths: &Paths) {
|
||||
|
||||
@@ -256,15 +256,20 @@ fn verify_all(dir: &Path) -> Result<()> {
|
||||
|
||||
/// Copies each component of `from` (the release's) into `bin` when `bin` lacks it or holds
|
||||
/// another version: staged, verified file by file, swapped in. What it did, as lines.
|
||||
/// Whether `seed` replaces `name` in `bin`: the release has the version the manifest wants,
|
||||
/// and `bin` another (or none).
|
||||
pub fn seeds(from: &Path, bin: &Path, name: &str) -> bool {
|
||||
let manifest = ps_core::components::manifest();
|
||||
let Some(comp) = manifest.components.get(name) else { return false };
|
||||
installed_version(from, name).as_deref() == Some(comp.version.as_str()) && installed_version(bin, name).as_deref() != Some(comp.version.as_str())
|
||||
}
|
||||
|
||||
pub fn seed(from: &Path, bin: &Path) -> Vec<String> {
|
||||
let manifest = ps_core::components::manifest();
|
||||
let mut notes = Vec::new();
|
||||
for (name, comp) in &manifest.components {
|
||||
let src = from.join(name);
|
||||
if installed_version(from, name).as_deref() != Some(comp.version.as_str()) {
|
||||
continue;
|
||||
}
|
||||
if installed_version(bin, name).as_deref() == Some(comp.version.as_str()) {
|
||||
if !seeds(from, bin, name) {
|
||||
continue;
|
||||
}
|
||||
let staging = bin.join(format!("{name}.staging"));
|
||||
|
||||
@@ -89,9 +89,22 @@ pub async fn run(
|
||||
paths.create_all().with_context(|| format!("creating {}", paths.root.display()))?;
|
||||
// The components the release carries, next to the program, into bin\ when they are newer.
|
||||
if let Some(dir) = install::bundled_components_dir() {
|
||||
// What runs from bin\ outside this service holds its files: a system-wide AmneziaWG
|
||||
// tunnel (stopped while its program is replaced, started again after), WinDivert's
|
||||
// driver (left loaded by a zapret stopped hard).
|
||||
let tunnels = if install::seeds(&dir, &paths.bin(), "amneziawg") { awgvpn::stop_running(&paths) } else { Vec::new() };
|
||||
#[cfg(windows)]
|
||||
if ["zapret", "zapret2"].iter().any(|n| install::seeds(&dir, &paths.bin(), n)) {
|
||||
winsvc::release_windivert();
|
||||
}
|
||||
for note in install::seed(&dir, &paths.bin()) {
|
||||
tracing::info!("{note}");
|
||||
}
|
||||
for iface in tunnels {
|
||||
if let Err(e) = awgvpn::start(&iface) {
|
||||
tracing::warn!("the AmneziaWG tunnel {iface} did not start again: {e:#}");
|
||||
}
|
||||
}
|
||||
}
|
||||
let svc = service::Service::new(paths.clone()).with_context(|| format!("opening {}", paths.root.display()))?;
|
||||
let interactive = svc.cfg().user_control.enable;
|
||||
|
||||
@@ -194,7 +194,9 @@ fn published_sum(text: &[u8]) -> Result<String> {
|
||||
}
|
||||
}
|
||||
|
||||
/// The release's setup program in `dir` (older ones gone), once its SHA-256 matches.
|
||||
/// The release's setup program in `dir` (older ones gone), once its SHA-256 matches. `dir` is
|
||||
/// under the state root, whose protected DACL (SYSTEM and Administrators only, inherited)
|
||||
/// keeps anyone else from replacing the file between this check and its run as SYSTEM.
|
||||
async fn download(release: &Release, routes: &[Route], dir: &Path) -> Result<PathBuf> {
|
||||
let sum = first(routes, |r| {
|
||||
let url = release.checksum.clone();
|
||||
@@ -295,6 +297,10 @@ pub fn report(dir: &Path) {
|
||||
let _ = std::fs::remove_file(&path);
|
||||
if wanted.trim() == env!("CARGO_PKG_VERSION") {
|
||||
tracing::info!("updated to {}", env!("CARGO_PKG_VERSION"));
|
||||
// Done with: ~80 MB.
|
||||
for e in std::fs::read_dir(dir).into_iter().flatten().flatten() {
|
||||
let _ = std::fs::remove_file(e.path());
|
||||
}
|
||||
} else {
|
||||
tracing::warn!("the update to {} did not finish; this is still {}", wanted.trim(), env!("CARGO_PKG_VERSION"));
|
||||
}
|
||||
|
||||
@@ -196,6 +196,13 @@ pub fn uninstall() -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// WinDivert's driver, if this suite's is still loaded: its files are about to be replaced.
|
||||
pub fn release_windivert() {
|
||||
if let Ok(manager) = ServiceManager::local_computer(None::<&str>, ServiceManagerAccess::CONNECT) {
|
||||
remove_windivert(&manager);
|
||||
}
|
||||
}
|
||||
|
||||
/// The WinDivert driver zapret loaded from this suite's components, if it is still registered
|
||||
/// (WinDivert removes its own service as it loads, but one stopped hard can stay): stopped and
|
||||
/// deleted, as Flowseal's service.bat removes it. One from elsewhere is left alone.
|
||||
|
||||
Reference in new issue
Block a user