mirror of
https://github.com/fluencelabs/js-libp2p-tcp
synced 2025-04-25 11:42:31 +00:00
fix: listen with multiaddr7
License: MIT Signed-off-by: Jacob Heun <jacobheun@gmail.com>
This commit is contained in:
parent
bf532d181a
commit
ba0346cbb6
@ -84,7 +84,10 @@ module.exports = (handler) => {
|
|||||||
|
|
||||||
listener.listen = (ma, callback) => {
|
listener.listen = (ma, callback) => {
|
||||||
listeningAddr = ma
|
listeningAddr = ma
|
||||||
if (includes(ma.protoNames(), 'ipfs')) {
|
if (typeof ma.decapsulateCode === 'function') {
|
||||||
|
ipfsId = getIpfsId(ma)
|
||||||
|
listeningAddr = ma.decapsulateCode(IPFS_CODE)
|
||||||
|
} else if (includes(ma.protoNames(), 'ipfs')) {
|
||||||
ipfsId = getIpfsId(ma)
|
ipfsId = getIpfsId(ma)
|
||||||
listeningAddr = ma.decapsulate('ipfs')
|
listeningAddr = ma.decapsulate('ipfs')
|
||||||
}
|
}
|
||||||
|
@ -127,6 +127,19 @@ describe('listen', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('getAddrs preserves IPFS Id (multiaddr 7)', (done) => {
|
||||||
|
const mh = multiaddr7('/ip4/127.0.0.1/tcp/9090/p2p/Qmb6owHp6eaWArVbcJJbQSyifyJBttMMjYV76N2hMbf5Vw')
|
||||||
|
const listener = tcp.createListener((conn) => {})
|
||||||
|
listener.listen(mh, () => {
|
||||||
|
listener.getAddrs((err, multiaddrs) => {
|
||||||
|
expect(err).to.not.exist()
|
||||||
|
expect(multiaddrs.length).to.equal(1)
|
||||||
|
expect(multiaddrs[0]).to.deep.equal(mh)
|
||||||
|
listener.close(done)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('dial', () => {
|
describe('dial', () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user