cmd/natc: separate perPeerState from connector

Make the perPeerState objects able to function independently without a
shared reference to the connector.

We don't currently change the values from connector that perPeerState
uses at runtime. Explicitly copying them at perPeerState creation allows
us to, for example, put the perPeerState into a consensus algorithm in
the future.

Updates #14667

Signed-off-by: Fran Bull <fran@tailscale.com>
This commit is contained in:
Fran Bull
2025-04-02 08:58:13 -07:00
committed by franbull
parent 7b29d39f45
commit e2eb6eb870
2 changed files with 14 additions and 6 deletions

View File

@@ -220,7 +220,7 @@ func TestPerPeerState(t *testing.T) {
}
c.setPrefixes([]netip.Prefix{netip.MustParsePrefix("100.64.1.0/24")})
ps := &perPeerState{c: c}
ps := newPerPeerState(c)
addrs, err := ps.ipForDomain("example.com")
if err != nil {
@@ -360,7 +360,7 @@ func TestIPPoolExhaustion(t *testing.T) {
}
c.setPrefixes([]netip.Prefix{smallPrefix})
ps := &perPeerState{c: c}
ps := newPerPeerState(c)
assignedIPs := make(map[netip.Addr]string)