relay

package
v0.0.0-...-ce94876 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2019 License: MIT, MIT Imports: 21 Imported by: 0

README

go-libp2p-circuit

Coverage Status Travis CI

The libp2p relay allows peers to relay connections on behalf of others.

Table of Contents

Install

go get -u github.com/libp2p/go-libp2p-circuit

Usage

TODO

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 P_CIRCUIT = 290
View Source
const ProtoID = "/libp2p/circuit/relay/0.1.0"

Variables

View Source
var (
	OptActive    = RelayOpt(0)
	OptHop       = RelayOpt(1)
	OptDiscovery = RelayOpt(2)
)
View Source
var HopConnectTimeout = 10 * time.Second
View Source
var Protocol = ma.Protocol{
	Code:  P_CIRCUIT,
	Size:  0,
	Name:  "p2p-circuit",
	VCode: ma.CodeToVarint(P_CIRCUIT),
}
View Source
var RelayAcceptTimeout = time.Minute

Functions

func AddRelayTransport

func AddRelayTransport(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) error

AddRelayTransport constructs a relay and adds it as a transport to the host network.

Types

type Conn

type Conn struct {
	inet.Stream
	// contains filtered or unexported fields
}

func (*Conn) LocalAddr

func (c *Conn) LocalAddr() net.Addr

func (*Conn) LocalMultiaddr

func (c *Conn) LocalMultiaddr() ma.Multiaddr

func (*Conn) RemoteAddr

func (c *Conn) RemoteAddr() net.Addr

func (*Conn) RemoteMultiaddr

func (c *Conn) RemoteMultiaddr() ma.Multiaddr

TODO: is it okay to cast c.Conn().RemotePeer() into a multiaddr? might be "user input"

type NetAddr

type NetAddr struct {
	Relay  string
	Remote string
}

func (*NetAddr) Network

func (n *NetAddr) Network() string

func (*NetAddr) String

func (n *NetAddr) String() string

type Relay

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

func NewRelay

func NewRelay(ctx context.Context, h host.Host, upgrader *tptu.Upgrader, opts ...RelayOpt) (*Relay, error)

func (*Relay) CanHop

func (r *Relay) CanHop(ctx context.Context, id peer.ID) (bool, error)

func (*Relay) Dial

func (r *Relay) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (*Conn, error)

func (*Relay) DialPeer

func (r *Relay) DialPeer(ctx context.Context, relay pstore.PeerInfo, dest pstore.PeerInfo) (*Conn, error)

func (*Relay) GetActiveHops

func (r *Relay) GetActiveHops() uint64

func (*Relay) Listener

func (r *Relay) Listener() *RelayListener

func (*Relay) Matches

func (r *Relay) Matches(addr ma.Multiaddr) bool

func (*Relay) Notifiee

func (r *Relay) Notifiee() inet.Notifiee

func (*Relay) Transport

func (r *Relay) Transport() *RelayTransport

type RelayError

type RelayError struct {
	Code pb.CircuitRelay_Status
}

func (RelayError) Error

func (e RelayError) Error() string

type RelayListener

type RelayListener Relay

func (*RelayListener) Accept

func (l *RelayListener) Accept() (manet.Conn, error)

func (*RelayListener) Addr

func (l *RelayListener) Addr() net.Addr

func (*RelayListener) Close

func (l *RelayListener) Close() error

func (*RelayListener) Multiaddr

func (l *RelayListener) Multiaddr() ma.Multiaddr

func (*RelayListener) Relay

func (l *RelayListener) Relay() *Relay

type RelayNotifiee

type RelayNotifiee Relay

func (*RelayNotifiee) ClosedStream

func (n *RelayNotifiee) ClosedStream(net inet.Network, s inet.Stream)

func (*RelayNotifiee) Connected

func (n *RelayNotifiee) Connected(s inet.Network, c inet.Conn)

func (*RelayNotifiee) Disconnected

func (n *RelayNotifiee) Disconnected(s inet.Network, c inet.Conn)

func (*RelayNotifiee) Listen

func (n *RelayNotifiee) Listen(net inet.Network, a ma.Multiaddr)

func (*RelayNotifiee) ListenClose

func (n *RelayNotifiee) ListenClose(net inet.Network, a ma.Multiaddr)

func (*RelayNotifiee) OpenedStream

func (n *RelayNotifiee) OpenedStream(net inet.Network, s inet.Stream)

func (*RelayNotifiee) Relay

func (n *RelayNotifiee) Relay() *Relay

type RelayOpt

type RelayOpt int

type RelayTransport

type RelayTransport Relay

func (*RelayTransport) CanDial

func (t *RelayTransport) CanDial(raddr ma.Multiaddr) bool

func (*RelayTransport) Dial

func (d *RelayTransport) Dial(ctx context.Context, a ma.Multiaddr, p peer.ID) (tpt.Conn, error)

func (*RelayTransport) Listen

func (t *RelayTransport) Listen(laddr ma.Multiaddr) (tpt.Listener, error)

func (*RelayTransport) Protocols

func (t *RelayTransport) Protocols() []int

func (*RelayTransport) Proxy

func (t *RelayTransport) Proxy() bool

func (*RelayTransport) Relay

func (t *RelayTransport) Relay() *Relay

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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