Skip to content

Add custom NAT rules to the legacy client - #30

Merged
ChrisonSimtian merged 2 commits into
mainfrom
feat/nat-rules
Nov 8, 2026
Merged

ChrisonSimtian merged 2 commits into
mainfrom
feat/nat-rules

Conversation

@ChrisonSimtian

Copy link
Copy Markdown
Collaborator

Adds custom NAT rules (DNAT, MASQUERADE, SNAT) to UnifiLegacyClient through the v2 site API (/proxy/network/v2/api/site/<site>/nat), so Homelab can declare them (Homelab#678).

  • UnifiNatRuleSpec / UnifiNatFilter: Name is the rule's description (rules have no name), networks by name, one address/range/CIDR per filter with InvertAddress for "except". Record equality is the drift check.
  • UnifiNatRuleJson: ToJson / FromJson. FromJson refuses what ToJson can't write back (non-IPv4, exclude, pppoe_use_base_interface, non-manual setting_preference, filter types other than ADDRESS_AND_PORT).
  • Client: list, create, update, delete, and GetNatNamesAsync (network name to _id). Create takes the next free rule_index (the controller rejects a duplicate); update keeps the live index when the spec has none. Update and delete refuse predefined rules and ids not on the controller.

Shape taken from the two live rules on the UCG (Network 10.6.106), supplied by the Homelab Blocky session; not yet checked by a read of my own. 143 passed, 7 skipped, 0 failed.

The throwaway container has no gateway and answers a NAT POST with 500, so there is no container create/delete test: writes are unit-tested against that shape, and one container test covers list and the name lookup.

@ChrisonSimtian ChrisonSimtian added the enhancement New feature or request label Oct 25, 2026
@ChrisonSimtian
ChrisonSimtian merged commit d75e3b8 into main Nov 8, 2026
1 check passed
@ChrisonSimtian
ChrisonSimtian deleted the feat/nat-rules branch November 8, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant