Gathering detailed insights and metrics for multicast-dns
Gathering detailed insights and metrics for multicast-dns
Gathering detailed insights and metrics for multicast-dns
Gathering detailed insights and metrics for multicast-dns
Low level multicast-dns implementation in pure javascript
npm install multicast-dns
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
513 Stars
133 Commits
91 Forks
10 Watching
2 Branches
15 Contributors
Updated on 17 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-4.7%
2,384,497
Compared to previous day
Last week
2.6%
12,557,576
Compared to previous week
Last month
12.4%
52,130,313
Compared to previous month
Last year
-2.1%
576,530,509
Compared to previous year
2
Low level multicast-dns implementation in pure javascript
npm install multicast-dns
1var mdns = require('multicast-dns')() 2 3mdns.on('response', function(response) { 4 console.log('got a response packet:', response) 5}) 6 7mdns.on('query', function(query) { 8 console.log('got a query packet:', query) 9}) 10 11// lets query for an A record for 'brunhilde.local' 12mdns.query({ 13 questions:[{ 14 name: 'brunhilde.local', 15 type: 'A' 16 }] 17})
Running the above (change brunhilde.local
to your-own-hostname.local
) will print an echo of the query packet first
1got a query packet: { type: 'query', 2 questions: [ { name: 'brunhilde.local', type: 'A', class: 1 } ], 3 answers: [], 4 authorities: [], 5 additionals: [] }
And then a response packet
1got a response packet: { type: 'response', 2 questions: [], 3 answers: 4 [ { name: 'brunhilde.local', 5 type: 'A', 6 class: 'IN', 7 ttl: 120, 8 flush: true, 9 data: '192.168.1.5' } ], 10 authorities: [], 11 additionals: 12 [ { name: 'brunhilde.local', 13 type: 'A', 14 class: 'IN', 15 ttl: 120, 16 flush: true, 17 data: '192.168.1.5' }, 18 { name: 'brunhilde.local', 19 type: 'AAAA', 20 class: 'IN', 21 ttl: 120, 22 flush: true, 23 data: 'fe80::5ef9:38ff:fe8c:ceaa' } ] }
npm install -g multicast-dns
multicast-dns brunhilde.local
> 192.168.1.1
A packet has the following format
1{ 2 questions: [{ 3 name: 'brunhilde.local', 4 type: 'A' 5 }], 6 answers: [{ 7 name: 'brunhilde.local', 8 type: 'A', 9 ttl: seconds, 10 data: (record type specific data) 11 }], 12 additionals: [ 13 (same format as answers) 14 ], 15 authorities: [ 16 (same format as answers) 17 ] 18}
Currently data from SRV
, A
, PTR
, TXT
, AAAA
and HINFO
records is passed
mdns = multicastdns([options])
Creates a new mdns
instance. Options can contain the following
1{ 2 multicast: true // use udp multicasting 3 interface: '192.168.0.2' // explicitly specify a network interface. defaults to all 4 port: 5353, // set the udp port 5 ip: '224.0.0.251', // set the udp ip 6 ttl: 255, // set the multicast ttl 7 loopback: true, // receive your own packets 8 reuseAddr: true // set the reuseAddr option when creating the socket (requires node >=0.11.13) 9}
mdns.on('query', (packet, rinfo))
Emitted when a query packet is received.
1mdns.on('query', function(query) { 2 if (query.questions[0] && query.questions[0].name === 'brunhilde.local') { 3 mdns.respond(someResponse) // see below 4 } 5})
mdns.on('response', (packet, rinfo))
Emitted when a response packet is received.
The response might not be a response to a query you send as this is the result of someone multicasting a response.
mdns.query(packet, [cb])
Send a dns query. The callback will be called when the packet was sent.
The following shorthands are equivalent
1mdns.query('brunhilde.local', 'A') 2mdns.query([{name:'brunhilde.local', type:'A'}]) 3mdns.query({ 4 questions: [{name:'brunhilde.local', type:'A'}] 5})
mdns.respond(packet, [cb])
Send a dns response. The callback will be called when the packet was sent.
1// reply with a SRV and a A record as an answer 2mdns.respond({ 3 answers: [{ 4 name: 'my-service', 5 type: 'SRV', 6 data: { 7 port: 9999, 8 weight: 0, 9 priority: 10, 10 target: 'my-service.example.com' 11 } 12 }, { 13 name: 'brunhilde.local', 14 type: 'A', 15 ttl: 300, 16 data: '192.168.1.5' 17 }] 18})
The following shorthands are equivalent
1mdns.respond([{name:'brunhilde.local', type:'A', data:'192.158.1.5'}]) 2mdns.respond({ 3 answers: [{name:'brunhilde.local', type:'A', data:'192.158.1.5'}] 4})
mdns.destroy()
Destroy the mdns instance. Closes the udp socket.
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
MIT
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
security policy file detected
Details
Reason
license file detected
Details
Reason
0 existing vulnerabilities detected
Reason
Found 7/30 approved changesets -- score normalized to 2
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More