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

Commit

Permalink
fix: only announce TCP for now
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jan 28, 2017
1 parent 30517e6 commit 234ddbe
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 51 deletions.
47 changes: 0 additions & 47 deletions examples/example.js

This file was deleted.

9 changes: 7 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ class MulticastDNS extends EventEmitter {
query.gotQuery(event, this.mdns, this.peerInfo, this.serviceTag, this.broadcast)
})

callback()
setImmediate(() => callback())
}

stop (callback) {
this.mdns.destroy(callback)
if (!this.mdns) {
callback(new Error('MulticastDNS service had not started yet'))
} else {
this.mdns.destroy(callback)
this.mdns = undefined
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ module.exports = {
gotQuery: function (qry, mdns, peerInfo, serviceTag, broadcast) {
if (!broadcast) { return }

const multiaddrs = tcp.filter(peerInfo.multiaddrs)
// Only announce TCP for now
if (multiaddrs.length === 0) { return }

if (qry.questions[0] && qry.questions[0].name === serviceTag) {
const answers = []

Expand All @@ -94,7 +98,6 @@ module.exports = {
})

// Only announce TCP multiaddrs for now
const multiaddrs = tcp.filter(peerInfo.multiaddrs)
const port = multiaddrs[0].toString().split('/')[4]

answers.push({
Expand Down
4 changes: 3 additions & 1 deletion test/multicast-dns.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ describe('MulticastDNS', () => {

parallel([
(cb) => mdnsA.start(cb),
(cb) => mdnsC.start(cb)
(cb) => mdnsC.start(cb),
(cb) => mdnsD.start(cb)

], () => {
mdnsA.once('peer', (peerInfo) => {
expect(pC.id.toB58String()).to.eql(peerInfo.id.toB58String())
Expand Down

0 comments on commit 234ddbe

Please sign in to comment.