carlos / platform Public

console: check an egress grant against every box's published addresses (#328)

checkEgressGrant fills plan 1's stub: it checks the addresses a grant adds
(next minus old) against every readable control/edges/ file through the
console's AddrCache, refusing an address a box lists, an unreadable file,
an older box without addrs, or a failed listing, and names live boxes that
publish no edges file as not_checked. A revoke or size-only change reads
nothing (ruling C5).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev 002fb34f54f3eebb07ae456543abd9e39a8e4c10 parent 4fe52f8
4 files changed, +504 −3
  • internal/console/apipolicy.go +12 −3
  • internal/console/egressfleet.go +128 −0
  • internal/console/egressfleet_test.go +359 −0
  • internal/console/server.go +5 −0
diff --git a/internal/console/apipolicy.go b/internal/console/apipolicy.go
index 8d9ca35af..43033fa27 100644
--- a/internal/console/apipolicy.go
+++ b/internal/console/apipolicy.go
@@ -1088,10 +1088,19 @@ func (s *Server) staleOverrides(ctx context.Context, acct *Account, app string,
// checkEgressGrant is the fleet-address check on a new egress allow (spec
// §4.2), called whenever the request carries egress_allow; old is the stored
// list, next the normalized new one. A non-zero status refuses with msg
-// before the audit; notChecked is the reply's not_checked. Plan 1's body is
-// a stub: plan 2 fills it.
+// before the audit; notChecked is the reply's not_checked. Only what next
+// adds to old is checked (egressfleet.go), so a revoke never reads the
+// fleet's addresses and always goes through.
func (s *Server) checkEgressGrant(ctx context.Context, acct *Account, app string, old, next []string) (notChecked []string, status int, msg string) {
- return []string{}, 0, ""
+ added, err := grantAdded(old, next)
+ if err != nil {
+ return nil, http.StatusBadRequest, err.Error()
+ }
+ notChecked, ref := s.egressGrantCheck(ctx, added)
+ if ref != nil {
+ return nil, ref.Status, ref.Msg
+ }
+ return notChecked, 0, ""
}
// auditRequired records the change's event and returns its failure: for the
diff --git a/internal/console/egressfleet.go b/internal/console/egressfleet.go
new file mode 100644
index 000000000..554253006
--- /dev/null
+++ b/internal/console/egressfleet.go
@@ -0,0 +1,128 @@
+// The grant-time fleet check (instance sizes and egress spec §4.2, ruling
+// 8, #328): an egress allow may not open an address a box of this fleet
+// holds. Each box publishes its addresses as its edges file's addrs
+// (internal/edgesfile); the policy door checks the addresses a grant adds
+// against every readable file under control/edges/, whatever its age, so a
+// retired box's retained file keeps excluding its addresses until an
+// operator removes it.
+//
+// The check fails closed on what it cannot see: a file it cannot read, a
+// box whose file has no addrs (an older box), or a listing that failed
+// refuses the grant. Boxes that publish no edges file at all (bucketless
+// fleet boxes) cannot be checked; the grant goes through and the door's
+// reply names them as not_checked.
+//
+// Only additions are checked (ruling C5): a revoke, a re-send of the same
+// list or a size-only change reads nothing, so a store outage never holds
+// one up. A grant reads the edges files through the console's AddrCache,
+// so an unchanged control/edges/ costs one listing and no Gets.
+package console
+
+import (
+ "context"
+ "fmt"
+ "net/http"
+ "net/netip"
+ "slices"
+ "strings"
+ "time"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+ "github.com/carlosframework/platform/internal/egressaddr"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// Door copy (drafts, collected for review in plan 2 Task 17).
+const (
+ egressFleetHeldMsg = "%s is an address of box %s. An egress allow cannot open a box of this fleet."
+ egressFleetUnreadableMsg = "Box %s's address list could not be read. Try again in a minute."
+ egressFleetOlderBoxMsg = "Box %s does not publish its addresses yet. Upgrade it before granting an egress allow."
+ egressFleetListMsg = "The fleet's address lists could not be read. Try again in a minute."
+ egressFleetBoxesMsg = "The fleet's list of boxes could not be read. Try again in a minute."
+)
+
+// egressGrantCheck checks the addresses a grant adds (new minus old) against
+// every readable edges file, whatever its age. notChecked: labels of
+// non-stale boxes in systemBoxes that publish no edges file.
+//
+// The refusals, in order: an added address a file lists (409, naming the
+// box); a listed file that could not be read (503, naming it); a file with
+// no addrs (409, naming its box); a failed listing of control/edges/ or of
+// the boxes (503). With nothing added it reads nothing.
+func (s *Server) egressGrantCheck(ctx context.Context, added []netip.Addr) (notChecked []string, ref *doorRefusal) {
+ if len(added) == 0 {
+ return []string{}, nil
+ }
+ if s.cfg.Releases == nil {
+ return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetListMsg}
+ }
+ inv, err := edgesfile.ReadAddrsCached(ctx, s.cfg.Releases, &s.egressAddrs)
+ if err != nil {
+ s.policyLogf("console: egress grant check: list %s: %v", edgesfile.Prefix, err)
+ return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetListMsg}
+ }
+ for _, a := range added {
+ if box, ok := inv.Holder(a); ok {
+ return nil, &doorRefusal{http.StatusConflict, fmt.Sprintf(egressFleetHeldMsg, a, box)}
+ }
+ }
+ if len(inv.Unreadable) > 0 {
+ s.policyLogf("console: egress grant check: unreadable edges files: %s", strings.Join(inv.Unreadable, ", "))
+ return nil, &doorRefusal{http.StatusServiceUnavailable, fmt.Sprintf(egressFleetUnreadableMsg, edgesKeyBox(inv.Unreadable[0]))}
+ }
+ if len(inv.Missing) > 0 {
+ return nil, &doorRefusal{http.StatusConflict, fmt.Sprintf(egressFleetOlderBoxMsg, inv.Missing[0])}
+ }
+
+ // Not checked: live boxes with no file. A partial box list would name
+ // fewer boxes than cannot be checked, so it refuses like a failed one.
+ boxes, partial, err := s.systemBoxes(ctx, false)
+ if err != nil || partial {
+ s.policyLogf("console: egress grant check: boxes (partial %t): %v", partial, err)
+ return nil, &doorRefusal{http.StatusServiceUnavailable, egressFleetBoxesMsg}
+ }
+ published := make(map[string]bool, len(inv.Boxes))
+ for b := range inv.Boxes {
+ published[b] = true
+ }
+ now := time.Now()
+ notChecked = []string{}
+ for _, b := range boxes {
+ if published[b.Label] || status.BoxStale(b, now, status.SnapshotPeriod) {
+ continue
+ }
+ notChecked = append(notChecked, b.Label)
+ }
+ slices.Sort(notChecked)
+ return slices.Compact(notChecked), nil
+}
+
+// edgesKeyBox is the box an edges file's key names: control/edges/<box>.json.
+func edgesKeyBox(key string) string {
+ return strings.TrimSuffix(strings.TrimPrefix(key, edgesfile.Prefix), ".json")
+}
+
+// grantAdded is next minus old, as addresses: what a grant opens that the
+// stored allow did not. next is the normalized list, so an entry that does
+// not parse is refused with egressaddr's reason; an old entry that does not
+// parse matches nothing.
+func grantAdded(old, next []string) ([]netip.Addr, error) {
+ had := make(map[netip.Addr]bool, len(old))
+ for _, o := range old {
+ if a, err := egressaddr.Parse(o); err == nil {
+ had[a] = true
+ }
+ }
+ var added []netip.Addr
+ for _, n := range next {
+ a, err := egressaddr.Parse(n)
+ if err != nil {
+ return nil, err
+ }
+ if !had[a] {
+ had[a] = true
+ added = append(added, a)
+ }
+ }
+ return added, nil
+}
diff --git a/internal/console/egressfleet_test.go b/internal/console/egressfleet_test.go
new file mode 100644
index 000000000..57c470316
--- /dev/null
+++ b/internal/console/egressfleet_test.go
@@ -0,0 +1,359 @@
+package console
+
+import (
+ "context"
+ "encoding/json"
+ "errors"
+ "net/http"
+ "net/netip"
+ "slices"
+ "strings"
+ "sync"
+ "testing"
+ "time"
+
+ "github.com/carlosframework/platform/internal/edgesfile"
+ "github.com/carlosframework/platform/internal/registry"
+ "github.com/carlosframework/platform/internal/release"
+ "github.com/carlosframework/platform/internal/status"
+)
+
+// putEdgesAddrs writes control/edges/<box>.json as a box publishes it, with
+// addrs as given; nil leaves the field out (an older box).
+func putEdgesAddrs(t *testing.T, s release.Store, box string, addrs []string) {
+ t.Helper()
+ f := map[string]any{"v": 1, "box": box, "eip": "192.0.2.1", "hosts": map[string]any{}}
+ if addrs != nil {
+ f["addrs"] = addrs
+ }
+ body, err := json.Marshal(f)
+ if err != nil {
+ t.Fatal(err)
+ }
+ putFixtureObject(t, s, edgesfile.Key(box), body)
+}
+
+// edgesCountingStore counts the requests the grant check makes under
+// control/edges/ and status/, forwards ETagLister as the production stores
+// answer it, and (failing set) refuses every one of them.
+type edgesCountingStore struct {
+ release.Store
+ mu sync.Mutex
+ failing bool
+ lists map[string]int // by prefix
+ listETags map[string]int
+ gets map[string]int // by key
+}
+
+func newEdgesCountingStore(s release.Store) *edgesCountingStore {
+ return &edgesCountingStore{Store: s, lists: map[string]int{}, listETags: map[string]int{}, gets: map[string]int{}}
+}
+
+func watchedKey(key string) bool {
+ return strings.HasPrefix(key, edgesfile.Prefix) || strings.HasPrefix(key, "status/") || strings.HasPrefix(key, "fleets/")
+}
+
+func (c *edgesCountingStore) fail(on bool) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ c.failing = on
+}
+
+func (c *edgesCountingStore) count(m map[string]int, key string) bool {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ if !watchedKey(key) {
+ return false
+ }
+ m[key]++
+ return c.failing
+}
+
+func (c *edgesCountingStore) List(ctx context.Context, prefix string) ([]string, error) {
+ if c.count(c.lists, prefix) {
+ return nil, errors.New("list refused")
+ }
+ return c.Store.List(ctx, prefix)
+}
+
+func (c *edgesCountingStore) ListETags(ctx context.Context, prefix string) ([]release.KeyETag, error) {
+ if c.count(c.listETags, prefix) {
+ return nil, errors.New("list refused")
+ }
+ l, ok := c.Store.(release.ETagLister)
+ if !ok {
+ return nil, errors.ErrUnsupported
+ }
+ return l.ListETags(ctx, prefix)
+}
+
+func (c *edgesCountingStore) Get(ctx context.Context, key string) ([]byte, string, error) {
+ if c.count(c.gets, key) {
+ return nil, "", errors.New("get refused")
+ }
+ return c.Store.Get(ctx, key)
+}
+
+// requests is every counted request, then the counts are zeroed.
+func (c *edgesCountingStore) requests() (lists, listETags, gets int) {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ lists, listETags, gets = countSum(c.lists), countSum(c.listETags), countSum(c.gets)
+ c.lists, c.listETags, c.gets = map[string]int{}, map[string]int{}, map[string]int{}
+ return lists, listETags, gets
+}
+
+func countSum(m map[string]int) int {
+ n := 0
+ for _, v := range m {
+ n += v
+ }
+ return n
+}
+
+// edgesGets is the Gets of edges files alone, then all counts are kept.
+func (c *edgesCountingStore) edgesGets() int {
+ c.mu.Lock()
+ defer c.mu.Unlock()
+ n := 0
+ for k, v := range c.gets {
+ if strings.HasPrefix(k, edgesfile.Prefix) {
+ n += v
+ }
+ }
+ return n
+}
+
+// grantServer is a bare console over a fresh bucket (no registry, so no
+// fleets): enough for egressGrantCheck, which reads only the store.
+func grantServer(t *testing.T) (*Server, *edgesCountingStore) {
+ t.Helper()
+ cs := newEdgesCountingStore(release.NewDirStore(t.TempDir()))
+ return &Server{cfg: Config{Releases: cs}, policyLog: func(string, ...any) {}}, cs
+}
+
+func addrs(t *testing.T, ss ...string) []netip.Addr {
+ t.Helper()
+ out := make([]netip.Addr, 0, len(ss))
+ for _, s := range ss {
+ out = append(out, netip.MustParseAddr(s))
+ }
+ return out
+}
+
+// An added address any edges file lists is refused, naming the box,
+// whatever the file's age: a retired box's retained file, whose status
+// snapshot has long gone stale, still excludes its addresses.
+func TestEgressGrantRefusesAFleetAddress(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ now := time.Now()
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.1.5", "fd00:5::/64"})
+ setBoxSnapshot(t, cs, "annie", now)
+ putEdgesAddrs(t, cs, "olive", []string{"10.0.5.20"})
+ setBoxSnapshot(t, cs, "olive", now.Add(-24*time.Hour))
+ if !status.BoxStale(status.Box{GeneratedAt: now.Add(-24 * time.Hour)}, now, status.SnapshotPeriod) {
+ t.Fatal("olive's snapshot is not stale; the fixture tests nothing")
+ }
+
+ for _, c := range []struct {
+ add []string
+ want string
+ }{
+ {[]string{"10.0.5.20"}, "10.0.5.20 is an address of box olive. An egress allow cannot open a box of this fleet."},
+ {[]string{"10.0.9.9", "10.0.1.5"}, "10.0.1.5 is an address of box annie. An egress allow cannot open a box of this fleet."},
+ {[]string{"fd00:5::20"}, "fd00:5::20 is an address of box annie. An egress allow cannot open a box of this fleet."},
+ } {
+ nc, ref := s.egressGrantCheck(context.Background(), addrs(t, c.add...))
+ if ref == nil || ref.Status != http.StatusConflict || ref.Msg != c.want {
+ t.Errorf("grant %v = %v %+v, want 409 %q", c.add, nc, ref, c.want)
+ }
+ }
+ nc, ref := s.egressGrantCheck(context.Background(), addrs(t, "10.0.5.21"))
+ if ref != nil || nc == nil || len(nc) != 0 {
+ t.Fatalf("an address no box lists = %#v %+v, want [] and no refusal", nc, ref)
+ }
+}
+
+// Any listed file that cannot be read refuses the grant (503, naming the
+// file's box), and so does a failed listing: the check does not pass what
+// it could not see.
+func TestEgressGrantRefusesWhileAFileIsUnreadable(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.1.5"})
+ putFixtureObject(t, cs, edgesfile.Key("betty"), []byte(`{"v":1,"box":"betty",`))
+ nc, ref := s.egressGrantCheck(context.Background(), addrs(t, "10.0.5.20"))
+ if want := "Box betty's address list could not be read. Try again in a minute."; ref == nil ||
+ ref.Status != http.StatusServiceUnavailable || ref.Msg != want {
+ t.Fatalf("an unreadable file = %v %+v, want 503 %q", nc, ref, want)
+ }
+
+ cs.fail(true)
+ nc, ref = s.egressGrantCheck(context.Background(), addrs(t, "10.0.5.20"))
+ if want := "The fleet's address lists could not be read. Try again in a minute."; ref == nil ||
+ ref.Status != http.StatusServiceUnavailable || ref.Msg != want {
+ t.Fatalf("a failed listing = %v %+v, want 503 %q", nc, ref, want)
+ }
+}
+
+// A box whose file has no addrs (an older box, or null) has addresses the
+// check cannot see: the grant is refused until it is upgraded.
+func TestEgressGrantRefusesAnOlderBox(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.1.5"})
+ putEdgesAddrs(t, cs, "betty", nil)
+ nc, ref := s.egressGrantCheck(context.Background(), addrs(t, "10.0.5.20"))
+ if want := "Box betty does not publish its addresses yet. Upgrade it before granting an egress allow."; ref == nil ||
+ ref.Status != http.StatusConflict || ref.Msg != want {
+ t.Fatalf("an older box = %v %+v, want 409 %q", nc, ref, want)
+ }
+}
+
+// Boxes that publish no edges file at all (bucketless fleet boxes) cannot
+// be checked: the grant goes through and names them. A stale box is not
+// named, nor is a box with a file (with or without addresses of its own).
+func TestEgressGrantNamesBoxesNotChecked(t *testing.T) {
+ t.Parallel()
+ fx := newConsoleFixture(t)
+ now := time.Now()
+ putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"})
+ setBoxSnapshot(t, fx.rel, "annie", now)
+ putEdgesAddrs(t, fx.rel, "dora", []string{})
+ setBoxSnapshot(t, fx.rel, "dora", now)
+ setBoxSnapshot(t, fx.rel, "bert", now) // no edges file: not checked
+ setBoxSnapshot(t, fx.rel, "cleo", now.Add(-24*time.Hour)) // stale, no file: not named
+ reg, err := registry.Open(fx.regPath)
+ if err != nil {
+ t.Fatal(err)
+ }
+ if _, err := reg.CreateFleet(registry.Fleet{Name: "fx", Account: fx.sqid, Bucket: "fx-data"}); err != nil {
+ t.Fatal(err)
+ }
+ reg.Close()
+ setBoxSnapshot(t, release.NewPrefixStore(fx.rel, "fleets/fx/"), "bx-1", now) // a fleet box: no edges file
+
+ nc, ref := fx.srv.egressGrantCheck(context.Background(), addrs(t, "10.0.5.20"))
+ if ref != nil {
+ t.Fatalf("refused: %+v", ref)
+ }
+ if want := []string{"bert", "bx-1"}; !slices.Equal(nc, want) {
+ t.Fatalf("not checked = %v, want %v", nc, want)
+ }
+}
+
+// Only the addresses a grant adds are checked (Review Focus 4). An allowed
+// address a box has since taken does not block an unrelated addition, and
+// a revoke or a no-op re-send reads nothing at all, so a store outage never
+// holds one up (ruling C5). A second grant over an unchanged edges prefix
+// costs one listing and no Gets of edges files (the request budget).
+func TestEgressGrantChecksOnlyAddedAddresses(t *testing.T) {
+ t.Parallel()
+ s, cs := grantServer(t)
+ putEdgesAddrs(t, cs, "annie", []string{"10.0.5.20"})
+ putEdgesAddrs(t, cs, "betty", []string{"10.0.1.6"})
+ cs.requests() // the fixture's own writes
+ ctx := context.Background()
+
+ nc, st, msg := s.checkEgressGrant(ctx, nil, "shop", []string{"10.0.5.20"}, []string{"10.0.5.20", "10.0.5.21"})
+ if st != 0 || nc == nil || len(nc) != 0 {
+ t.Fatalf("adding 10.0.5.21 beside a held 10.0.5.20 = %v %d %q, want [] 0", nc, st, msg)
+ }
+ if got := cs.edgesGets(); got != 2 {
+ t.Fatalf("the first grant read %d edges files, want 2", got)
+ }
+ cs.requests()
+ if _, st, msg := s.checkEgressGrant(ctx, nil, "shop", nil, []string{"10.0.5.22"}); st != 0 {
+ t.Fatalf("a second grant = %d %q", st, msg)
+ }
+ if got := cs.edgesGets(); got != 0 {
+ t.Fatalf("a second grant over unchanged edges files read %d of them again", got)
+ }
+ if cs.listETags[edgesfile.Prefix] != 1 || cs.lists[edgesfile.Prefix] != 0 {
+ t.Fatalf("a second grant listed edges %d times with ETags and %d without, want 1 and 0",
+ cs.listETags[edgesfile.Prefix], cs.lists[edgesfile.Prefix])
+ }
+ if _, st, _ := s.checkEgressGrant(ctx, nil, "shop", []string{"10.0.5.20"}, []string{"10.0.5.20", "10.0.1.6"}); st != http.StatusConflict {
+ t.Fatalf("adding betty's address = %d, want 409", st)
+ }
+
+ cs.fail(true)
+ cs.requests()
+ for _, c := range []struct{ old, next []string }{
+ {[]string{"10.0.5.20", "10.0.5.21"}, []string{"10.0.5.21"}}, // a revoke
+ {[]string{"10.0.5.20"}, []string{}}, // revoke everything
+ {[]string{"10.0.5.20"}, []string{"10.0.5.20"}}, // the same list again
+ {nil, []string{}},
+ } {
+ nc, st, msg := s.checkEgressGrant(ctx, nil, "shop", c.old, c.next)
+ if st != 0 || nc == nil || len(nc) != 0 {
+ t.Errorf("%v -> %v with the store down = %v %d %q, want [] 0", c.old, c.next, nc, st, msg)
+ }
+ }
+ if l, le, g := cs.requests(); l+le+g != 0 {
+ t.Fatalf("a revoke made %d lists, %d ETag lists and %d gets, want none", l, le, g)
+ }
+}
+
+// The door's reply names the boxes it could not check, in the JSON a CLI
+// reads.
+func TestPolicyDoorReplyCarriesNotChecked(t *testing.T) {
+ t.Parallel()
+ fx := newPolicyFx(t, "code-policy-not-checked")
+ now := time.Now()
+ putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.1.5"})
+ setBoxSnapshot(t, fx.rel, "annie", now)
+ setBoxSnapshot(t, fx.rel, "bert", now)
+ st, _, out := policyReq(t, fx.consoleFixture, http.MethodPut, "shop", fx.owner, `{"egress_allow":["10.0.5.20"]}`, policyCreate)
+ if st != http.StatusOK || !strings.Contains(out, `"not_checked":["bert"]`) {
+ t.Fatalf("PUT = %d %s, want 200 with not_checked [bert]", st, out)
+ }
+}
+
+// Through the door, with control/edges/ and the status snapshots down: a
+// revoke and a size-only change go through and read neither, and only an
+// addition is refused (ruling C5).
+func TestPolicyDoorRevokeGoesThroughAnEdgesOutage(t *testing.T) {
+ t.Parallel()
+ fx := newPolicyFx(t, "code-policy-revoke-outage")
+ first := fx.mustPut(t, "shop", `{"egress_allow":["10.0.5.20","10.0.5.21"]}`, policyCreate)
+ cs := newEdgesCountingStore(fx.srv.cfg.Releases)
+ fx.srv.cfg.Releases = cs
+ cs.fail(true)
+
+ revoked := fx.mustPut(t, "shop", `{"egress_allow":["10.0.5.21"]}`, policyIfMatch(first.ETag))
+ if !slices.Equal(revoked.Policy.EgressAllow, []string{"10.0.5.21"}) || revoked.NotChecked == nil || len(revoked.NotChecked) != 0 {
+ t.Fatalf("revoke reply %+v", revoked)
+ }
+ sized := fx.mustPut(t, "shop", `{"default_size":"large"}`, policyIfMatch(revoked.ETag))
+ if l, le, g := cs.requests(); l+le+g != 0 {
+ t.Fatalf("a revoke and a size change made %d lists, %d ETag lists and %d gets of edges or status, want none", l, le, g)
+ }
+ if st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.5.21","10.0.5.22"]}`, policyIfMatch(sized.ETag)); st != http.StatusServiceUnavailable {
+ t.Fatalf("an addition with edges down = %d %s, want 503", st, out)
+ }
+}
+
+// A refused check writes nothing: no audit event, no policy object, no row,
+// no serial bump.
+func TestPolicyDoorWritesNothingWhenTheCheckRefuses(t *testing.T) {
+ t.Parallel()
+ fx := newPolicyFx(t, "code-policy-check-refuses")
+ putEdgesAddrs(t, fx.rel, "annie", []string{"10.0.5.20"})
+ before := fx.serial(t)
+ st, _, out := fx.put(t, "shop", `{"egress_allow":["10.0.5.20"],"default_size":"large"}`, policyCreate)
+ if want := "10.0.5.20 is an address of box annie. An egress allow cannot open a box of this fleet."; st != http.StatusConflict || errorOf(t, out) != want {
+ t.Fatalf("PUT = %d %s, want 409 %q", st, out, want)
+ }
+ fx.noObject(t, "shop")
+ if evs := fx.policyEvents(t, "shop"); len(evs) != 0 {
+ t.Fatalf("a refused grant recorded events: %+v", evs)
+ }
+ if row := fx.row(t, "shop"); row.Revision != 0 {
+ t.Fatalf("a refused grant recorded a row: %+v", row)
+ }
+ if got := fx.serial(t); got != before {
+ t.Fatalf("serial %d, want %d", got, before)
+ }
+}
diff --git a/internal/console/server.go b/internal/console/server.go
index 6958e14cd..99424ec66 100644
--- a/internal/console/server.go
+++ b/internal/console/server.go
@@ -1180,6 +1180,11 @@ type Server struct {
// plus one Get per edges file behind every row of every listing. Zero
// value is ready to use.
edgeFold edgeFoldCache
+ // egressAddrs is the box addresses read from control/edges/, each file
+ // kept under its ETag (edgesfile.AddrCache): the egress grant check
+ // (egressfleet.go) re-reads only a file that changed. Zero value is
+ // ready to use.
+ egressAddrs edgesfile.AddrCache
// edgeProof is the mesh-key cache and the seen latch behind clientIP's
// loopback check (edgeproof.go). Zero value is ready to use.
edgeProof edgeProofState