fix(backend): sync forward ports on tunnel entry change

This commit is contained in:
sagitchu
2026-03-11 11:18:52 +08:00
parent 673d38a089
commit d2a425d761
2 changed files with 121 additions and 0 deletions
@@ -0,0 +1,19 @@
# 028 - Sync Forward Ports On Tunnel Entry Change
## Goal
When a tunnel's entry nodes change, automatically keep all forwards under that tunnel aligned by rebuilding `forward_port` rows to match the latest entry node set.
## Scope
- Backend only: update tunnel mutation flow to sync forward entry mappings.
- Preserve existing forward port and bind IP behavior:
- Keep the existing forward port (choose the current min port in `forward_port`).
- Preserve `in_ip` only when the tunnel has a single entry node; clear `in_ip` for multi-entry tunnels.
## Checklist
- [x] Capture old entry node IDs before tunnel update commits.
- [x] After commit, compare old/new entry node sets.
- [x] If changed, rebuild `forward_port` for all forwards in the tunnel.
- [x] Run `go test ./...` in `go-backend`.
## Notes
- Runtime redeploy/downlink is handled elsewhere; this change focuses on DB-level consistency of forward entry mappings.