Commit Graph

37 Commits

Author SHA1 Message Date
founder 84275d0fe4 status: deduplicate the healthy and degraded paths, keep the System block contiguous
print_status and print_degraded_sections carried four byte-identical blocks - host
firewall (25 lines), anti-torrent (24), last actions (9) and recent events (10) - plus a
Conntrack block that was the same logic assembled differently and a Traffic desired block
of four printlns. Roughly 80 lines of copy-paste with no test covering either copy, so a
format change applied to one path would have silently diverged from the other. The
divergence would only ever be visible while the container is down, which is the worst
moment to discover the diagnostic output is wrong.

Every shared section is now one function called from both paths:
print_traffic_desired_section, print_host_firewall_section, print_antitorrent_section,
print_conntrack_section, print_last_actions_section, print_recent_events_section. The file
already had this shape for print_swap_status and print_reboot_section; the pattern is now
followed consistently. The Docker/Amnezia port path block keeps two variants because they
genuinely differ - real values against unknown - but the shared FORWARD ownership note is
a single constant.

The runtime state paths were also duplicated across modules: status.rs re-declared the
literals that daemon.rs already owns. daemon::LAST_STATE_FILE and daemon::EVENTS_FILE are
now pub and reused, and the recent-events window is a named constant instead of a bare 10.

Ordering fix in the same function: print_network_tuning_status ran between the service
line and the container lines, so container/container_id/pid/netns/interface appeared under
the "Network tuning:" header at the same two-space indent as its fields. Container
identity is now printed inside the discovery match, before any other section opens, in
both the healthy and degraded paths. Field names are unchanged; only the order of two
blocks moved. IMPLEMENTATION_SPEC section 15 documented the old order and is updated.

print_degraded_sections returned anyhow::Result<()> while never failing; it returns unit
now.

status.rs: 645 -> 602 lines. cargo test --workspace: 110 + 4 passed. clippy -D warnings
clean.
2026-08-06 18:41:39 +05:00
founder 16214f3c66 AmneziaWG 3.0 readiness: centralize wg CLI contract, drop dead host-side fallback
Peer discovery is now the single owner of how wg is invoked and parsed.

wg.rs:
- resolve the binary through ordered amnezia.wg_binaries (default [awg, wg]);
  awg is the real binary in the official image and wg is a symlink to it, so awg is
  tried first and wg stays for plain WireGuard containers. No probe call: resolution
  is a property of the command being run anyway.
- drop the nsenter fallback. AmneziaWG is userspace and its UAPI socket lives under
  RUNSTATEDIR/amneziawg/ in the container mount namespace, while host wireguard-tools
  looks under /var/run/wireguard/. nsenter -n enters only the network namespace, so
  that path could never return peers.
- classify dump lines structurally instead of by column count. The AWG interface line
  is longer than a peer line (14 columns on AWG 2.0, 28 on AWG 3.0) and its
  handshake/rx/tx positions hold junk-packet sizes that parse as integers, so only the
  allowed-ips column discriminates. Column 1 of an interface line is the device private
  key, which the previous heuristic rejected only incidentally.
- fix allowed-ips parsing: `show all allowed-ips` separates a peer's addresses with
  spaces, not commas, so peers with more than one allowed IP were shaped on their first
  address only and the rest ran unlimited.
- collapse the three duplicated /32-in-CIDR filters into one tokenizer shared by the
  allowed-ips, dump and pretty-print parsers.

config.rs:
- add amnezia.wg_binaries with serde default, validated as bare command names
  (non-empty, no whitespace, no path separators) since they execute inside the
  container. Existing deployed configs keep parsing unchanged.
- remove host wg from the required-tool preflight. It gated daemon startup on
  wireguard-tools for a code path that produced nothing.

status.rs:
- discover peers once instead of twice per status call and degrade gracefully like the
  neighbouring sections instead of aborting the whole output.

