Skip to content
This repository has been archived by the owner on Jul 21, 2023. It is now read-only.

fix: actually check tcp multiaddrs #94

Merged
merged 2 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"homepage": "https://github.com/libp2p/js-libp2p-mdns",
"devDependencies": {
"aegir": "^21.0.2",
"aegir": "^25.0.0",
"chai": "^4.2.0",
"delay": "^4.3.0",
"dirty-chai": "^2.0.1",
Expand All @@ -44,9 +44,9 @@
},
"dependencies": {
"debug": "^4.1.1",
"multiaddr": "^7.1.0",
"multiaddr": "^7.5.0",
"multicast-dns": "^7.2.0",
"peer-id": "~0.13.3"
"peer-id": "^0.13.13"
},
"contributors": [
"David Dias <daviddias.p@gmail.com>",
Expand Down
8 changes: 7 additions & 1 deletion src/compat/responder.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,13 @@ class Responder {
}

_onQuery (event, info) {
const addresses = this._multiaddrs.map(ma => ma.toOptions())
const addresses = this._multiaddrs.reduce((acc, addr) => {
if (addr.isThinWaistAddress()) {
acc.push(addr.toOptions())
}
return acc
}, [])

// Only announce TCP for now
if (!addresses.length) return

Expand Down
8 changes: 7 additions & 1 deletion src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,13 @@ module.exports = {
gotQuery: function (qry, mdns, peerId, multiaddrs, serviceTag, broadcast) {
if (!broadcast) { return }

const addresses = multiaddrs.map(ma => ma.toOptions())
const addresses = multiaddrs.reduce((acc, addr) => {
if (addr.isThinWaistAddress()) {
acc.push(addr.toOptions())
}
return acc
}, [])

// Only announce TCP for now
if (addresses.length === 0) { return }

Expand Down
10 changes: 7 additions & 3 deletions test/multicast-dns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,21 @@ describe('MulticastDNS', () => {
])

aMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20001')
multiaddr('/ip4/127.0.0.1/tcp/20001'),
multiaddr('/dns4/webrtc-star.discovery.libp2p.io/tcp/443/wss/p2p-webrtc-star'),
multiaddr('/dns4/discovery.libp2p.io/tcp/8443')
]

bMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20002'),
multiaddr('/ip6/::1/tcp/20002')
multiaddr('/ip6/::1/tcp/20002'),
multiaddr('/dnsaddr/discovery.libp2p.io')
]

cMultiaddrs = [
multiaddr('/ip4/127.0.0.1/tcp/20003'),
multiaddr('/ip4/127.0.0.1/tcp/30003/ws')
multiaddr('/ip4/127.0.0.1/tcp/30003/ws'),
multiaddr('/dns4/discovery.libp2p.io')
]

dMultiaddrs = [
Expand Down