Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
fix revocation race
Antonio Ojea6fe7762f9fc0
diff --git a/cmd/sam-node/mcp_handlers.go b/cmd/sam-node/mcp_handlers.goindex c626a8e6..eb7e1b13 100644--- a/cmd/sam-node/mcp_handlers.go+++ b/cmd/sam-node/mcp_handlers.go@@ -226,6 +226,12 @@ func (n *SamNode) handleConnectPeer(ctx context.Context, req *mcp.CallToolRequesif err != nil {return nil, nil, err}+ if n.revokedPeers.Contains(addrInfo.ID.String()) {+ return nil, nil, fmt.Errorf("failed to dial: failed to dial %s: gater disallows connection to peer", addrInfo.ID)+ }+ if n.Store.IsBanned(addrInfo.ID) {+ return nil, nil, fmt.Errorf("failed to dial: failed to dial %s: gater disallows connection to peer", addrInfo.ID)+ }conns := n.Host.Network().ConnsToPeer(addrInfo.ID)connectedness := n.Host.Network().Connectedness(addrInfo.ID)logger.Debugf("[connect_peer] Target peer %s, connectedness: %v, active conns: %d", addrInfo.ID, connectedness, len(conns))diff --git a/cmd/sam-node/middleware.go b/cmd/sam-node/middleware.goindex d2d06b51..5714c242 100644--- a/cmd/sam-node/middleware.go+++ b/cmd/sam-node/middleware.go@@ -226,7 +226,8 @@ func (n *SamNode) Authorize(rawToken []byte, req RequestContext, pubKey ed25519.func (n *SamNode) injectIdentityFacts(authorizer biscuit.Authorizer, pubKey ed25519.PublicKey) error {ourIdentity := n.GetIdentity()if ourIdentity == nil {- return fmt.Errorf("node identity is missing")+ logger.Debugf("[Auth] Node identity is missing, skipping target fact injection")+ return nil}ourB, err := biscuit.Unmarshal(ourIdentity)diff --git a/tests/e2e/revocation_test.bats b/tests/e2e/revocation_test.batsindex d786eb9b..d07143b2 100644--- a/tests/e2e/revocation_test.bats+++ b/tests/e2e/revocation_test.bats@@ -113,5 +113,13 @@ teardown() {local node2_addr="/dns4/sam-node-2/tcp/5002/p2p/${node2_peer_id}"run docker run --rm --network "${MESH_NETWORK}" "${MESH_RUNTIME_IMAGE}" mcp-client -url "http://sam-node-1:8080/mcp" -tool "connect_peer" -args "{\"peer_addr\":\"${node2_addr}\"}"echo "Reconnect output: $output"++ local info_output+ info_output="$(docker run --rm --network "${MESH_NETWORK}" "${MESH_RUNTIME_IMAGE}" mcp-client -url "http://sam-node-1:8080/mcp" -tool "get_mesh_info" 2>/dev/null)"+ echo "After reconnect mesh info: ${info_output}"+ local connected+ connected="$(echo "${info_output}" | jq -r --arg peer "${node2_peer_id}" '.connected_peers | index($peer) != null')"+ echo "Connected after reconnect: ${connected}"+[[ "$output" == *"gater disallows connection"* ]]}