Files
AWG2_harness/traffic_core/src/firewall
founder dbceda5c13 refactor(firewall): split firewall.rs by subsystem, collapse duplicated test fixtures
firewall.rs held two subsystems that share nothing but the nft command layer: the host
INPUT firewall, applied in the host namespace and owning inet awg2_host_firewall, and the
anti-torrent guard, applied in the namespace chosen by config and owning inet
awg2_harness. The split follows that boundary rather than an inspect/apply one:

  firewall/mod.rs          apply_firewall, namespace selection, shared table constants
  firewall/nft.rs          text normalization and the nft command wrappers
  firewall/host.rs         host INPUT firewall and its 5 tests
  firewall/antitorrent.rs  connection-count guard and its 6 tests

Production logic is unchanged. Function sets before and after are identical: 25 against
25, verified by extracting names from the old blob and the four new files and diffing.

Not a pure move in one respect, stated here so it is not a surprise in review: the test
module contained four near-identical 45-line Config literals, about 180 lines of
copy-paste, differing only in the single field each test actually cared about. Carrying
four copies into the new files would have knowingly propagated the duplication, so they
collapse into one test_config() helper in firewall/mod.rs that tests mutate. This is why
the four files total 875 lines against the old 890 despite gaining doc comments.

Doc comments now record the reasoning that was only implicit before: why nft output is
compared after normalization (rendering differs across versions - quoting, comma-separated
ct state lists, brace layout), why the host firewall batch never contains a delete (a
partially applied INPUT chain could lock out SSH), why ct state new is load-bearing in the
anti-torrent rule, why connlimit_state_present accepts two renderings, and why the
anti-torrent rule defaults to the container namespace.

IMPLEMENTATION_SPEC section 3 is updated: it described the old flat layout and carried the
split as an unfulfilled intention. Both traffic and firewall now match what it documents.

cargo test --workspace: 110 + 4 passed, unchanged count. clippy -D warnings clean.
2026-08-06 18:51:31 +05:00
..