dhtrouter

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const ValidatorNamespace = "peerinfo"

Variables

View Source
var InvalidDhtKey = errors.New("invalid dht key")

Functions

func ACLQueryFilter

func ACLQueryFilter(acl ACL, protocol protocol.ID, logger commontypes.Logger) dht.QueryFilterFunc

ACLQueryFilter is a filter applied when considering peers to dial when querying

func ACLRoutingTableFilter

func ACLRoutingTableFilter(acl ACL, protocol protocol.ID, logger commontypes.Logger) dht.RouteTableFilterFunc

ACLRoutingTableFilter is a filter applied when considering connections to keep in the local route table.

Types

type ACL

type ACL interface {
	// if an ID in the white list of a protocol
	IsAllowed(id peer.ID, protocol protocol.ID) bool

	// if ACL is enforced for a protocol
	IsACLEnforced(protocol protocol.ID) bool

	String() string
}

type ACLHost

type ACLHost interface {
	host.Host

	SetACL(acl ACL)
	GetACL() ACL
}

func WrapACL

func WrapACL(h host.Host, acl ACL, logger loghelper.LoggerWithContext) ACLHost

type AnnouncementValidator

type AnnouncementValidator struct{}

AnnouncementValidator verifies peer announcements

func (AnnouncementValidator) Select

func (v AnnouncementValidator) Select(_ string, values [][]byte) (int, error)

Select returns the latest (i.e., the one with the largest counter)

func (AnnouncementValidator) Validate

func (v AnnouncementValidator) Validate(key string, value []byte) error

Validate 1) extracts the pk from DHT key; 2) checks value is properly signed with pk

type BasicACLHost

type BasicACLHost struct {
	// contains filtered or unexported fields
}

func (BasicACLHost) Addrs

func (aclHost BasicACLHost) Addrs() []ma.Multiaddr

func (BasicACLHost) Close

func (aclHost BasicACLHost) Close() error

func (BasicACLHost) ConnManager

func (aclHost BasicACLHost) ConnManager() connmgr.ConnManager

func (BasicACLHost) Connect

func (aclHost BasicACLHost) Connect(ctx context.Context, pi peer.AddrInfo) error

func (BasicACLHost) EventBus

func (aclHost BasicACLHost) EventBus() event.Bus

func (BasicACLHost) GetACL

func (aclHost BasicACLHost) GetACL() ACL

func (BasicACLHost) ID

func (aclHost BasicACLHost) ID() peer.ID

func (BasicACLHost) Mux

func (aclHost BasicACLHost) Mux() protocol.Switch

func (BasicACLHost) Network

func (aclHost BasicACLHost) Network() p2pnetwork.Network

func (BasicACLHost) NewStream

func (aclHost BasicACLHost) NewStream(ctx context.Context, p peer.ID, pids ...protocol.ID) (p2pnetwork.Stream, error)

func (BasicACLHost) Peerstore

func (aclHost BasicACLHost) Peerstore() peerstore.Peerstore

func (BasicACLHost) RemoveStreamHandler

func (aclHost BasicACLHost) RemoveStreamHandler(pid protocol.ID)

func (*BasicACLHost) SetACL

func (aclHost *BasicACLHost) SetACL(acl ACL)

func (BasicACLHost) SetStreamHandler

func (aclHost BasicACLHost) SetStreamHandler(protocol protocol.ID, handler p2pnetwork.StreamHandler)

func (BasicACLHost) SetStreamHandlerMatch

func (aclHost BasicACLHost) SetStreamHandlerMatch(id protocol.ID, f func(string) bool, handler p2pnetwork.StreamHandler)

type DHTNodeConfig

type DHTNodeConfig struct {
	// contains filtered or unexported fields
}

func BuildConfig

func BuildConfig(
	bootstrapNodes []peer.AddrInfo,
	prefix protocol.ID,
	configDigest ocr1types.ConfigDigest,
	logger loghelper.LoggerWithContext,
	bootstrapConnectionCheckInterval time.Duration,
	failureThreshold int,
	extendedDHTLogging bool,
	announcementUserPrefix uint32,
) DHTNodeConfig

func (*DHTNodeConfig) AddBootstrapNodes

func (config *DHTNodeConfig) AddBootstrapNodes(addrs []peer.AddrInfo)

func (DHTNodeConfig) ProtocolID

func (config DHTNodeConfig) ProtocolID() protocol.ID

func (DHTNodeConfig) String

func (config DHTNodeConfig) String() string

type DHTRouter

type DHTRouter struct {
	// contains filtered or unexported fields
}

func (DHTRouter) Close

func (router DHTRouter) Close() error

func (DHTRouter) FindPeer

func (router DHTRouter) FindPeer(ctx context.Context, peerId peer.ID) (addr peer.AddrInfo, error error)

func (DHTRouter) ProtocolID

func (router DHTRouter) ProtocolID() p2pprotocol.ID

func (DHTRouter) Start

func (router DHTRouter) Start()

type PeerDiscoveryRouter

type PeerDiscoveryRouter interface {
	rhost.Routing
	Start()
	Close() error
	ProtocolID() p2pprotocol.ID
}

PeerDiscoveryRouter is a router (rhost.Routing) with resource management capabilities via Start() and Close()

func NewDHTRouter

func NewDHTRouter(ctx context.Context, config DHTNodeConfig, aclHost ACLHost) (PeerDiscoveryRouter, error)

type PermitListACL

type PermitListACL interface {
	ACL

	// Activate ACL for a protocol with the provided allowlist.
	// No-op if ACL is already activated for that protocol
	Activate(protocol protocol.ID, permitted ...peer.ID)

	// Deactivate ACL for a protocol. No-op if not already activated
	Deactivate(protocol protocol.ID)

	// add ids to the allowlist for protocol. Error if not already activated
	Permit(protocol protocol.ID, ids ...peer.ID) error

	// remove id from the allowlist. Error if not already activated.
	Reject(protocol protocol.ID, id peer.ID) error
}

func NewPermitListACL

func NewPermitListACL(logger loghelper.LoggerWithContext) PermitListACL

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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