windows: authorize streamed requests, self-removal on uninstall, tun on

- Every request is authorized before it is handled, including `logs -f`,
  which skipped the check.
- The state root is checked once per process: a second check under Wine
  moved the live root (and its log) aside.
- uninstall removes Program Files after it exits: cmd got a garbled
  quoted command line; it now runs raw, outside the folder, windowless.
- install no longer fails when the first start does; it says how to start.
- `proxy-ctl proxy tun on` also turns on proxy.tun.enable.
- build-tg-ws-proxy.sh resolves its output path before changing directory.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Opus 5.5 committed 2026-10-27 00:41:53 +03:00
1 parent 28cc7b2cbe
commit 8af7b2e628
5 files changed
+62 -15

No files matched your search

+18 -6
View File
@@ -174,6 +174,17 @@ async fn connection(mut conn: Conn, shared: Shared) {
}
};
let peer = conn.peer();
// Every request, streamed or not, is authorized here before anything is done for it.
let denied = {
let s = shared.lock().await;
allowed(s.cfg(), &peer, scope_of(&req)).err()
};
if let Some(e) = denied {
if conn.write_json(&Response::err(e)).await.is_err() {
return;
}
continue;
}
if let Request::Logs { unit, lines, follow: true } = &req {
follow_logs(&mut conn, &shared, unit.clone(), *lines).await;
return;
@@ -208,13 +219,8 @@ async fn follow_logs(conn: &mut Conn, shared: &Shared, unit: Option<String>, lin
}
}
/// Does what `req` asks; the caller has authorized it (`connection`).
pub async fn handle(req: Request, peer: &Peer, shared: &Shared) -> Response {
{
let s = shared.lock().await;
if let Err(e) = allowed(s.cfg(), peer, scope_of(&req)) {
return Response::err(e);
}
}
match req {
Request::Status => Response::ok(shared.lock().await.status()),
@@ -525,6 +531,12 @@ mod tests {
assert_eq!(back.proxy.listener.auth.password.as_deref(), Some("pw"));
}
#[test]
fn following_logs_needs_the_secrets_scope_too() {
assert_eq!(scope_of(&Request::Logs { unit: None, lines: 10, follow: true }), Some(Scope::Secrets));
assert_eq!(scope_of(&Request::Logs { unit: None, lines: 10, follow: false }), Some(Scope::Secrets));
}
#[test]
fn scopes_follow_user_control() {
let mut cfg = Config::default();