relay

package module
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2023 License: MIT Imports: 27 Imported by: 0

README

DEPRECATION NOTICE

This package has moved into go-libp2p as a sub-package, github.com/libp2p/go-libp2p/p2p/protocol/internal/circuitv1-deprecated.

go-libp2p-circuit

Coverage Status Travis CI Discourse posts

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

Table of Contents

Install

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

Usage

Refer to the relay example in the go-libp2p-examples repository for usage instructions.

Contribute

PRs are welcome!

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

License

MIT © Jeromy Johnson


The last gx published version of this module was: 2.3.15: QmRTkLxADQRbgnhpt2zzQQJr8Ri764b7dujoDkZw33b3iE

Documentation

Index

Constants

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

Variables

View Source
var (
	RelayAcceptTimeout   = 10 * time.Second
	HopConnectTimeout    = 30 * time.Second
	StopHandshakeTimeout = 1 * time.Minute

	HopStreamBufferSize = 4096
	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 = RelayOpt(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 = RelayOpt(1)
	// OptDiscovery is a no-op. It was introduced as a way to probe new
	// peers to see if they were willing to act as a relays. However, in
	// practice, it's useless. While it does test to see if these peers are
	// relays, it doesn't (and can't), check to see if these peers are
	// _active_ relays (i.e., will actively dial the target peer).
	//
	// This option may be re-enabled in the future but for now you shouldn't
	// use it.
	OptDiscovery = RelayOpt(2)
)
View Source
var HopTagWeight = 5

HopTagWeight is the connection manager weight for connections carrying relay hop streams

Functions

func AddRelayTransport

func AddRelayTransport(h host.Host, upgrader transport.Upgrader, opts ...RelayOpt) 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)

Queries a peer for support of hop relay

func GenUpgrader

func GenUpgrader(n *swarm.Swarm, connGater connmgr.ConnectionGater, opts ...tptu.Option) (transport.Upgrader, error)

GenUpgrader creates a new connection upgrader for use with this swarm.

Types

type Conn

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

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) LocalAddr

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

func (*Conn) LocalMultiaddr

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

func (*Conn) Read

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

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"

func (*Conn) SetDeadline

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

func (*Conn) SetReadDeadline

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

func (*Conn) SetWriteDeadline

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

func (*Conn) Write

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

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
}

Relay is the relay transport and service.

func NewRelay

func NewRelay(h host.Host, upgrader transport.Upgrader, opts ...RelayOpt) (*Relay, error)

NewRelay constructs a new relay.

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 peer.AddrInfo, dest peer.AddrInfo) (*Conn, error)

func (*Relay) GetActiveHops

func (r *Relay) GetActiveHops() int32

func (*Relay) Listener

func (r *Relay) Listener() *RelayListener

func (*Relay) Matches

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

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 RelayOpt

type RelayOpt int

RelayOpts are options for configuring the relay transport.

type RelayTransport

type RelayTransport Relay

func (*RelayTransport) CanDial

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

func (*RelayTransport) Close

func (r *RelayTransport) Close() error

func (*RelayTransport) Dial

func (*RelayTransport) Listen

func (t *RelayTransport) Listen(laddr ma.Multiaddr) (transport.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