mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-05-21 14:41:22 +00:00
fix: use libp2p.multiaddrs instead of listen
Co-Authored-By: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
parent
51474c334a
commit
7fbd1556e8
@ -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()
|
||||
// [ <Multiaddr 047f00000106f9ba - /ip4/127.0.0.1/tcp/63930> ]
|
||||
```
|
||||
|
||||
### contentRouting.findProviders
|
||||
|
||||
|
@ -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",
|
||||
|
@ -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(),
|
||||
|
@ -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()
|
||||
|
@ -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')
|
||||
}])
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user