Tests: real AWG 3.0 / AWG 2.0 / plain WireGuard interface-line fixtures, AWG 3.0 range
keepalive, space-separated allowed-ips, binary resolution order, and a test that parses
and validates the shipped config.example.toml.
2026-08-06 15:32:26 +05:00
founder 0d0b1c006b fix(sysctl_tuning): complete fix36 production reconcile and bbr modules-load lifecycle 2026-05-28 20:04:08 +05:00
founder 4f384bcff0 Decouple sysctl runtime validation and modprobe dependencies 2026-05-28 12:12:42 +05:00
founder 10b2d0aefb Production sysctl_tuning hardening and upgrade-safe defaults 2026-05-28 12:01:08 +05:00
founder 2c27bff800 Реализован production-модуль sysctl_tuning и полная интеграция fix33
Добавлен отдельный host-level модуль sysctl_tuning без легаси-подходов: managed sysctl файл, точечный reconcile через sysctl -w только для drifted ключей, режимы tcp_bbr off/auto/require, безопасное удаление только managed-файла и атомарная запись конфигурации.

Интегрированы новые CLI-команды apply-network-tuning/inspect-network-tuning, startup reconcile в daemon и секция Network tuning в status. Расширены config/defaults/валидация, обновлен пример конфига и документация. Добавлены unit-тесты для config и sysctl_tuning.
2026-05-28 11:31:13 +05:00
founder bb37da72c0 fix30: очищены old-bash формулировки и уточнён class-id контракт 2026-05-12 17:50:15 +05:00
founder 44a62cf634 fix29: удалён legacy, введён Debian 13-only и обновлён rollback 2026-05-12 17:26:41 +05:00
founder a9bac8fdad fix27: исправлен парсер root-класса tc без ложных совпадений 2026-05-12 14:34:28 +05:00
founder ead1130e5f fix25: исправлена идемпотентность swap и удаления default qdisc 2026-05-12 14:24:02 +05:00
founder 6e586c7af9 Fix23: финализация production-сборки 0.1.4
- Swap: сузил tolerance usable size до 64 KiB

- Cargo.lock: синхронизирована версия awg2-harness = 0.1.4

- Example/docs: ssh_port default приведен к 22

- Обновлен acceptance checklist по SSH default
2026-05-12 14:00:54 +05:00
founder 44d3593944 Fix22: подготовка production 0.1.4 и стабилизация сервиса
- Поднята версия awg2-harness до 0.1.4

- Обновлены production defaults: peer_limit=50mbit, root_rate=500mbit

- Добавлен systemd anti-flapping rate-limit и увеличен RestartSec

- Синхронизирована документация CONFIGURATION/MIGRATION
2026-05-12 13:47:37 +05:00
founder ff2ae98d30 Fix21: прод-фиксы swap/firewall/wg без легаси
- Swap: допуск небольшой дельты usable size при verify/compare

- Firewall: поддержка Debian 13 dynamic set/add @set вместо только literal meter

