doc: document relay options

This commit is contained in:
Steven Allen 2019-04-06 07:34:52 -07:00
parent 45df977d57
commit 1d8efc31aa
1 changed files with 19 additions and 4 deletions

View File

@ -201,7 +201,12 @@ func AddrsFactory(factory config.AddrsFactory) Option {
} }
} }
// EnableRelay configures libp2p to enable the relay transport with configuration options. // EnableRelay configures libp2p to enable the relay transport with
// configuration options. By default, this option only configures libp2p to
// accept inbound connections from relays and make outbound connections
// _through_ relays when requested by the remote peer. (default: enabled)
//
// To _act_ as a relay, pass the circuit.OptHop option.
func EnableRelay(options ...circuit.RelayOpt) Option { func EnableRelay(options ...circuit.RelayOpt) Option {
return func(cfg *Config) error { return func(cfg *Config) error {
cfg.RelayCustom = true cfg.RelayCustom = true
@ -211,7 +216,7 @@ func EnableRelay(options ...circuit.RelayOpt) Option {
} }
} }
// DisableRelay configures libp2p to disable the relay transport // DisableRelay configures libp2p to disable the relay transport.
func DisableRelay() Option { func DisableRelay() Option {
return func(cfg *Config) error { return func(cfg *Config) error {
cfg.RelayCustom = true cfg.RelayCustom = true
@ -220,8 +225,18 @@ func DisableRelay() Option {
} }
} }
// EnableAutoRelay configures libp2p to enable autorelay advertising; requires relay to // EnableAutoRelay configures libp2p to enable the AutoRelay subsystem. It is an
// be enabled and the Routing option to provide an instance of ContentRouting. // error to enable AutoRelay without enabling relay (enabled by default) and
// routing (not enabled by default).
//
// This subsystem performs two functions:
//
// 1. When this libp2p node is configured to act as a relay "hop"
// (circuit.OptHop is passed to EnableRelay), this node will advertise itself
// as a public relay using the provided routing system.
// 2. When this libp2p node is _not_ configured as a relay "hop", it will
// automatically if it is unreachable (e.g., behind a NAT). If so, it will
// find, configure, and announce a set of public relays.
func EnableAutoRelay() Option { func EnableAutoRelay() Option {
return func(cfg *Config) error { return func(cfg *Config) error {
cfg.EnableAutoRelay = true cfg.EnableAutoRelay = true