Files
zapret-autotune/MANAGED_TARGET.md
T
2026-10-10 08:20:08 +03:00

2.8 KiB

Local managed-target transaction core (not deployed)

managedTransaction is intentionally not wired to the CLI. No container, remote, production, existing zapret2-ss-autotune, or Xray configuration is changed. The caller explicitly provisions a private persistent target-owned directory and existing regular config, then calls Initialize once to adopt that config. Missing/corrupt journals never trigger automatic adoption. The journal is the source of truth; the DB provides immutable candidate definitions and qualification evidence only. Call Reconcile before accepting work after every process startup.

Apply uses candidate IDs, distinct profiles and exact ^host GGC filters. Shell syntax is rejected, not interpreted. Journal/backup/config updates use same-dir staging, file fsync, rename and directory fsync. An advisory lock serializes engine instances; the directory must not be writable by untrusted processes. Hash checks reject external drift (including during recovery). This is not protection against a hostile writer racing a hash check or renaming directory ancestors. Crash-left temporary files are inert, never adopted or promoted. Failed recovery blocks apply; an operator must resolve drift/corruption explicitly, without deleting the journal to silently adopt a different config.

Reload and health are injected no-argument functions. The future adapter must bind reload ONLY to /opt/zapret2/init.d/sysv/zapret2 restart-daemons, never start or firewall restart, and health ONLY to existing health youtube through the target's configured host-loopback SOCKS, returning OK only for its successful status. No command strings or shell scripts are persisted in transaction metadata. On activation failure the prior config is atomically restored and reloaded; a rollback reload failure retains a pending journal and is a distinct error. Recovery always restores pending transactions, even after a successful pre-crash probe. It marks recovery committed only after the injected reloader succeeds.

Pending remote acceptance: create ONLY a new test prod-like zapret2-ss target using the pinned image digest; verify config variable names, shell include loading, payload/Lua dependencies, profile semantics and restart-daemons behavior against the image's v0.9.0 scripts/blockcheckw. No actual compatibility is asserted here. Later integration must preserve the stable loopback SOCKS interface for Xray, own only this target's NFQWS2 config/process, and reuse DB v4 health state with policy env defaults of 5 minutes / 3 failures / 30 minutes. Scheduling, environment parsing, adapters, target creation and user-facing CLI are deliberately deferred.

Local checks for the orchestrator (not executed in this increment): go test ./cmd/zapret-autotune -run TestManaged and go build ./cmd/zapret-autotune.