Documentation ¶
Index ¶
- Variables
- type Host
- func (h *Host) AddDirectPeer(dp ma.Multiaddr) error
- func (h *Host) ClearDirectPeers()
- func (h *Host) ConnectionManager() manager.ConnectionManager
- func (h *Host) Context() context.Context
- func (h *Host) Dial(remoteAddr ma.Multiaddr) (network.Connection, error)
- func (h *Host) ID() peer.ID
- func (h *Host) LocalAddresses() []ma.Multiaddr
- func (h *Host) Logger() *rainbowlog.Logger
- func (h *Host) Network() network.Network
- func (h *Host) Notify(notifiee host.Notifiee)
- func (h *Host) PeerBlackList() blacklist.PeerBlackList
- func (h *Host) PeerProtocols(protocolIDs []protocol.ID) (peerProtocols []*host.PeerProtocols, err error)
- func (h *Host) PeerStore() store.PeerStore
- func (h *Host) PeerSupportProtocol(pid peer.ID, protocolID protocol.ID) bool
- func (h *Host) ProtocolManager() manager.ProtocolManager
- func (h *Host) RegisterMsgPayloadHandler(protocolID protocol.ID, handler handler.MsgPayloadHandler) error
- func (h *Host) SendMsg(protocolID protocol.ID, receiverPID peer.ID, msgPayload []byte) (err error)
- func (h *Host) Start() (err error)
- func (h *Host) Stop() error
- func (h *Host) UnregisterMsgPayloadHandler(protocolID protocol.ID) error
- type NetworkConfig
- type NetworkType
- type Option
- func WithBlackNetAddr(netAddr ...string) Option
- func WithBlackPIDs(pid ...peer.ID) Option
- func WithBlacklist(blacklist blacklist.PeerBlackList) Option
- func WithConnectionManager(connMgr manager.ConnectionManager) Option
- func WithConnectionSupervisor(supervisor manager.ConnectionSupervisor) Option
- func WithContext(ctx context.Context) Option
- func WithDirectPeer(pid peer.ID, address ma.Multiaddr) Option
- func WithEasyToUseTLS(priKey cc.PriKey) Option
- func WithHandlerExecutorConcurrency(puc uint8) Option
- func WithListenAddresses(addresses ...ma.Multiaddr) Option
- func WithMsgCompressible() Option
- func WithNetworkType(networkType NetworkType) Option
- func WithPayloadHandlerRouterConcurrency(c uint8) Option
- func WithPayloadUnmarshalConcurrency(c uint8) Option
- func WithPeerStore(peerStore store.PeerStore) Option
- func WithPriKey(priKey cc.PriKey) Option
- func WithProtocolExchanger(protocolExr manager.ProtocolExchanger) Option
- func WithProtocolManager(protocolMgr manager.ProtocolManager) Option
- func WithReceiveStreamMgr(receiveStreamMgr manager.ReceiveStreamManager) Option
- func WithSendStreamMgr(sendStreamMgr manager.SendStreamPoolManager) Option
- func WithSendStreamPoolBuilder(builder manager.SendStreamPoolBuilder) Option
- func WithTLS(tlsConfig *tls.Config, pidLoader peer.IDLoader) Option
Constants ¶
This section is empty.
Variables ¶
var ( ErrPeerNotConnected = errors.New("peer is not connected") ErrProtocolNotSupported = errors.New("protocol is not supported") ErrSendStreamPoolNotFound = errors.New("send stream pool not found") ErrSendStreamWriteFailed = errors.New("failed to write to send stream") ErrWriteMsgIncompletely = errors.New("write msg incompletely") ErrInvalidAddr = errors.New("invalid address") ErrNoAddressFoundInStore = errors.New("no address found in store") ErrAllDialFailed = errors.New("all dial failed") )
var ( ErrNilTLSConfig = errors.New("nil tls config") ErrUnknownNetworkType = errors.New("unknown network type") )
Functions ¶
This section is empty.
Types ¶
type Host ¶
type Host struct {
// contains filtered or unexported fields
}
Host is the main struct representing the Rainbow-bee host.
func NewHost ¶
func NewHost(logger *rainbowlog.Logger, opts ...Option) (h *Host, err error)
NewHost creates a new host with the provided options.
func (*Host) AddDirectPeer ¶
AddDirectPeer adds a direct peer to the host.
func (*Host) ClearDirectPeers ¶
func (h *Host) ClearDirectPeers()
ClearDirectPeers removes all direct peers from the host.
func (*Host) ConnectionManager ¶
func (h *Host) ConnectionManager() manager.ConnectionManager
ConnectionManager returns the connection manager associated with the host.
func (*Host) LocalAddresses ¶
LocalAddresses returns the list of multiaddresses the host is listening on.
func (*Host) Logger ¶
func (h *Host) Logger() *rainbowlog.Logger
func (*Host) PeerBlackList ¶
func (h *Host) PeerBlackList() blacklist.PeerBlackList
PeerBlackList returns the peer blacklist associated with the host.
func (*Host) PeerProtocols ¶
func (h *Host) PeerProtocols(protocolIDs []protocol.ID) (peerProtocols []*host.PeerProtocols, err error)
PeerProtocols returns a list of peer protocols that match the specified protocol IDs.
func (*Host) PeerSupportProtocol ¶
PeerSupportProtocol checks if a peer supports a specific protocol.
func (*Host) ProtocolManager ¶
func (h *Host) ProtocolManager() manager.ProtocolManager
ProtocolManager returns the protocol manager associated with the host.
func (*Host) RegisterMsgPayloadHandler ¶
func (h *Host) RegisterMsgPayloadHandler(protocolID protocol.ID, handler handler.MsgPayloadHandler) error
RegisterMsgPayloadHandler registers a message payload handler for a given protocol ID.
func (*Host) SendMsg ¶
SendMsg sends a message payload to a specific peer using the specified protocol ID.
type NetworkConfig ¶
type NetworkConfig struct { Type NetworkType Ctx context.Context PrivateKey cc.PriKey TLSEnabled bool TLSConfig *tls.Config PIDLoader peer.IDLoader // contains filtered or unexported fields }
NetworkConfig represents the configuration for creating a network instance.
func (NetworkConfig) NewNetwork ¶
func (c NetworkConfig) NewNetwork(logger *rainbowlog.Logger) (network.Network, error)
NewNetwork creates a new network instance based on the configuration.
type NetworkType ¶
type NetworkType uint8
NetworkType represents the type of network.
const ( NetworkTypeUnknown NetworkType = iota NetworkTypeTCP NetworkTypeUDPQuic )
func (NetworkType) String ¶
func (t NetworkType) String() string
String returns the string representation of the NetworkType.
type Option ¶
Option represents an option function for configuring a Host.
func WithBlackNetAddr ¶
WithBlackNetAddr adds blacklisted network addresses to the Host.
func WithBlackPIDs ¶
WithBlackPIDs adds blacklisted peer IDs to the Host.
func WithBlacklist ¶
func WithBlacklist(blacklist blacklist.PeerBlackList) Option
WithBlacklist sets the peer blacklist for the Host.
func WithConnectionManager ¶
func WithConnectionManager(connMgr manager.ConnectionManager) Option
WithConnectionManager sets the connection manager for the Host.
func WithConnectionSupervisor ¶
func WithConnectionSupervisor(supervisor manager.ConnectionSupervisor) Option
WithConnectionSupervisor sets the connection supervisor for the Host.
func WithContext ¶
WithContext sets the context for the Host.
func WithDirectPeer ¶
WithDirectPeer adds a direct peer with the given peer ID and address to the Host.
func WithEasyToUseTLS ¶
WithEasyToUseTLS will perform the same logic as WithPriKey and use the given priKey to generate a tls.Config with a self-signed certificate and also set up a corresponding PIDLoader. This option facilitates quick start for users who do not require custom tls.Config.
func WithHandlerExecutorConcurrency ¶
WithHandlerExecutorConcurrency sets the concurrency of the handler executor.
func WithListenAddresses ¶
WithListenAddresses sets the listen addresses for the Host.
func WithMsgCompressible ¶
func WithMsgCompressible() Option
WithMsgCompressible sets the Host to compress messages.
func WithNetworkType ¶
func WithNetworkType(networkType NetworkType) Option
WithNetworkType sets the network type for the Host.
func WithPayloadHandlerRouterConcurrency ¶
WithPayloadHandlerRouterConcurrency sets the concurrency of the payload handler router.
func WithPayloadUnmarshalConcurrency ¶
WithPayloadUnmarshalConcurrency sets the concurrency of the payload unmarshaler.
func WithPeerStore ¶
WithPeerStore sets the peer store for the Host.
func WithPriKey ¶
WithPriKey sets the private key for the Host. This Option will also set the Local PID at the same time.
func WithProtocolExchanger ¶
func WithProtocolExchanger(protocolExr manager.ProtocolExchanger) Option
WithProtocolExchanger sets the protocol exchanger for the Host.
func WithProtocolManager ¶
func WithProtocolManager(protocolMgr manager.ProtocolManager) Option
WithProtocolManager sets the protocol manager for the Host.
func WithReceiveStreamMgr ¶
func WithReceiveStreamMgr(receiveStreamMgr manager.ReceiveStreamManager) Option
WithReceiveStreamMgr sets the receive stream manager for the Host.
func WithSendStreamMgr ¶
func WithSendStreamMgr(sendStreamMgr manager.SendStreamPoolManager) Option
WithSendStreamMgr sets the send stream pool manager for the Host.
func WithSendStreamPoolBuilder ¶
func WithSendStreamPoolBuilder(builder manager.SendStreamPoolBuilder) Option
WithSendStreamPoolBuilder sets the send stream pool builder for the Host.