relay

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

The relay package contains the components necessary to implement the "autorelay" feature.

Warning: the internal interfaces are unstable.

System Components:

  • A discovery service to discover public relays.
  • An AutoNAT client used to determine if the node is behind a NAT/firewall.
  • One or more autonat services, instances of `AutoNATServices`. These are used by the autonat client.
  • One or more relays, instances of `RelayHost`.
  • The AutoRelay service. This is the service that actually:

AutoNATService: https://github.com/libp2p/go-libp2p-autonat-svc AutoNAT: https://github.com/libp2p/go-libp2p-autonat

How it works:

  • `AutoNATService` instances are instantiated in the bootstrappers (or other well known publicly reachable hosts)
  • `AutoRelay`s are constructed with `libp2p.New(libp2p.Routing(makeDHT))` They passively discover autonat service instances and test dialability of their listen address set through them. When the presence of NAT is detected, they discover relays through the DHT, connect to some of them and begin advertising relay addresses. The new set of addresses is propagated to connected peers through the `identify/push` protocol.

Index

Constants

View Source
const (
	RelayRendezvous = "/libp2p/relay"
)

Variables

View Source
var (
	DesiredRelays = 3

	BootDelay = 20 * time.Second
)
View Source
var (
	AdvertiseBootDelay = 30 * time.Second
)

Functions

func Advertise(ctx context.Context, advertise discovery.Advertiser)

Advertise advertises this node as a libp2p relay.

func Filter added in v0.0.6

func Filter(addrs []ma.Multiaddr) []ma.Multiaddr

Filter filters out all relay addresses.

Types

type AutoRelay added in v0.0.6

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

AutoRelay is a Host that uses relays for connectivity when a NAT is detected.

func NewAutoRelay added in v0.0.6

func NewAutoRelay(ctx context.Context, bhost *basic.BasicHost, discover discovery.Discoverer, router routing.PeerRouting) *AutoRelay

func (*AutoRelay) ClosedStream added in v0.0.6

func (ar *AutoRelay) ClosedStream(inet.Network, inet.Stream)

func (*AutoRelay) Connected added in v0.0.6

func (ar *AutoRelay) Connected(inet.Network, inet.Conn)

func (*AutoRelay) Disconnected added in v0.0.6

func (ar *AutoRelay) Disconnected(net inet.Network, c inet.Conn)

func (*AutoRelay) Listen added in v0.0.6

func (ar *AutoRelay) Listen(inet.Network, ma.Multiaddr)

func (*AutoRelay) ListenClose added in v0.0.6

func (ar *AutoRelay) ListenClose(inet.Network, ma.Multiaddr)

func (*AutoRelay) OpenedStream added in v0.0.6

func (ar *AutoRelay) OpenedStream(inet.Network, inet.Stream)

Jump to

Keyboard shortcuts

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