server

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: Apache-2.0, BSD-2-Clause Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTimeout is returned when an expected incoming connection was not received in time.
	ErrTimeout = errors.New("accept timeout")
	// ErrDuplicateAccept is returned when the server already registered an accept request for that peer ID.
	ErrDuplicateAccept = errors.New("accept request for that peer already exists")
	// ErrClosed means that the server was shut down before a response could be received.
	ErrClosed = errors.New("server closed")
	// ErrInvalidHandshake is returned when no correct handshake could be established.
	ErrInvalidHandshake = errors.New("invalid handshake")
	// ErrNoGossip means that the given peer does not support the gossip service.
	ErrNoGossip = errors.New("peer does not have a gossip service")
)

Functions

This section is empty.

Types

type ConnectPeerOption added in v0.6.2

type ConnectPeerOption func(conf *connectPeerConfig)

ConnectPeerOption defines an option for the DialPeer and AcceptPeer methods.

func WithNoDefaultTimeout added in v0.6.2

func WithNoDefaultTimeout() ConnectPeerOption

WithNoDefaultTimeout returns a ConnectPeerOption that disables the default timeout for dial or accept.

type TCP

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

TCP establishes verified incoming and outgoing TCP connections to other peers.

func ServeTCP

func ServeTCP(local *peer.Local, listener *net.TCPListener, log *zap.SugaredLogger) *TCP

ServeTCP creates the object and starts listening for incoming connections.

func (*TCP) AcceptPeer

func (t *TCP) AcceptPeer(ctx context.Context, p *peer.Peer, opts ...ConnectPeerOption) (net.Conn, error)

AcceptPeer awaits an incoming connection from the given peer. If the peer does not establish the connection or the handshake fails, an error is returned.

func (*TCP) Close

func (t *TCP) Close()

Close stops listening on the gossip address.

func (*TCP) DialPeer

func (t *TCP) DialPeer(ctx context.Context, p *peer.Peer, opts ...ConnectPeerOption) (net.Conn, error)

DialPeer establishes a gossip connection to the given peer. If the peer does not accept the connection or the handshake fails, an error is returned.

func (*TCP) LocalAddr

func (t *TCP) LocalAddr() net.Addr

LocalAddr returns the listener's network address,

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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