p2p

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultTransport = Transport{
	DialContext: (&net.Dialer{
		Timeout:   30 * time.Second,
		KeepAlive: 30 * time.Second,
		DualStack: true,
	}).DialContext,
}

DefaultTransport implements the default dialing strategy

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn

	Transport *Transport
	// contains filtered or unexported fields
}

Conn is a connection between two waves nodes

func NewConn

func NewConn(options ...ConnOption) (*Conn, error)

NewConn creates a new connection

func (*Conn) Dial

func (c *Conn) Dial(network, addr string) error

Dial is a wrapper around DialContext

func (*Conn) DialContext

func (c *Conn) DialContext(ctx context.Context, network, addr string) error

DialContext dials a remote andpoint

type ConnOption

type ConnOption func(*Conn) error

ConnOption is a connection creation option

func WithRemote

func WithRemote(network, addr string) ConnOption

WithRemote is an option for remote endpoint

func WithTransport

func WithTransport(t *Transport) ConnOption

WithTransport is an option for custom transport of the connection

func WithVersion

func WithVersion(v proto.Version) ConnOption

WithVersion is an option for versioning a connection

type Transport

type Transport struct {
	DialContext func(ctx context.Context, network, addr string) (net.Conn, error)
}

Transport allows one to reimplement the way we dial a peer

Jump to

Keyboard shortcuts

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