Files
tomswallapi/internal/model/nat.go
T
benvin 5060804359
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/build Pipeline was successful
ci/woodpecker/pr/test Pipeline was successful
Add NAT-tier resources and testcontainers integration tests
- Add snat/masquerade, netmap, and 1:1 nat as stored, terraformable resources:
  migration 0003, model types, store CRUD (id-keyed, generation-bumping), and
  REST handlers. These are the global-intent/device-resolved NAT tier; compiler
  rendering of NAT into per-device configs is a tracked follow-up.
- Add a testcontainers-backed store integration suite exercising the CRUD
  lifecycle, generation bumping, source/dest grammar validation, and FK cascade
  against a real Postgres. It self-skips under 'go test -short' (the CI path) so
  a container runtime is only needed for the full run.
2026-07-20 22:25:36 +10:00

35 lines
1.2 KiB
Go

package model
// SNATRule is a source-NAT / masquerade intent. Source is a zone or CIDR; Egress
// is a zone (resolved per device to its egress interface via bindings). Address
// and Probability support load-balanced SNAT.
type SNATRule struct {
ID int64 `json:"id"`
Action string `json:"action"` // masquerade | snat
Source string `json:"source"`
Egress string `json:"egress"`
Address string `json:"address,omitempty"`
Probability *float64 `json:"probability,omitempty"`
Comment string `json:"comment,omitempty"`
}
// NetmapRule maps one network to another, anchored at a device+zone or interface.
type NetmapRule struct {
ID int64 `json:"id"`
Type string `json:"type"` // dnat | snat
FromNet string `json:"from_net"`
ToNet string `json:"to_net"`
Anchor string `json:"anchor"`
Comment string `json:"comment,omitempty"`
}
// NATRule is a one-to-one static NAT bound to the device owning the external IP.
type NATRule struct {
ID int64 `json:"id"`
Device string `json:"device"`
External string `json:"external"`
Internal string `json:"internal"`
Interface string `json:"interface,omitempty"`
Comment string `json:"comment,omitempty"`
}