autorelay

package
v0.18.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2022 License: MIT Imports: 22 Imported by: 50

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/p2p/host/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 = 1

	BootDelay = 20 * time.Second
)
View Source
var (
	// this is purposefully long to require some node stability before advertising as a relay
	AdvertiseBootDelay = 15 * time.Minute
	AdvertiseTTL       = 30 * time.Minute
)
View Source
var DefaultRelays = []string{
	"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
	"/ip4/147.75.80.110/udp/4001/quic/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
	"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
	"/ip4/147.75.195.153/udp/4001/quic/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
	"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
	"/ip4/147.75.70.221/udp/4001/quic/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
}

DefaultRelays are the known PL-operated v1 relays; will be decommissioned in 2022.

Functions

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

Advertise advertises this node as a libp2p relay.

func Filter

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

Filter filters out all relay addresses.

Types

type AutoRelay

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

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

func NewAutoRelay

func NewAutoRelay(bhost *basic.BasicHost, router routing.PeerRouting, opts ...Option) (*AutoRelay, error)

func (*AutoRelay) Close

func (ar *AutoRelay) Close() error

type AutoRelayHost

type AutoRelayHost struct {
	host.Host
	// contains filtered or unexported fields
}

func NewAutoRelayHost

func NewAutoRelayHost(h host.Host, ar *AutoRelay) *AutoRelayHost

func (*AutoRelayHost) Close

func (h *AutoRelayHost) Close() error

type Option

type Option func(*AutoRelay) error

func WithDiscoverer

func WithDiscoverer(discover discovery.Discoverer) Option

type StaticRelayOption

type StaticRelayOption Option

func WithDefaultStaticRelays

func WithDefaultStaticRelays() StaticRelayOption

func WithStaticRelays

func WithStaticRelays(static []peer.AddrInfo) StaticRelayOption

Jump to

Keyboard shortcuts

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