conn

package module
v0.0.0-...-8e5f941 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2017 License: MIT Imports: 23 Imported by: 0

README

go-libp2p-conn

Coverage Status Travis CI

A library providing 'Connection' objects for libp2p.

Table of Contents

Install

make install

Contribute

PRs are welcome!

Small note: If editing the Readme, please conform to the standard-readme specification.

License

MIT © Jeromy Johnson

Documentation

Index

Constants

View Source
const (
	SecioTag        = "/secio/1.0.0"
	NoEncryptionTag = "/plaintext/1.0.0"
)

Variables

View Source
var (
	ConnAcceptTimeout = 60 * time.Second
)
View Source
var DialTimeout = 60 * time.Second

DialTimeout is the maximum duration a Dial is allowed to take. This includes the time between dialing the raw network connection, protocol selection as well the handshake, if applicable.

Functions

func WrapTransportListener

func WrapTransportListener(ctx context.Context, ml tpt.Listener, local peer.ID, pstpt smux.Transport,
	sk ic.PrivKey) (iconn.Listener, error)

func WrapTransportListenerWithProtector

func WrapTransportListenerWithProtector(ctx context.Context, ml tpt.Listener, local peer.ID,
	sk ic.PrivKey, pstpt smux.Transport, protec ipnet.Protector) (iconn.Listener, error)

Types

type ConnWrapper

type ConnWrapper func(tpt.Conn) tpt.Conn

ConnWrapper is any function that wraps a raw multiaddr connection

type Dialer

type Dialer struct {
	// LocalPeer is the identity of the local Peer.
	LocalPeer peer.ID

	// Dialers are the sub-dialers usable by this dialer
	// selected in order based on the address being dialed
	Dialers []tpt.Dialer

	// PrivateKey used to initialize a secure connection.
	// Warning: if PrivateKey is nil, connection will not be secured.
	PrivateKey ci.PrivKey

	// Protector makes dialer part of a private network.
	// It includes implementation details how connection are protected.
	// Can be nil, then dialer is in public network.
	Protector ipnet.Protector

	// Wrapper to wrap the raw connection (optional)
	Wrapper WrapFunc
	// contains filtered or unexported fields
}

Dialer is an object that can open connections. We could have a "convenience" Dial function as before, but it would have many arguments, as dialing is no longer simple (need a peerstore, a local peer, a context, a network, etc)

func NewDialer

func NewDialer(p peer.ID, pk ci.PrivKey, wrap WrapFunc, sm smux.Transport) *Dialer

func (*Dialer) AddDialer

func (d *Dialer) AddDialer(pd tpt.Dialer)

func (*Dialer) Dial

func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (iconn.Conn, error)

Dial connects to a peer over a particular address Ensures raddr is part of peer.Addresses() Example: d.DialAddr(ctx, peer.Addresses()[0], peer)

func (*Dialer) String

func (d *Dialer) String() string

String returns the string rep of d.

type ListenerConnWrapper

type ListenerConnWrapper interface {
	SetConnWrapper(ConnWrapper)
}

type WrapFunc

type WrapFunc func(tpt.Conn) tpt.Conn

The WrapFunc is used to wrap a tpt.Conn. It must not block.

Jump to

Keyboard shortcuts

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