Documentation ¶
Index ¶
- func PeerIDAllowList(peerIDs []peer.ID) config.Option
- type AllowListConnectionGater
- func (allowlist *AllowListConnectionGater) InterceptAccept(network.ConnMultiaddrs) bool
- func (allowlist *AllowListConnectionGater) InterceptAddrDial(peerID peer.ID, addr ma.Multiaddr) bool
- func (allowlist *AllowListConnectionGater) InterceptPeerDial(peerID peer.ID) bool
- func (allowlist *AllowListConnectionGater) InterceptSecured(direction network.Direction, peerID peer.ID, multiAddr network.ConnMultiaddrs) bool
- func (allowlist *AllowListConnectionGater) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)
- func (allowlist *AllowListConnectionGater) IsPeerIDAllowed(peerID peer.ID) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AllowListConnectionGater ¶
type AllowListConnectionGater struct { // PeerIDs is a map of allowed peer.ID, converted from a slice for // easier and constant time lookups. PeerIDs map[peer.ID]struct{} }
AllowListConnectionGater is a connmgr.ConnectionGater implementation that only allows connections to and from the specified peer IDs.
func NewAllowList ¶
func NewAllowList(peerIDs []peer.ID) *AllowListConnectionGater
NewAllowList returns a new AllowList.
func (*AllowListConnectionGater) InterceptAccept ¶
func (allowlist *AllowListConnectionGater) InterceptAccept(network.ConnMultiaddrs) bool
InterceptAccept tests whether an incipient inbound connection is allowed.
This is called by the upgrader, or by the transport directly (e.g. QUIC, Bluetooth), straight after it has accepted a connection from its socket.
func (*AllowListConnectionGater) InterceptAddrDial ¶
func (allowlist *AllowListConnectionGater) InterceptAddrDial(peerID peer.ID, addr ma.Multiaddr) bool
InterceptAddrDial tests whether we're permitted to dial the specified multiaddr for the given peer.
This is called by the network.Network implementation after it has resolved the peer's addrs, and prior to dialling each.
func (*AllowListConnectionGater) InterceptPeerDial ¶
func (allowlist *AllowListConnectionGater) InterceptPeerDial(peerID peer.ID) bool
InterceptPeerDial tests whether we're permitted to Dial the specified peer.
This is called by the network.Network implementation when dialling a peer.
func (*AllowListConnectionGater) InterceptSecured ¶
func (allowlist *AllowListConnectionGater) InterceptSecured( direction network.Direction, peerID peer.ID, multiAddr network.ConnMultiaddrs, ) bool
InterceptSecured tests whether a given connection, now authenticated, is allowed.
This is called by the upgrader, after it has performed the security handshake, and before it negotiates the muxer, or by the directly by the transport, at the exact same checkpoint.
func (*AllowListConnectionGater) InterceptUpgraded ¶
func (allowlist *AllowListConnectionGater) InterceptUpgraded(network.Conn) (bool, control.DisconnectReason)
InterceptUpgraded tests whether a fully capable connection is allowed.
At this point, the connection a multiplexer has been selected. When rejecting a connection, the gater can return a DisconnectReason. Refer to the godoc on the ConnectionGater type for more information.
NOTE: the go-libp2p implementation currently IGNORES the disconnect reason.
func (*AllowListConnectionGater) IsPeerIDAllowed ¶
func (allowlist *AllowListConnectionGater) IsPeerIDAllowed(peerID peer.ID) bool
IsPeerIDAllowed returns true if the peer ID is contained in the allowed list.