network

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2023 License: MIT Imports: 9 Imported by: 2

Documentation

Overview

Package network handles incoming network connections.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConnectionEstablisher

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

ConnectionEstablisher periodically triggers the EstablishNewConnections application command.

func (ConnectionEstablisher) Run

Run periodically triggers the command until the context is closed.

type Discoverer

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

Discoverer receives local UDP announcements from other Secure Scuttlebutt clients and passes them to the ProcessNewLocalDiscovery command.

func NewDiscoverer

func NewDiscoverer(
	discoverer *local.Discoverer,
	handler ProcessNewLocalDiscoveryCommandHandler,
	logger logging.Logger,
) *Discoverer

func (Discoverer) Run

func (d Discoverer) Run(ctx context.Context) error

Run receives local announcements and passes them to the command until the context is closed.

type EstablishNewConnectionsCommandHandler

type EstablishNewConnectionsCommandHandler interface {
	Handle(ctx context.Context) error
}

type Listener

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

Listener handles incoming TCP connections initiated by other peers, initializes them and passes them to the AcceptNewPeer command.

func NewListener

func NewListener(
	initializer ServerPeerInitializer,
	address string,
	logger logging.Logger,
) (*Listener, error)

NewListener creates a new listener which listens on the provided address. The address should be formatted in the way which can be handled by the net package e.g. ":8008".

func (*Listener) ListenAndServe

func (l *Listener) ListenAndServe(ctx context.Context) error

ListenAndServe starts listening and keeps accepting connections and processing them until the context is closed. The context passed to this function is not used to initiate RPC connections.

type ProcessNewLocalDiscoveryCommandHandler

type ProcessNewLocalDiscoveryCommandHandler interface {
	Handle(ctx context.Context, cmd commands.ProcessNewLocalDiscovery) error
}

type ServerPeerInitializer

type ServerPeerInitializer interface {
	// InitializeServerPeer initializes incoming connections by performing a
	// handshake and establishing an RPC connection using the provided
	// ReadWriteCloser. Context is used as the RPC connection context.
	InitializeServerPeer(ctx context.Context, rwc io.ReadWriteCloser) (transport.Peer, error)
}

Jump to

Keyboard shortcuts

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