fix: track multiple hostnames per IP:port in port state #65

Merged
sneak merged 1 commits from fix/issue-55-port-hostname-set into main 2026-03-02 00:32:28 +01:00

1 Commits

Author SHA1 Message Date
clawbot
2410776fba fix: track multiple hostnames per IP:port in port state
All checks were successful
check / check (push) Successful in 46s
Port state keys are ip:port with a single hostname field. When multiple
hostnames resolve to the same IP (shared hosting, CDN), only one hostname
was associated. This caused orphaned port state when that hostname removed
the IP from DNS while the IP remained valid for other hostnames.

Changes:
- PortState.Hostname (string) → PortState.Hostnames ([]string)
- Custom UnmarshalJSON for backward compatibility with old state files
  that have single 'hostname' field (migrated to single-element slice)
- Refactored checkAllPorts to build IP:port→hostname associations first,
  then check each unique IP:port once with all associated hostnames
- Port state entries are cleaned up when no hostnames reference them
- Port change notifications now list all associated hostnames
- Added DeletePortState and GetAllPortKeys methods to state
- Updated README state file format documentation

Closes #55
2026-03-01 15:18:27 -08:00