relay

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2020 License: AGPL-3.0, MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const PCIRCUIT = ma.P_CIRCUIT

PCIRCUIT is deprecated

View Source
const ProtoID = "/libp2p/circuit/relay/0.1.0"

ProtoID is the id of the libp2p circuit relay protocol

Variables

View Source
var (
	// RelayAcceptTimeout  defines the relay connection timeout
	RelayAcceptTimeout = 10 * time.Second
	// HopConnectTimeout defines when we timeout hops
	HopConnectTimeout = 30 * time.Second
	// StopHandshakeTimeout defines a stop handshake timeout
	StopHandshakeTimeout = 1 * time.Minute
	// HopStreamBufferSize returns th size of the hop stream buffer
	HopStreamBufferSize = 4096
	// HopStreamLimit returns the maximum number of hops
	HopStreamLimit = 1 << 19 // 512K hops for 1M goroutines
)
View Source
var (
	// OptActive configures the relay transport to actively establish
	// outbound connections on behalf of clients. You probably don't want to
	// enable this unless you know what you're doing.
	OptActive = Opt(0)
	// OptHop configures the relay transport to accept requests to relay
	// traffic on behalf of third-parties. Unless OptActive is specified,
	// this will only relay traffic between peers already connected to this
	// node.
	OptHop = Opt(1)
	// OptDiscovery configures this relay transport to discover new relays
	// by probing every new peer. You almost _certainly_ don't want to
	// enable this.
	OptDiscovery = Opt(2)
)

Protocol is Deprecated: use ma.ProtocolWithCode(P_CIRCUIT)

Functions

func AddRelayTransport

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

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

func CanHop

func CanHop(ctx context.Context, host host.Host, id peer.ID) (bool, error)

CanHop queries a peer for support of hop relay

Types

type Conn

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

Conn is a circuit connection

func (*Conn) Close

func (c *Conn) Close() error

Close closes the connection

func (*Conn) LocalAddr

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

LocalAddr returns our local multi address

func (*Conn) LocalMultiaddr

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

LocalMultiaddr returns th eaddress of the local connection (us)

func (*Conn) Read

func (c *Conn) Read(buf []byte) (int, error)

func (*Conn) RemoteAddr

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

RemoteAddr returns the address of the remote peer

func (*Conn) RemoteMultiaddr

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

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

func (*Conn) SetDeadline

func (c *Conn) SetDeadline(t time.Time) error

SetDeadline sets the deadline

func (*Conn) SetReadDeadline

func (c *Conn) SetReadDeadline(t time.Time) error

SetReadDeadline sets the read deadline

func (*Conn) SetWriteDeadline

func (c *Conn) SetWriteDeadline(t time.Time) error

SetWriteDeadline sets the write deadline

func (*Conn) Write

func (c *Conn) Write(buf []byte) (int, error)

type Error

type Error struct {
	Code pb.CircuitRelay_Status
}

Error is an error returned from the relay

func (Error) Error

func (e Error) Error() string

type Listener

type Listener Relay

Listener is ???

func (*Listener) Accept

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

Accept is used to accept ??

func (*Listener) Addr

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

Addr returns the net addr

func (*Listener) Close

func (l *Listener) Close() error

Close is a noop closer

func (*Listener) Multiaddr

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

Multiaddr returns the multiaddr of ?

func (*Listener) Relay

func (l *Listener) Relay() *Relay

Relay returns the underlying relay

type NetAddr

type NetAddr struct {
	Relay  string
	Remote string
}

NetAddr ???

func (*NetAddr) Network

func (n *NetAddr) Network() string

Network ??

func (*NetAddr) String

func (n *NetAddr) String() string

type Notifiee

type Notifiee Relay

Notifiee does ??

func (*Notifiee) ClosedStream

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

ClosedStream satisfies the network.Notifiee interface

func (*Notifiee) Connected

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

Connected satisfies the network.Notifiee interface

func (*Notifiee) Disconnected

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

Disconnected satisfies the network.Notifiee interface

func (*Notifiee) Listen

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

Listen satisfies the network.Notifiee interface

func (*Notifiee) ListenClose

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

ListenClose satisfies the network.Notifiee interface

func (*Notifiee) OpenedStream

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

OpenedStream satisfies the network.Notifiee interface

func (*Notifiee) Relay

func (n *Notifiee) Relay() *Relay

Relay ??

type Opt

type Opt int

Opt are options for configuring the relay transport.

type Relay

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

Relay is the relay transport and service.

func NewRelay

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

NewRelay constructs a new relay.

func (*Relay) CanHop

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

CanHop indicates if we can hop to this peer

func (*Relay) Dial

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

Dial is used to dial the peer

func (*Relay) DialPeer

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

DialPeer attempts to dial the given peer

func (*Relay) GetActiveHops

func (r *Relay) GetActiveHops() int32

GetActiveHops is used to return the number of active hops

func (*Relay) Listener

func (r *Relay) Listener() *Listener

Listener returns the listener

func (*Relay) Matches

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

Matches indicates if we match with this addr

func (*Relay) Transport

func (r *Relay) Transport() *Transport

Transport does ??

type Transport

type Transport Relay

Transport ??

func (*Transport) CanDial

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

CanDial indicates if we can dial th eper

func (*Transport) Dial

Dial is used to dial the peer

func (*Transport) Listen

func (t *Transport) Listen(laddr ma.Multiaddr) (transport.Listener, error)

Listen does ??

func (*Transport) Protocols

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

Protocols returns the protocols of this transport

func (*Transport) Proxy

func (t *Transport) Proxy() bool

Proxy returns if the transport is a proxy

func (*Transport) Relay

func (t *Transport) Relay() *Relay

Relay does ?

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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