diff --git a/doc/CONFIGURATION.md b/doc/CONFIGURATION.md index 41055517..4804185a 100644 --- a/doc/CONFIGURATION.md +++ b/doc/CONFIGURATION.md @@ -20,6 +20,7 @@ - [Customizing DHT](#customizing-dht) - [Setup with Content and Peer Routing](#setup-with-content-and-peer-routing) - [Setup with Relay](#setup-with-relay) + - [Setup with Auto Relay](#setup-with-auto-relay) - [Setup with Keychain](#setup-with-keychain) - [Configuring Dialing](#configuring-dialing) - [Configuring Connection Manager](#configuring-connection-manager) @@ -419,12 +420,43 @@ const node = await Libp2p.create({ hop: { enabled: true, // Allows you to be a relay for other peers active: true // You will attempt to dial destination peers if you are not connected to them + }, + advertise: { + bootDelay: 15 * 60 * 1000, // Delay before HOP relay service is advertised on the network + enabled: true, // Allows you to disable the advertise of the Hop service + ttl: 30 * 60 * 1000 // Delay Between HOP relay service advertisements on the network } } } }) ``` +#### Setup with Auto Relay + +```js +const Libp2p = require('libp2p') +const TCP = require('libp2p-tcp') +const MPLEX = require('libp2p-mplex') +const SECIO = require('libp2p-secio') + +const node = await Libp2p.create({ + modules: { + transport: [TCP], + streamMuxer: [MPLEX], + connEncryption: [SECIO] + }, + config: { + relay: { // Circuit Relay options (this config is part of libp2p core configurations) + enabled: true, // Allows you to dial and accept relayed connections. Does not make you a relay. + autoRelay: { + enabled: false, // Allows you to bind to relays with HOP enabled for improving node dialability + maxListeners: 2 // Configure maximum number of HOP relays to use + }, + } + } +}) +``` + #### Setup with Keychain Libp2p allows you to setup a secure keychain to manage your keys. The keychain configuration object should have the following properties: diff --git a/src/circuit/auto-relay.js b/src/circuit/auto-relay.js index 4bffecc0..c0475dba 100644 --- a/src/circuit/auto-relay.js +++ b/src/circuit/auto-relay.js @@ -242,7 +242,7 @@ class AutoRelay { try { const cid = await namespaceToCid(RELAY_RENDEZVOUS_NS) for await (const provider of this._libp2p.contentRouting.findProviders(cid)) { - if (!provider || !provider.multiaddrs.length) { + if (!provider.multiaddrs.length) { continue } const peerId = provider.id