Say which machines are inside the private network from placement, for route-proxy, whose membership read goes with the assignments stream (issue 774, research 072 rows 33 and 34)

This commit is contained in:
2026-10-31 09:28:15 +01:00
parent a4e7629742
commit 98d5306d6b
2 changed files with 19 additions and 0 deletions
+16
View File
@@ -578,3 +578,19 @@ func PlacementValues(p Placement) (map[string][]byte, error) {
}
return out, nil
}
// InsideAddresses is every node's address on the private network as its placement decides it (NodeDecided.Address),
// sorted and each once: the machines inside the private network, which a membership's Mesh carried until the assignments
// stream went (ADR 0167; research 072 rows 33 and 34). A node with no address decided is left out.
func InsideAddresses(placements map[string]Placement) []string {
seen := map[string]bool{}
out := []string{}
for _, p := range placements {
if a := strings.TrimSpace(p.Decided.Address); a != "" && !seen[a] {
seen[a] = true
out = append(out, a)
}
}
sort.Strings(out)
return out
}
+3
View File
@@ -180,6 +180,9 @@ func TestPlacement(t *testing.T) {
if err != nil || !SamePlacement(got["g14"], g14) || len(got) != 1 {
t.Fatalf("PlacementsOf = %+v, %v", got, err)
}
if got := InsideAddresses(map[string]Placement{"g14": g14, "novox": novox, "x": {Node: "x"}, "y": {Node: "y", Decided: NodeDecided{Address: " 10.77.0.1"}}}); strings.Join(got, ",") != "10.77.0.1,10.77.0.2" {
t.Errorf("InsideAddresses = %v", got)
}
legacy, _ := EncodePlacement(novox)
stale, _ := EncodePlacement(Placement{Node: "g14"})
both := map[string][]byte{"placement.novox": legacy, "placement.g14": stale}