relay

package
v0.0.0-...-8b9b725 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2019 License: MIT, MIT Imports: 17 Imported by: 4

Documentation

Overview

The relay package contains host implementations that automatically advertise relay addresses when the presence of NAT is detected. This feature is dubbed `autorelay`.

Warning: the internal interfaces are unstable.

System Components: - AutoNATService instances -- see https://github.com/libp2p/go-libp2p-autonat-svc - One or more relays, instances of `RelayHost` - The autorelayed hosts, instances of `AutoRelayHost`.

How it works:

  • `AutoNATService` instances are instantiated in the bootstrappers (or other well known publicly reachable hosts)
  • `RelayHost`s are constructed with `libp2p.New(libp2p.EnableRelay(circuit.OptHop), libp2p.Routing(makeDHT))`. They provide Relay Hop services, and advertise through the DHT in the `/libp2p/relay` namespace
  • `AutoRelayHost`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 = 60 * time.Second
)
View Source
var (
	AdvertiseBootDelay = 30 * time.Second
)

Functions

This section is empty.

Types

type AutoRelayHost

type AutoRelayHost struct {
	*basic.BasicHost
	// contains filtered or unexported fields
}

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

func NewAutoRelayHost

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

func (*AutoRelayHost) ClosedStream

func (h *AutoRelayHost) ClosedStream(inet.Network, inet.Stream)

func (*AutoRelayHost) Connected

func (h *AutoRelayHost) Connected(inet.Network, inet.Conn)

func (*AutoRelayHost) Disconnected

func (h *AutoRelayHost) Disconnected(_ inet.Network, c inet.Conn)

func (*AutoRelayHost) Listen

func (h *AutoRelayHost) Listen(inet.Network, ma.Multiaddr)

notify

func (*AutoRelayHost) ListenClose

func (h *AutoRelayHost) ListenClose(inet.Network, ma.Multiaddr)

func (*AutoRelayHost) OpenedStream

func (h *AutoRelayHost) OpenedStream(inet.Network, inet.Stream)

type RelayHost

type RelayHost struct {
	*basic.BasicHost
	// contains filtered or unexported fields
}

RelayHost is a Host that provides Relay services.

func NewRelayHost

func NewRelayHost(ctx context.Context, bhost *basic.BasicHost, advertise discovery.Advertiser) *RelayHost

New constructs a new RelayHost

Jump to

Keyboard shortcuts

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