host

package
v0.12.3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2021 License: GPL-3.0 Imports: 30 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Event_STATUS = "host-status"
)

Transfer Emission Events

View Source
const UDSDir = "sock"

Variables

View Source
var (
	ErrRoutingNotSet    = errors.New("DHT and Host have not been set by Routing Function")
	ErrListenerRequired = errors.New("Listener was not Provided")
	ErrMDNSInvalidConn  = errors.New("Invalid Connection, cannot begin MDNS Service")
)

Error Definitions

Functions

This section is empty.

Types

type HostOption

type HostOption func(hostOptions)

HostOption is a function that modifies the node options.

func WithConnOptions

func WithConnOptions(low int, hi int, grace time.Duration) HostOption

WithConnOptions sets the connection manager options. Defaults are (lowWater: 15, highWater: 40, gracePeriod: 5m)

func WithConnection

func WithConnection(c common.Connection) HostOption

WithConnection sets the connection to the host. Default is WIFI.

func WithInterval

func WithInterval(interval time.Duration) HostOption

WithInterval sets the interval for the host. Default is 5 seconds.

func WithTTL

func WithTTL(ttl time.Duration) HostOption

WithTTL sets the ttl for the host. Default is 2 minutes.

type SNRHost

type SNRHost struct {
	host.Host

	// Discovery
	*dht.IpfsDHT
	*ps.PubSub
	// contains filtered or unexported fields
}

SNRHost is the host wrapper for the Sonr Network

func NewHost

func NewHost(ctx context.Context, options ...HostOption) (*SNRHost, error)

NewHost creates a new host

func (*SNRHost) AuthenticateId

func (h *SNRHost) AuthenticateId(id *wallet.UUID) (bool, error)

AuthenticateId verifies UUID value and signature

func (*SNRHost) AuthenticateMessage

func (n *SNRHost) AuthenticateMessage(msg proto.Message, metadata *common.Metadata) bool

AuthenticateMessage Authenticates incoming p2p message

func (*SNRHost) Close

func (hn *SNRHost) Close() error

Close closes the underlying host

func (*SNRHost) Connect

func (hn *SNRHost) Connect(pi peer.AddrInfo) error

Connect connects with `peer.AddrInfo` if underlying Host is ready

func (*SNRHost) HandlePeerFound

func (hn *SNRHost) HandlePeerFound(pi peer.AddrInfo)

HandlePeerFound is to be called when new peer is found

func (*SNRHost) HasRouting

func (h *SNRHost) HasRouting() error

HasRouting returns no-error if the host is ready for connect

func (*SNRHost) Join

func (hn *SNRHost) Join(topic string, opts ...ps.TopicOpt) (*ps.Topic, error)

Join wraps around PubSub.Join and returns topic. Checks wether the host is ready before joining.

func (*SNRHost) Router

func (hn *SNRHost) Router(h host.Host) (routing.PeerRouting, error)

Router returns the host node Peer Routing Function

func (*SNRHost) SendMessage

func (h *SNRHost) SendMessage(id peer.ID, p protocol.ID, data proto.Message) error

SendMessage writes a protobuf go data object to a network stream

func (*SNRHost) Serve

func (hn *SNRHost) Serve()

Serve handles incoming peer Addr Info

func (*SNRHost) SetStatus

func (h *SNRHost) SetStatus(s SNRHostStatus)

SetStatus sets the host status and emits the event

func (*SNRHost) SignData

func (n *SNRHost) SignData(data []byte) ([]byte, error)

SignData signs an outgoing p2p message payload

func (*SNRHost) SignMessage

func (n *SNRHost) SignMessage(message proto.Message) ([]byte, error)

SignMessage signs an outgoing p2p message payload

func (*SNRHost) Stat

func (hn *SNRHost) Stat() (map[string]string, error)

Stat returns the host stat info

func (*SNRHost) VerifyData

func (n *SNRHost) VerifyData(data []byte, signature []byte, peerId peer.ID, pubKeyData []byte) bool

VerifyData verifies incoming p2p message data integrity

type SNRHostStatus

type SNRHostStatus int

SNRHostStatus is the status of the host

const (
	Status_IDLE       SNRHostStatus = iota // Host is idle, default state
	Status_STANDBY                         // Host is standby, waiting for connection
	Status_CONNECTING                      // Host is connecting
	Status_READY                           // Host is ready
	Status_FAIL                            // Host failed to connect
	Status_CLOSED                          // Host is closed
)

SNRHostStatus Definitions

func (SNRHostStatus) Equals

func (s SNRHostStatus) Equals(other SNRHostStatus) bool

Equals returns true if given SNRHostStatus matches this one

func (SNRHostStatus) IsClosed

func (s SNRHostStatus) IsClosed() bool

IsClosed returns true if the SNRHostStatus == Status_CLOSED

func (SNRHostStatus) IsConnecting

func (s SNRHostStatus) IsConnecting() bool

IsConnecting returns true if the SNRHostStatus == Status_CONNECTING

func (SNRHostStatus) IsFail

func (s SNRHostStatus) IsFail() bool

IsFail returns true if the SNRHostStatus == Status_FAIL

func (SNRHostStatus) IsNotIdle

func (s SNRHostStatus) IsNotIdle() bool

IsNotIdle returns true if the SNRHostStatus != Status_IDLE

func (SNRHostStatus) IsReady

func (s SNRHostStatus) IsReady() bool

IsReady returns true if the SNRHostStatus == Status_READY

func (SNRHostStatus) IsStandby

func (s SNRHostStatus) IsStandby() bool

IsStandby returns true if the SNRHostStatus == Status_STANDBY

func (SNRHostStatus) String

func (s SNRHostStatus) String() string

String returns the string representation of the SNRHostStatus

type SockManager

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

func NewSockManager

func NewSockManager(path string) (*SockManager, error)

func (*SockManager) NewSockPath

func (sm *SockManager) NewSockPath() (string, error)

Jump to

Keyboard shortcuts

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