diff --git a/doc/API.md b/doc/API.md index df331fe3..8278e100 100644 --- a/doc/API.md +++ b/doc/API.md @@ -366,10 +366,9 @@ const latency = await libp2p.ping(otherPeerId) ## multiaddrs -Get peer advertising multiaddrs. This computes the advertising multiaddrs of the peer by -joining the multiaddrs that libp2p transports are listening on with the announce multiaddrs -provided in hte libp2p config. No announce multiaddrs will be filtered out, even when -using random ports in the provided multiaddrs. +Gets the multiaddrs the libp2p node announces to the network. This computes the advertising multiaddrs +of the peer by joining the multiaddrs that libp2p transports are listening on with the announce multiaddrs +provided in the libp2p config. Configured no announce multiaddrs will be filtered out of the advertised addresses. `libp2p.multiaddrs` @@ -465,6 +464,7 @@ Get the multiaddrs that libp2p transports are using to listen on. // ... const listenMa = libp2p.transportManager.getAddrs() // [ ] +``` ### contentRouting.findProviders diff --git a/package.json b/package.json index 71323c2a..1176a6ca 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,7 @@ "libp2p-floodsub": "^0.21.0", "libp2p-gossipsub": "^0.4.0", "libp2p-kad-dht": "^0.19.1", - "libp2p-mdns": "^0.14.0", + "libp2p-mdns": "^0.14.1", "libp2p-mplex": "^0.9.5", "libp2p-secio": "^0.12.4", "libp2p-tcp": "^0.14.1", diff --git a/src/circuit/index.js b/src/circuit/index.js index 0e7c9fe3..904e9ad2 100644 --- a/src/circuit/index.js +++ b/src/circuit/index.js @@ -32,7 +32,7 @@ class Circuit { this._connectionManager = libp2p.connectionManager this._upgrader = upgrader this._options = libp2p._config.relay - this.addressManager = libp2p.addressManager + this._libp2p = libp2p this.peerId = libp2p.peerId this._registrar.handle(multicodec, this._onProtocol.bind(this)) } @@ -122,7 +122,7 @@ class Circuit { type: CircuitPB.Type.HOP, srcPeer: { id: this.peerId.toBytes(), - addrs: this.addressManager.getListenAddrs().map(addr => addr.buffer) + addrs: this._libp2p.multiaddrs.map(addr => addr.buffer) }, dstPeer: { id: destinationPeer.toBytes(), diff --git a/src/index.js b/src/index.js index 19e383ca..4d4c7bcf 100644 --- a/src/index.js +++ b/src/index.js @@ -189,8 +189,7 @@ class Libp2p extends EventEmitter { */ async start () { log('libp2p is starting') - // TODO: consider validate listen addresses on start? - // depend on transports? + try { await this._onStarting() await this._onDidStart() diff --git a/test/dialing/relay.node.js b/test/dialing/relay.node.js index 003bab4f..bdf8f1b1 100644 --- a/test/dialing/relay.node.js +++ b/test/dialing/relay.node.js @@ -161,7 +161,7 @@ describe('Dialing (via relay, TCP)', () => { expect(dstLibp2p.transportManager.getAddrs()).to.have.deep.members([...tcpAddrs, dialAddr.decapsulate('p2p')]) // Tamper with the our multiaddrs for the circuit message - sinon.stub(srcLibp2p.addressManager, 'getListenAddrs').returns([{ + sinon.stub(srcLibp2p, 'multiaddrs').value([{ buffer: Buffer.from('an invalid multiaddr') }])