multicast-dns
Advanced tools
Comparing version 5.0.0 to 5.0.1
{ | ||
"name": "multicast-dns", | ||
"version": "5.0.0", | ||
"version": "5.0.1", | ||
"description": "Low level multicast-dns implementation in pure javascript", | ||
@@ -14,4 +14,4 @@ "main": "index.js", | ||
"devDependencies": { | ||
"standard": "^3.3.2", | ||
"tape": "^3.0.3" | ||
"standard": "^5.4.1", | ||
"tape": "^4.4.0" | ||
}, | ||
@@ -18,0 +18,0 @@ "repository": { |
var types = require('./types') | ||
var name = {} | ||
var FLUSH_MASK = 1 << 15 | ||
@@ -86,3 +87,3 @@ name.decode = function (buf, offset) { | ||
arcount: buf.readUInt16BE(offset + 10) | ||
} | ||
} | ||
} | ||
@@ -330,2 +331,5 @@ | ||
a.flush = !!(a.class & FLUSH_MASK) | ||
if (a.flush) a.class &= ~FLUSH_MASK | ||
var enc = renc(a.type) | ||
@@ -346,3 +350,7 @@ a.data = enc.decode(buf, offset + 8) | ||
buf.writeUInt16BE(types.toType(a.type), offset) | ||
buf.writeUInt16BE(a.class === undefined ? 1 : a.class, offset + 2) | ||
var klass = a.class === undefined ? 1 : a.class | ||
if (a.flush) klass |= FLUSH_MASK // the 1st bit of the class is the flush bit | ||
buf.writeUInt16BE(klass, offset + 2) | ||
buf.writeUInt32BE(a.ttl || 0, offset + 4) | ||
@@ -349,0 +357,0 @@ |
@@ -59,4 +59,5 @@ # multicast-dns | ||
type: 'A', | ||
class: 32769, | ||
class: 1, | ||
ttl: 120, | ||
flush: true, | ||
data: '192.168.1.5' } ], | ||
@@ -67,9 +68,11 @@ authorities: [], | ||
type: 'A', | ||
class: 32769, | ||
class: 1, | ||
ttl: 120, | ||
flush: true, | ||
data: '192.168.1.5' }, | ||
{ name: 'brunhilde.local', | ||
type: 'AAAA', | ||
class: 32769, | ||
class: 1, | ||
ttl: 120, | ||
flush: true, | ||
data: 'fe80::5ef9:38ff:fe8c:ceaa' } ] } | ||
@@ -76,0 +79,0 @@ ``` |
41
test.js
@@ -60,3 +60,3 @@ var mdns = require('./') | ||
t.same(packet.answers.length, 1, 'one answer') | ||
t.same(packet.answers[0], {type: 'A', name: 'hello-world', ttl: 120, data: '127.0.0.1', class: 1}) | ||
t.same(packet.answers[0], {type: 'A', name: 'hello-world', ttl: 120, data: '127.0.0.1', class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -80,4 +80,4 @@ t.end() | ||
t.same(packet.answers.length, 2, 'one answers') | ||
t.same(packet.answers[0], {type: 'A', name: 'hello-world', ttl: 120, data: '127.0.0.1', class: 1}) | ||
t.same(packet.answers[1], {type: 'A', name: 'hej.verden', ttl: 120, data: '127.0.0.2', class: 1}) | ||
t.same(packet.answers[0], {type: 'A', name: 'hello-world', ttl: 120, data: '127.0.0.1', class: 1, flush: false}) | ||
t.same(packet.answers[1], {type: 'A', name: 'hej.verden', ttl: 120, data: '127.0.0.2', class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -100,3 +100,3 @@ t.end() | ||
t.same(packet.answers.length, 1, 'one answer') | ||
t.same(packet.answers[0], {type: 'AAAA', name: 'hello-world', ttl: 120, data: 'fe80::5ef9:38ff:fe8c:ceaa', class: 1}) | ||
t.same(packet.answers[0], {type: 'AAAA', name: 'hello-world', ttl: 120, data: 'fe80::5ef9:38ff:fe8c:ceaa', class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -119,3 +119,3 @@ t.end() | ||
t.same(packet.answers.length, 1, 'one answer') | ||
t.same(packet.answers[0], {type: 'SRV', name: 'hello-world', ttl: 120, data: {port: 11111, target: 'hello.world.com', priority: 10, weight: 12}, class: 1}) | ||
t.same(packet.answers[0], {type: 'SRV', name: 'hello-world', ttl: 120, data: {port: 11111, target: 'hello.world.com', priority: 10, weight: 12}, class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -140,3 +140,3 @@ t.end() | ||
t.same(packet.answers.length, 1, 'one answer') | ||
t.same(packet.answers[0], {type: 'TXT', name: 'hello-world', ttl: 120, data: data, class: 1}) | ||
t.same(packet.answers[0], {type: 'TXT', name: 'hello-world', ttl: 120, data: data, class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -156,3 +156,3 @@ t.end() | ||
dns.once('response', function (packet) { | ||
t.same(packet.answers[0], {type: 'TXT', name: 'hello-world', ttl: 120, data: new Buffer('00', 'hex'), class: 1}) | ||
t.same(packet.answers[0], {type: 'TXT', name: 'hello-world', ttl: 120, data: new Buffer('00', 'hex'), class: 1, flush: false}) | ||
dns.destroy(function () { | ||
@@ -165,1 +165,28 @@ t.end() | ||
}) | ||
test('cache flush bit', function (dns, t) { | ||
dns.once('query', function (packet) { | ||
dns.respond({ | ||
answers: [ | ||
{type: 'A', name: 'foo', ttl: 120, data: '127.0.0.1', class: 1, flush: true}, | ||
{type: 'A', name: 'foo', ttl: 120, data: '127.0.0.2', class: 1, flush: false} | ||
], | ||
additionals: [ | ||
{type: 'A', name: 'foo', ttl: 120, data: '127.0.0.3', class: 1, flush: true} | ||
] | ||
}) | ||
}) | ||
dns.once('response', function (packet) { | ||
t.same(packet.answers, [ | ||
{type: 'A', name: 'foo', ttl: 120, data: '127.0.0.1', class: 1, flush: true}, | ||
{type: 'A', name: 'foo', ttl: 120, data: '127.0.0.2', class: 1, flush: false} | ||
]) | ||
t.same(packet.additionals[0], {type: 'A', name: 'foo', ttl: 120, data: '127.0.0.3', class: 1, flush: true}) | ||
dns.destroy(function () { | ||
t.end() | ||
}) | ||
}) | ||
dns.query('foo', 'A') | ||
}) |
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
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
29454
736
208