rendezvous

package
v0.4.31 Latest Latest
Warning

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

Go to latest
Published: May 15, 2020 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	sonm.RendezvousClient
	// Close closes this client freeing the associated resources.
	//
	// All pending operations will be terminated with error.
	Close() error
}

Client extends the generated gRPC client allowing to close the underlying connection. Users should call Client.Close to terminate all the pending operations.

func NewRendezvousClient

func NewRendezvousClient(ctx context.Context, addr string, credentials credentials.TransportCredentials, opts ...grpc.DialOption) (Client, error)

NewRendezvousClient constructs a new rendezvous client.

The address provided will be used for establishing a TCP connection while optional credentials - for authentication. Additionally other dial options can be specified.

type Config

type Config struct {
	Endpoints             []auth.Addr   `yaml:"endpoints"`
	MaxConnectionAttempts int           `yaml:"max_connection_attempts" default:"5"`
	Timeout               time.Duration `yaml:"timeout" default:"3s"`
}

type Option

type Option func(options *options)

Option is a function that configures the server.

func WithCredentials

func WithCredentials(cfg *tls.Config) Option

WithCredentials is an option that specifies transport credentials used for establishing secure connections between peer and the server. Nil value is also supported, but discouraged, because it disables the authentication. Clients that require TLS will fail the handshake process and disconnect from such server. Note that we use ETH based TLS credentials.

func WithLogger

func WithLogger(log *zap.Logger) Option

WithLogger is an option that specifies provided logger used for the internal logging. Nil value is supported and can be passed to deactivate the logging system entirely.

func WithQUIC added in v0.4.17

func WithQUIC() Option

WithQUIC activates QUIC support in the Rendezvous server, allowing to penetrate NAT for UDP. When using this option it is REQUIRED to specify transport credentials by passing "WithCredentials" option, because QUIC provides security protection equivalent to TLS.

type Peer

type Peer struct {
	peer.Peer
	ID PeerID
	// contains filtered or unexported fields
}

func NewPeer

func NewPeer(peerInfo peer.Peer, privateAddrs []*sonm.Addr) Peer

type PeerID

type PeerID string

PeerID represents an unique peer id generated at the time of either publishing or resolving another peer.

This id is used for cleaning resources when a request is finished. Note, that we cannot use peer's Ethereum address as an id, because it can be shared across multiple servers/clients.

func NewPeerID

func NewPeerID() PeerID

NewPeerID constructs and returns a new unique id used for internal identifying peers connected for publishing and resolving each other.

func (PeerID) String

func (m PeerID) String() string

type Server

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

Server represents a rendezvous server.

This server is responsible for tracking servers and clients to make them meet each other.

func NewServer

func NewServer(cfg *ServerConfig, options ...Option) (*Server, error)

NewServer constructs a new rendezvous server using specified config and options.

The server supports TLS by passing transport credentials using WithCredentials option. Also it is possible to activate logging system by passing a logger using WithLogger function as an option.

func (*Server) Info

func (m *Server) Info(ctx context.Context, request *sonm.Empty) (*sonm.RendezvousState, error)

func (*Server) Publish

func (m *Server) Publish(ctx context.Context, request *sonm.PublishRequest) (*sonm.RendezvousReply, error)

func (*Server) Resolve

func (m *Server) Resolve(ctx context.Context, request *sonm.ConnectRequest) (*sonm.RendezvousReply, error)

func (*Server) ResolveAll

func (m *Server) ResolveAll(ctx context.Context, request *sonm.ID) (*sonm.ResolveMetaReply, error)

func (*Server) Run

func (m *Server) Run(ctx context.Context) error

Run starts accepting incoming connections, serving them by blocking the caller execution context until either explicitly terminated using Stop or some critical error occurred.

Always returns non-nil error.

func (*Server) Stop

func (m *Server) Stop()

Stop stops the server.

It immediately closes all open connections and listeners. Also it cancels all active RPCs on the server side and the corresponding pending RPCs on the client side will get notified by connection errors.

type ServerConfig

type ServerConfig struct {
	// Listening address.
	Addr       net.Addr
	PrivateKey *ecdsa.PrivateKey
	Logging    logging.Config
	Debug      *debug.Config
}

ServerConfig represents a Rendezvous server configuration.

func NewServerConfig

func NewServerConfig(path string) (*ServerConfig, error)

NewServerConfig loads a new Rendezvous server config from a file.

Jump to

Keyboard shortcuts

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