- WG: приоритет docker exec для peer/runtime discovery с безопасным fallback
2026-05-12 13:37:37 +05:00
founder c463e64205 Исправлены runtime-баги firewall policy и парсера swapon для Debian 13 2026-05-12 13:15:14 +05:00
founder 5800b6c874 Исправлен парсер tc-хитов для строк match+success 2026-05-12 12:34:37 +05:00
founder bff9c50a6b Исправлены clippy-замечания под gate -D warnings 2026-05-12 12:19:47 +05:00
founder 1e2a3b5b67 Добавлен fallback диагностики FORWARD через nft и расширен вывод status 2026-05-12 11:48:18 +05:00
founder ed786f165f Исправлен сломанный unit-тест docker parser в docker.rs 2026-05-12 11:33:32 +05:00
founder f8c6f2e92d Уточнена диагностика UDP port mapping для Docker и обновлены checklist/docs 2026-05-11 19:30:25 +05:00
founder adc244daa7 Добавлена диагностика Docker/Amnezia port path в status и уточнена документация host firewall 2026-05-11 19:22:39 +05:00
founder 640178a592 Исправлен drift-check host firewall для established/related, добавлены тесты и trim policy в status 2026-05-11 18:54:15 +05:00
founder 36600c0a5a fix10: стабилизация host firewall first-run и no-op reconcile
- исправлен first-run дефект: delete table вынесен из nft batch\n- добавлен no-op путь при отсутствии host firewall drift\n- исправлен trim для default_input_policy в drift-check\n- добавлены тесты для batch script и policy trim\n- уточнен release-gate в acceptance checklist по INPUT/FORWARD
2026-05-11 18:45:17 +05:00
founder ed4a571d71 fix9: безопасный host firewall apply и строгий конфиг
- host_firewall секция стала обязательной (убран silent enable)\n- host firewall применяется атомарным nft batch\n- добавлен verify-after-apply с hard-fail при drift\n- усилен tolerant parser drift (кавычки, ipv6-icmp alias)\n- расширены unit-тесты config/firewall\n- дополнен acceptance checklist блоком host firewall
2026-05-11 18:33:46 +05:00
founder 3d5bec424c chore: форматирование тестов wg и reboot module 2026-05-11 18:16:26 +05:00
founder 381c106f9d fix8: продакшн host firewall + dual reconcile firewall
- добавлена секция host_firewall в конфиг и defaults\n- реализован host firewall reconcile в отдельной таблице\n- apply-firewall теперь делает host firewall + anti-torrent\n- убрана JSON-инспекция из full-table drift для anti-torrent\n- расширен status вывод drift по host firewall/anti-torrent
2026-05-11 18:14:46 +05:00
founder 7a4e9764b1 fix7: продакшен-реализация полного reconcile swap и интеграций
- Полностью переписан swap-модуль в режиме exclusive ownership\n- Добавлены verify/checks, статус фактического swap-state и drift\n- Интегрирован ensure-swap в daemon и systemd ExecStartPre\n- Усилен lock API (таймауты) и применение в traffic/firewall/swap\n- Усилен parser firewall (JSON-first + устойчивый text fallback)\n- Обновлены config validation, runtime tools и default priority\n- Синхронизированы docs и build/package hygiene\n- Удалены member Cargo.lock в пользу корневого lockfile
2026-05-11 17:30:15 +05:00
founder 819cc9c308 Документация и runtime: полный production-fix по fix6 без legacy 2026-05-10 22:58:59 +05:00
founder d4cd6a4e43 traffic_core: продакшн-фиксы runtime и валидации 2026-05-10 21:29:52 +05:00
founder a4bb7adb4f Traffic: исправить детект ingress redirect для реального вывода tc
has_ingress_redirect_to_ifb переведён на case-insensitive разбор и поддержку обоих вариантов: dev <ifb> и device <ifb>. Добавлены тесты на lowercase dev-формат и отрицательный кейс с другим ifb.

Также синхронизирован docs/ANTI_TORRENT.md: единая шкала threshold (100 default, 150 мягче, 200/250 permissive, 70 агрессивный), и антипример over 200 явно помечен как non-default/non-production.
2026-05-10 18:07:05 +05:00
founder 9d2d2bc0c2 Сборка: добавить production packaging flow через .deb
Добавлен package-режим в tools/build.sh: --package, --dist-dir, --version. Реализована сборка Debian-пакета, metadata/control, postinst/postrm и SHA256SUMS. Установочные пути унифицированы под /usr/sbin и /lib/systemd/system для production-модели.
2026-05-10 17:26:11 +05:00
founder 76c6b52f4e Полный продакшн-фикс: parity с old bash, drift-recovery, status/runtime и builder separation 2026-05-10 17:09:39 +05:00
founder b8d2c4592b Полный production-рефакторинг билдера, drift-reconcile и документации по up5 2026-05-10 16:42:09 +05:00
founder b3dad5974c Полный продакшн-фикс: hardened build/install, drift/firewall/wg проверки и актуализация документации 2026-05-10 15:41:44 +05:00
founder 535c1dbc33 Полная реализация production-фиксов из up3: anti-torrent rebuild, peer-status, drift rate/ceil, reboot window 2026-05-10 00:15:17 +05:00
founder d9f140b3e0 Полностью доведена production-логика AWG2 harness по up2: strict execution, tc parser, anti-torrent, status и документация 2026-05-09 23:38:53 +05:00
founder e7818054e8 Рефакторинг под прод: nsenter-first транспорт, drift-aware reconcile, hardening daemon/lock/reboot/swap, расширенный status и build-скрипт 2026-05-09 22:03:30 +05:00
founder d937f816bf feat: bootstrap awg2 harness rust workspace and docs 2026-05-09 02:17:25 +05:00