Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
mobile: let the operator set the egress floor on a phone node
Antonio Ojea90112da9e7ff
diff --git a/mobile/sam-node-ffi/ffi/ffi.go b/mobile/sam-node-ffi/ffi/ffi.goindex e0082d5a..bdbafe2f 100644--- a/mobile/sam-node-ffi/ffi/ffi.go+++ b/mobile/sam-node-ffi/ffi/ffi.go@@ -67,6 +67,10 @@ type MobileConfig struct {// Local attenuation, same shape as the config file's block. Go matches// these keys to the yaml-tagged fields case-insensitively.Attenuation api.Attenuation `json:"attenuation"`+ // Egress mirrors the config file's egress block: the operator's floor on+ // the peers this node calls (api.Egress). JSON spelling is requireLabels,+ // matched case-insensitively to the Go field, not the yaml require_labels.+ Egress api.Egress `json:"egress"`}// MobileService is one statically declared service.@@ -191,6 +195,7 @@ func StartNode(configJSON string) error {Attenuation: config.Attenuation,Services: services,Labels: config.Labels,+ Egress: config.Egress,})if err != nil {_ = store.Close()diff --git a/mobile/sam-node-ffi/ffi/ffi_test.go b/mobile/sam-node-ffi/ffi/ffi_test.goindex 52138435..23c48807 100644--- a/mobile/sam-node-ffi/ffi/ffi_test.go+++ b/mobile/sam-node-ffi/ffi/ffi_test.go@@ -125,6 +125,8 @@ func TestMobileFFILifecycle(t *testing.T) {ApiToken: "test-token",AllowLoopback: true,Labels: map[string]string{"region": "eu-west-1"},+ // A valid floor must not stop startup; enforcement is internal/node's.+ Egress: api.Egress{RequireLabels: map[string]string{"jurisdiction": "eu"}},}cfgBytes, _ := json.Marshal(cfg)@@ -200,6 +202,19 @@ func TestMobileConfigDecodesAttenuation(t *testing.T) {}}+// Same pin for the egress floor: it rides the yaml-tagged api.Egress, so the+// JSON spelling is requireLabels. A silent miss here would start the node+// with no floor while the operator believes one is set.+func TestMobileConfigDecodesEgressFloor(t *testing.T) {+ var config MobileConfig+ if err := json.Unmarshal([]byte(`{"egress":{"requireLabels":{"jurisdiction":"eu"}}}`), &config); err != nil {+ t.Fatalf("json.Unmarshal() error = %v", err)+ }+ if config.Egress.RequireLabels["jurisdiction"] != "eu" {+ t.Fatalf("got %+v, want the floor pair decoded", config.Egress)+ }+}+// Re-enrollment buys a JWT with the stored refresh token and re-attests the// new labels under the same PeerID, with no browser involved.func TestReEnrollNodeUsesStoredRefreshToken(t *testing.T) {