host

package
v0.17.6 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2022 License: GPL-3.0 Imports: 37 Imported by: 1

Documentation

Index

Constants

View Source
const UDSDir = "sock"

Variables

This section is empty.

Functions

This section is empty.

Types

type HostImpl added in v0.15.2

type HostImpl interface {
	// AuthenticateMessage authenticates a message
	AuthenticateMessage(msg proto.Message, metadata *types.Metadata) bool

	// Close closes the node
	Close()

	// Connect to a peer
	Connect(pi peer.AddrInfo) error

	// HasRouting returns true if the node has routing
	HasRouting() error

	// HostID returns the ID of the Host
	HostID() peer.ID

	// Join subsrcibes to a topic
	Join(topic string, opts ...ps.TopicOpt) (*ps.Topic, error)

	// Listener returns the listener of the node
	Listener() (net.Listener, error)

	// NewStream opens a new stream to a peer
	NewStream(ctx context.Context, pid peer.ID, pids ...protocol.ID) (network.Stream, error)

	// NewTopic creates a new pubsub topic with event handler and subscription
	NewTopic(topic string, opts ...ps.TopicOpt) (*ps.Topic, *ps.TopicEventHandler, *ps.Subscription, error)

	// NeedsWait checks if state is Resumed or Paused and blocks channel if needed
	NeedsWait()

	// Pause tells all of goroutines to pause execution
	Pause()

	// Persist persists the node to the port and address
	Persist()

	// Ping sends a ping to a peer to check if it is alive
	Ping(id string) error

	// Peer returns the peer of the node
	Peer() (*types.Peer, error)

	// Profile returns the profile of the node from Local Store
	Profile() (*types.Profile, error)

	// Publish publishes a message to a topic
	Publish(topic string, msg proto.Message, metadata *types.Metadata) error

	// Resume tells all of goroutines to resume execution
	Resume()

	// Role returns the role of the node
	Role() config.Role

	// Router returns the routing.Router
	Router(h host.Host) (routing.PeerRouting, error)

	// SendMessage sends a message to a peer
	SendMessage(id peer.ID, p protocol.ID, data proto.Message) error

	// SetStreamHandler sets the handler for a protocol
	SetStreamHandler(protocol protocol.ID, handler network.StreamHandler)

	// SignData signs the data with the private key
	SignData(data []byte) ([]byte, error)

	// SignMessage signs a message with the node's private key
	SignMessage(message proto.Message) ([]byte, error)

	// VerifyData verifies the data signature
	VerifyData(data []byte, signature []byte, peerId peer.ID, pubKeyData []byte) bool

	// WebauthnConfig returns the webauthn config
	WebauthnConfig() *webauthn.Config
}

HostImpl returns the HostImpl for the Main Node

func NewHost

func NewHost(ctx context.Context, r config.Role, options ...Option) (HostImpl, error)

NewHost Creates a Sonr libp2p Host with the given config

type HostStatus added in v0.15.2

type HostStatus int

HostStatus is the status of the host

const (
	Status_IDLE       HostStatus = 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 (HostStatus) Equals added in v0.15.2

func (s HostStatus) Equals(other HostStatus) bool

Equals returns true if given SNRHostStatus matches this one

func (HostStatus) IsClosed added in v0.15.2

func (s HostStatus) IsClosed() bool

IsClosed returns true if the SNRHostStatus == Status_CLOSED

func (HostStatus) IsConnecting added in v0.15.2

func (s HostStatus) IsConnecting() bool

IsConnecting returns true if the SNRHostStatus == Status_CONNECTING

func (HostStatus) IsFail added in v0.15.2

func (s HostStatus) IsFail() bool

IsFail returns true if the SNRHostStatus == Status_FAIL

func (HostStatus) IsNotIdle added in v0.15.2

func (s HostStatus) IsNotIdle() bool

IsNotIdle returns true if the SNRHostStatus != Status_IDLE

func (HostStatus) IsReady added in v0.15.2

func (s HostStatus) IsReady() bool

IsReady returns true if the SNRHostStatus == Status_READY

func (HostStatus) IsStandby added in v0.15.2

func (s HostStatus) IsStandby() bool

IsStandby returns true if the SNRHostStatus == Status_STANDBY

func (HostStatus) String added in v0.15.2

func (s HostStatus) String() string

String returns the string representation of the SNRHostStatus

type LogLevel added in v0.15.2

type LogLevel string

LogLevel is the type for the log level

const (
	// DebugLevel is the debug log level
	DebugLevel LogLevel = "debug"
	// InfoLevel is the info log level
	InfoLevel LogLevel = "info"
	// WarnLevel is the warn log level
	WarnLevel LogLevel = "warn"
	// ErrorLevel is the error log level
	ErrorLevel LogLevel = "error"
	// FatalLevel is the fatal log level
	FatalLevel LogLevel = "fatal"
)

type Option added in v0.15.2

type Option func(*options)

Option is a function that modifies the node options.

func WithAddress added in v0.15.2

func WithAddress(host string) Option

WithAddress sets the host address for the Node Stub Client Host

func WithConnOptions

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

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

func WithInterval

func WithInterval(interval time.Duration) Option

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

func WithLogLevel added in v0.15.2

func WithLogLevel(level LogLevel) Option

WithLogLevel sets the log level for Logger

func WithPort added in v0.15.2

func WithPort(port int) Option

WithPort sets the port for the Node Stub Client

func WithTTL

func WithTTL(ttl time.Duration) Option

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

func WithWebAuthn added in v0.17.0

func WithWebAuthn(displayName string, rpId string, rpOrigin string, isDebug bool) Option

WithWebAuthn sets the webauthn server Properties

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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