Agent: translate the NAT tier into native config #4

Merged
benvin merged 1 commits from benvin/agent-nat into main 2026-07-21 22:30:10 +10:00
Owner

Why

tomswallapi now renders the NAT tier (snat/masquerade, netmap, 1:1 nat) into per-device configs. The agent must map those rendered sections into native tomswall config so they are actually applied.

Changes

  • Add RenderedSNAT/RenderedNetmap/RenderedNAT to the agent's rendered-config types.
  • Translate them in the agent: snat/masquerade → config.SNAT (expanding the egress-interface list and source CIDRs into one native rule per (egress, source) pair, since a native SNAT rule takes a single dest; carries address/probability); netmap → config.Netmap; 1:1 nat → config.StaticNAT.
  • Unit test covering the full RenderedConfig → config.Config mapping for all three.

Pairs with

tomswallapi #6 (compiler renders the NAT tier).

## Why tomswallapi now renders the NAT tier (snat/masquerade, netmap, 1:1 nat) into per-device configs. The agent must map those rendered sections into native tomswall config so they are actually applied. ## Changes - Add RenderedSNAT/RenderedNetmap/RenderedNAT to the agent's rendered-config types. - Translate them in the agent: snat/masquerade → config.SNAT (expanding the egress-interface list and source CIDRs into one native rule per (egress, source) pair, since a native SNAT rule takes a single dest; carries address/probability); netmap → config.Netmap; 1:1 nat → config.StaticNAT. - Unit test covering the full RenderedConfig → config.Config mapping for all three. ## Pairs with tomswallapi #6 (compiler renders the NAT tier).
unkinben added 1 commit 2026-07-21 22:21:25 +10:00
Agent: translate the NAT tier into native config
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
06928bc150
The agent now maps the rendered NAT sections into native tomswall config:
- snat/masquerade -> config.SNAT, expanding a rendered rule's egress interface
  list and source CIDRs into one native rule per (egress, source) pair (a native
  SNAT rule takes a single dest interface); carries address/probability.
- netmap -> config.Netmap (from_net/to_net -> net1/net2 on the resolved interface).
- 1:1 nat -> config.StaticNAT.
Unit-tested end to end from RenderedConfig to config.Config.
benvin merged commit 17b2130047 into main 2026-07-21 22:30:10 +10:00
benvin deleted branch benvin/agent-nat 2026-07-21 22:30:10 +10:00
Sign in to join this conversation.