allowlist

package
v0.0.0-...-8cb8a38 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 24, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PeerIDAllowList

func PeerIDAllowList(peerIDs []peer.ID) config.Option

PeerIDAllowList is a libp2p config option that configures an allowlist of Peer IDs. Any peer ID not in the allowlist will be rejected for both incoming and outgoing connections.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL