AutoRelay enables libp2p nodes to dynamically find and bind to relays on the network. Once binding (listening) is done, the node can and should advertise its addresses to the network, allowing any other node to dial it over its bound relay(s). While direct connections to nodes are preferable, it's not always possible to do so due to NATs.
Use Cases
Finding Relays
A connected relay
The Circuit Relay module has the ability to ask connected nodes if they support the relay HOP protocol. If they do, the libp2p node can bind to that relay as a listener. A node should record a list of relays and use only a subset of those to avoid binding to a large number of relays, as this is not considerate to those relays.
- When a node connects to a peer that announces support for the relay protocol,
/libp2p/circuit/relay/0.1.0, it may ask that node if it support HOP.
- If the peer supports
HOP, libp2p should add it to its list of known relays.
- When a known relay is added, libp2p should check to see if it needs a/another relay (to meet some min threshold). If below that threshold, libp2p should bind to that relay and add it to its announced addresses.
- When adding announced addresses, libp2p SHOULD avoid adding private addresses of the relay, such as
/ip4/127.0.0.1/tcp/4001.
- If libp2p does not have enough known relays, it should query the network if possible.
- When libp2p updates its addresses, it should update the network.
Remote Relays
When a node with AutoRelay enabled boots, it should search the network for the relay protocol, /libp2p/relay. This search may be done via one of several options leveraging libp2p.contentRouting.findProviders(). Depending on what features are turned on this may include: the DHT, Delegate Routing, and/or the Rendezvous Protocol (WIP).
If a node does not have enough known relays connected, and is unable to connect to other known relays, it should query the network for more relays. This should be done with a backoff to avoid spamming queries.
References:
AutoRelay enables libp2p nodes to dynamically find and bind to relays on the network. Once binding (listening) is done, the node can and should advertise its addresses to the network, allowing any other node to dial it over its bound relay(s). While direct connections to nodes are preferable, it's not always possible to do so due to NATs.
Use Cases
Finding Relays
A connected relay
The Circuit Relay module has the ability to ask connected nodes if they support the relay
HOPprotocol. If they do, the libp2p node can bind to that relay as a listener. A node should record a list of relays and use only a subset of those to avoid binding to a large number of relays, as this is not considerate to those relays./libp2p/circuit/relay/0.1.0, it may ask that node if it supportHOP.HOP, libp2p should add it to its list of known relays./ip4/127.0.0.1/tcp/4001.Remote Relays
When a node with AutoRelay enabled boots, it should search the network for the relay protocol,
/libp2p/relay. This search may be done via one of several options leveraginglibp2p.contentRouting.findProviders(). Depending on what features are turned on this may include: the DHT, Delegate Routing, and/or the Rendezvous Protocol (WIP).If a node does not have enough known relays connected, and is unable to connect to other known relays, it should query the network for more relays. This should be done with a backoff to avoid spamming queries.
References: