Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.0.1 to 5.0.2

26

example.js

@@ -0,1 +1,3 @@

var local = require('os').hostname() + '.local'
var mdns = require('./')()

@@ -13,10 +15,30 @@

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'
}]
})
}
})
// lets query for an A record for 'brunhilde.local'
// lets query for an A record for 'your-own-hostname.local'
mdns.query({
questions: [{
name: 'brunhilde.local',
name: local,
type: 'A'
}]
})

5

package.json
{
"name": "multicast-dns",
"version": "5.0.1",
"version": "5.0.2",
"description": "Low level multicast-dns implementation in pure javascript",

@@ -11,3 +11,4 @@ "main": "index.js",

"dependencies": {
"thunky": "^0.1.0"
"thunky": "^0.1.0",
"ip": "^1.1.0"
},

@@ -14,0 +15,0 @@ "devDependencies": {

var types = require('./types')
var ip = require('ip')

@@ -254,6 +255,3 @@ var name = {}

offset += 2
var nums = host.split('.')
for (var i = 0; i < 4; i++) buf[offset++] = Number(nums[i])
ip.toBuffer(host, buf, offset)
ra.encode.bytes = 6

@@ -265,8 +263,5 @@ return buf

offset += 2
var host = []
for (var i = 0; i < 4; i++) host.push(buf[offset++])
var host = ip.toString(buf, offset, 4)
ra.decode.bytes = 6
return host.join('.')
return host
}

@@ -283,9 +278,3 @@

offset += 2
var nums = host.split(':')
var idx = nums.indexOf('')
var missing = 8 - nums.length
for (var i = 0; i < missing; i++) nums.splice(idx, 0, '0')
for (var j = 0; j < nums.length; j++) buf.writeUInt16BE(parseInt(nums[j] || 0, 16), offset + 2 * j)
ip.toBuffer(host, buf, offset)
raaaa.encode.bytes = 18

@@ -297,8 +286,5 @@ return buf

offset += 2
var host = []
for (var i = 0; i < 16; i += 2) host.push(buf.toString('hex', offset + i, offset + i + 2))
var host = ip.toString(buf, offset, 16)
raaaa.decode.bytes = 18
return host.join(':').replace(/(:|^)0000(:0000)*(:|$)/, '$1$3').replace(/(^|:)0*(\d)/g, '$1$2')
return host
}

@@ -305,0 +291,0 @@

@@ -185,3 +185,3 @@ # multicast-dns

name: 'brunhilde.local',
type: 'A'
type: 'A',
ttl: 300,

@@ -206,4 +206,15 @@ data: '192.168.1.5'

# Development
To start hacking on this module you can use this example to get started
```
git clone git://github.com/mafintosh/multicast-dns.git
npm install
node example.js
node cli.js $(hostname).local
```
## License
MIT
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