Socket
Socket
Sign inDemoInstall

multicast-dns

Package Overview
Dependencies
Maintainers
2
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multicast-dns - npm Package Compare versions

Comparing version 5.1.0 to 5.2.0

foo.js

41

example.js

@@ -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

@@ -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) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc