Agent Mesh
Go a2aa2a-protocolagent-meshagentic-aiinferencemcpmeshmesh-networknetwork-securitynetworking-aip2p-network
also check acl on dst on nodes
Antonio Ojeadbdf0d86278c
diff --git a/cmd/sam-node/node.go b/cmd/sam-node/node.goindex 00926ab2..2595bcaf 100644--- a/cmd/sam-node/node.go+++ b/cmd/sam-node/node.go@@ -88,7 +88,7 @@ func (a *nodeRelayACL) AllowReserve(p peer.ID, addr multiaddr.Multiaddr) bool {}func (a *nodeRelayACL) AllowConnect(src peer.ID, srcAddr multiaddr.Multiaddr, dest peer.ID) bool {- _, ok := a.node.authPeers.Load(src)+ _, ok := a.node.authPeers.Load(dest)return ok}diff --git a/cmd/sam-node/relay_acl_test.go b/cmd/sam-node/relay_acl_test.gonew file mode 100644index 00000000..abfdc6a6--- /dev/null+++ b/cmd/sam-node/relay_acl_test.go@@ -0,0 +1,66 @@+// Copyright 2026 Google LLC+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+//+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package main++import (+ "testing"++ "github.com/libp2p/go-libp2p/core/peer"+ "github.com/multiformats/go-multiaddr"+)++func TestNodeRelayACL_AllowConnect(t *testing.T) {+ node := &SamNode{}+ acl := &nodeRelayACL{node: node}++ srcPeer := peer.ID("src-peer")+ destPeer := peer.ID("dest-peer")+ srcAddr, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1234")++ // Neither is authenticated+ if acl.AllowConnect(srcPeer, srcAddr, destPeer) {+ t.Errorf("Expected AllowConnect to return false when dest is not authenticated")+ }++ // Src is authenticated, dest is not -> should fail+ node.authPeers.Store(srcPeer, struct{}{})+ if acl.AllowConnect(srcPeer, srcAddr, destPeer) {+ t.Errorf("Expected AllowConnect to return false when dest is not authenticated, even if src is")+ }++ // Dest is authenticated, src is not -> should succeed+ node.authPeers.Delete(srcPeer)+ node.authPeers.Store(destPeer, struct{}{})+ if !acl.AllowConnect(srcPeer, srcAddr, destPeer) {+ t.Errorf("Expected AllowConnect to return true when dest is authenticated")+ }+}++func TestNodeRelayACL_AllowReserve(t *testing.T) {+ node := &SamNode{}+ acl := &nodeRelayACL{node: node}++ peerID := peer.ID("some-peer")+ addr, _ := multiaddr.NewMultiaddr("/ip4/127.0.0.1/tcp/1234")++ if acl.AllowReserve(peerID, addr) {+ t.Errorf("Expected AllowReserve to return false when peer is not authenticated")+ }++ node.authPeers.Store(peerID, struct{}{})+ if !acl.AllowReserve(peerID, addr) {+ t.Errorf("Expected AllowReserve to return true when peer is authenticated")+ }+}