relay

package
v0.4.19 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2018 License: GPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrInvalidHandshake int32 = iota
	ErrUnknownPeerType
	ErrTimeout
	ErrNoPeer
	ErrWrongNode
	ErrEmptyContinuum
)

Variables

This section is empty.

Functions

func Dial

func Dial(addr net.Addr, targetAddr common.Address, uuid string) (net.Conn, error)

Dial communicates with the relay server waiting for other server peer to establish a relayed TCP connection.

All network traffic will be transported through that server.

func DialWithLog

func DialWithLog(addr net.Addr, targetAddr common.Address, uuid string, log *zap.Logger) (net.Conn, error)

DialWithLog does the same as Dial, but with logging.

func Listen

func Listen(addr net.Addr, publishAddr SignedETHAddr) (net.Conn, error)

Listen publishes itself to the relay server waiting for other client peer to establish a relayed TCP connection.

All network traffic will be transported through that server.

func ListenWithLog

func ListenWithLog(addr net.Addr, publishAddr SignedETHAddr, log *zap.Logger) (net.Conn, error)

ListenWithLog does the same as Listen, but with logging.

func NewServer

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

NewServer constructs a new relay server using specified config with options.

Types

type BackPressureListener added in v0.4.3

type BackPressureListener struct {
	net.Listener

	Log *zap.Logger
}

func (*BackPressureListener) Accept added in v0.4.3

func (m *BackPressureListener) Accept() (net.Conn, error)

type ClusterConfig

type ClusterConfig struct {
	Name      string
	Endpoint  string
	Announce  string
	SecretKey string `yaml:"secret_key" json:"-"`
	Members   []string
}

ClusterConfig represents a cluster membership config.

type Config

type Config struct {
	Endpoints   []string
	Concurrency uint8 `yaml:"concurrency" default:"2"`
}

Config represents a client-side relay configuration.

Used as a basic building block for high-level configurations.

type ConnID

type ConnID string

func (ConnID) String

func (m ConnID) String() string

type Dialer

type Dialer struct {
	Addrs []string
	Log   *zap.Logger
}

Dialer is a thing that constructs a new TCP connection using remote Relay server. One or more Relay TCP addresses must be specified in "Addrs" field. Hostname resolution is performed for each of them for environments with dynamic DNS addition/removal. Thus, a single Relay endpoint as a hostname should fit the best.

func (*Dialer) Dial

func (m *Dialer) Dial(target common.Address) (net.Conn, error)

Dial mimics "net.Dial" and connects to a remote endpoint using Relay server.

type Listener

type Listener struct {
	Addrs      []string
	SignedAddr SignedETHAddr
	Log        *zap.Logger
}

Listener represents client-side TCP listener that will route traffic through Relay server. One or more Relay TCP addresses must be specified in "Addrs" field. Hostname resolution is performed for each of them for environments with dynamic DNS addition/removal.

func NewListener

func NewListener(addrs []string, key *ecdsa.PrivateKey, log *zap.Logger) (*Listener, error)

func (*Listener) Accept

func (m *Listener) Accept() (net.Conn, error)

Accept accepts a new TCP connection that is relayed through the Relay server specified in the configuration.

This is done by establishing a TCP connection to a Relay server and waiting until a remote peer decides to communicate with us.

This method can be called multiple times, even concurrently to announce the server multiple times, which is useful for reducing the time window between the next announce after the remote peer appearing. However, this increases resource usage, such as fd, on both this server and the Relay. Use wisely.

type MonitorConfig

type MonitorConfig struct {
	Endpoint   string
	PrivateKey *ecdsa.PrivateKey `json:"-"`
}

type Node added in v0.4.4

type Node struct {
	Name string
	Addr string
}

Node represents a node point on the Continuum.

func ParseNode added in v0.4.4

func ParseNode(node string) (*Node, error)

func (*Node) String added in v0.4.4

func (m *Node) String() string

type Option

type Option func(options *options) error

Option is a function that configures the server.

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.

type ServerConfig

type ServerConfig struct {
	Addr    netutil.TCPAddr
	Cluster ClusterConfig
	Logging logging.Config
	Monitor MonitorConfig
	Debug   *debug.Config
}

ServerConfig describes the complete relay server configuration.

func NewServerConfig

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

NewServerConfig loads a new Relay server config from a file.

type SignedETHAddr

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

SignedETHAddr represents self-signed ETH address.

func NewSignedAddr

func NewSignedAddr(key *ecdsa.PrivateKey) (SignedETHAddr, error)

NewSignedAddr constructs a new self-signed Ethereum address using the specified private key.

func (*SignedETHAddr) Addr

func (m *SignedETHAddr) Addr() common.Address

Jump to

Keyboard shortcuts

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