multicast-dns
Advanced tools
Comparing version 5.1.0 to 5.2.0
@@ -1,3 +0,1 @@ | ||
var local = require('os').hostname() + '.local' | ||
var mdns = require('./')() | ||
@@ -15,30 +13,25 @@ | ||
console.log('got a query packet:', query) | ||
// send a response for 'your-own-hostname.local' | ||
if (query.questions.length && query.questions[0].name === local) { | ||
mdns.respond({ | ||
answers: [{ | ||
name: 'my-service', | ||
type: 'SRV', | ||
data: { | ||
port: 6666, | ||
weigth: 0, | ||
priority: 10, | ||
target: local | ||
} | ||
}, { | ||
name: local, | ||
type: 'A', | ||
ttl: 300, | ||
data: '192.168.1.5' | ||
}] | ||
}) | ||
} | ||
// iterate over all questions to check if we should respond | ||
query.questions.forEach(function (q) { | ||
if (q.type === 'A' && q.name === 'example.local') { | ||
// send an A-record response for example.local | ||
mdns.respond({ | ||
answers: [{ | ||
name: 'example.local', | ||
type: 'A', | ||
ttl: 300, | ||
data: '192.168.1.5' | ||
}] | ||
}) | ||
} | ||
}) | ||
}) | ||
// lets query for an A record for 'your-own-hostname.local' | ||
// lets query for an A-record for example.local | ||
mdns.query({ | ||
questions: [{ | ||
name: local, | ||
name: 'example.local', | ||
type: 'A' | ||
}] | ||
}) |
{ | ||
"name": "multicast-dns", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Low level multicast-dns implementation in pure javascript", | ||
@@ -38,3 +38,7 @@ "main": "index.js", | ||
"avahi" | ||
], | ||
"coordinates": [ | ||
56.009986032141335, | ||
11.961881270211734 | ||
] | ||
} |
@@ -6,2 +6,3 @@ var types = require('./types') | ||
var FLUSH_MASK = 1 << 15 | ||
var QU_MASK = 1 << 15 | ||
@@ -369,2 +370,5 @@ name.decode = function (buf, offset) { | ||
var qu = !!(q.class & QU_MASK) | ||
if (qu) q.class &= ~QU_MASK | ||
question.decode.bytes = offset - oldOffset | ||
@@ -371,0 +375,0 @@ return q |
23
test.js
@@ -19,3 +19,7 @@ var mdns = require('./') | ||
port(function (p) { | ||
fn(mdns({ip: '127.0.0.1', port: p, multicast: false}), t) | ||
var dns = mdns({ip: '127.0.0.1', port: p, multicast: false}) | ||
dns.on('warning', function (e) { | ||
t.error(e) | ||
}) | ||
fn(dns, t) | ||
}) | ||
@@ -161,2 +165,19 @@ }) | ||
test('QU question bit', function (dns, t) { | ||
dns.once('query', function (packet) { | ||
t.same(packet.questions, [ | ||
{type: 'A', name: 'foo', class: 1}, | ||
{type: 'A', name: 'bar', class: 1} | ||
]) | ||
dns.destroy(function () { | ||
t.end() | ||
}) | ||
}) | ||
dns.query([ | ||
{type: 'A', name: 'foo', class: 32769}, | ||
{type: 'A', name: 'bar', class: 1} | ||
]) | ||
}) | ||
test('cache flush bit', function (dns, t) { | ||
@@ -163,0 +184,0 @@ dns.once('query', function (packet) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30662
12
781
3