github.com/ethereum-optimism/optimism@v1.7.2/op-node/p2p/gating/blocking.go (about) 1 package gating 2 3 import ( 4 "net" 5 6 ds "github.com/ipfs/go-datastore" 7 "github.com/libp2p/go-libp2p/core/connmgr" 8 "github.com/libp2p/go-libp2p/core/peer" 9 "github.com/libp2p/go-libp2p/p2p/net/conngater" 10 ) 11 12 //go:generate mockery --name BlockingConnectionGater --output mocks/ --with-expecter=true 13 type BlockingConnectionGater interface { 14 connmgr.ConnectionGater 15 16 // BlockPeer adds a peer to the set of blocked peers. 17 // Note: active connections to the peer are not automatically closed. 18 BlockPeer(p peer.ID) error 19 UnblockPeer(p peer.ID) error 20 ListBlockedPeers() []peer.ID 21 22 // BlockAddr adds an IP address to the set of blocked addresses. 23 // Note: active connections to the IP address are not automatically closed. 24 BlockAddr(ip net.IP) error 25 UnblockAddr(ip net.IP) error 26 ListBlockedAddrs() []net.IP 27 28 // BlockSubnet adds an IP subnet to the set of blocked addresses. 29 // Note: active connections to the IP subnet are not automatically closed. 30 BlockSubnet(ipnet *net.IPNet) error 31 UnblockSubnet(ipnet *net.IPNet) error 32 ListBlockedSubnets() []*net.IPNet 33 } 34 35 func NewBlockingConnectionGater(store ds.Batching) (BlockingConnectionGater, error) { 36 return conngater.NewBasicConnectionGater(store) 37 }