{"name":"multicast-dns","version":"2.1.0","description":"Low level multicast-dns implementation in pure javascript","main":"index.js","scripts":{"test":"standard && tape test.js"},"bin":{"multicast-dns":"cli.js"},"dependencies":{"thunky":"^0.1.0"},"devDependencies":{"standard":"^3.3.2","tape":"^3.0.3"},"repository":{"type":"git","url":"https://github.com/mafintosh/multicast-dns.git"},"author":{"name":"Mathias Buus","url":"@mafintosh"},"license":"MIT","bugs":{"url":"https://github.com/mafintosh/multicast-dns/issues"},"homepage":"https://github.com/mafintosh/multicast-dns","keywords":["multicast","dns","mdns","multicastdns","dns-sd","service","discovery","bonjour","avahi"],"gitHead":"e061f37a13437ba55441cec8f6b04cbda1b4cd74","_id":"multicast-dns@2.1.0","_shasum":"f0f93e7584bb4e0f59d8f838b2ded055ff77f535","_from":".","_npmVersion":"2.7.5","_nodeVersion":"1.6.4","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dist":{"shasum":"f0f93e7584bb4e0f59d8f838b2ded055ff77f535","tarball":"http://registry-npm.ywwl.com/multicast-dns/download/multicast-dns-2.1.0.tgz","integrity":"sha512-zsXx7ybQklUoWRRvfrhruak08n2MksHn3Cb3DDejD1r26sKiRgm39eErLPe+NKJYkZM1JeBCdNH9my4mDTLCcQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC36d+Yy16+qTDQEIdOLVnj0oDxfLH76+XyfgBrJ3dutQIgG3ssPJxbnHuK4l5oPqdQTqQ/XekEPOUKO8xT/5R4OVE="}],"size":7045,"noattachment":false,"key":"/multicast-dns/-/multicast-dns-2.1.0.tgz"},"directories":{},"readme":"# multicast-dns\n\nLow level multicast-dns implementation in pure javascript\n\n```\nnpm install multicast-dns\n```\n\n[![build status](http://img.shields.io/travis/mafintosh/multicast-dns.svg?style=flat)](http://travis-ci.org/mafintosh/multicast-dns)\n\n## Usage\n\n``` js\nvar mdns = require('multicast-dns')()\n\nmdns.on('response', function(response) {\n  console.log('got a response packet:', response)\n})\n\nmdns.on('query', function(query) {\n  console.log('got a query packet:', query)\n})\n\n// lets query for an A record for 'brunhilde.local'\nmdns.query({\n  questions:[{\n    name: 'brunhilde.local',\n    type: 'A'\n  }]\n})\n```\n\nRunning the above (change `brunhilde.local` to `your-own-hostname.local`) will print an echo of the query packet first\n\n``` js\ngot a query packet: { type: 'query',\n  questions: [ { name: 'brunhilde.local', type: 'A', class: 1 } ],\n  answers: [],\n  authorities: [],\n  additionals: [] }\n```\n\nAnd then a response packet\n\n``` js\ngot a response packet: { type: 'response',\n  questions: [],\n  answers:\n   [ { name: 'brunhilde.local',\n       type: 'A',\n       class: 'IN',\n       ttl: 120,\n       flush: true,\n       data: '192.168.1.5' } ],\n  authorities: [],\n  additionals:\n   [ { name: 'brunhilde.local',\n       type: 'A',\n       class: 'IN',\n       ttl: 120,\n       flush: true,\n       data: '192.168.1.5' },\n     { name: 'brunhilde.local',\n       type: 'AAAA',\n       class: 'IN',\n       ttl: 120,\n       flush: true,\n       data: 'fe80::5ef9:38ff:fe8c:ceaa' } ] }\n```\n\n\n# CLI\n\n```\nnpm install -g multicast-dns\n```\n\n```\nmulticast-dns brunhilde.local\n> 192.168.1.1\n```\n\n# API\n\nA packet has the following format\n\n``` js\n{\n  questions: [{\n    name: 'brunhilde.local',\n    type: 'A'\n  }],\n  answers: [{\n    name: 'brunhilde.local',\n    type: 'A',\n    ttl: seconds,\n    data: (record type specific data)\n  }],\n  additionals: [\n    (same format as answers)\n  ],\n  authorities: [\n    (same format as answers)\n  ]\n}\n```\n\nCurrently data from `SRV`, `A`, `PTR`, `TXT`, `AAAA` and `HINFO` records is passed\n\n#### `mdns = multicastdns([options])`\n\nCreates a new `mdns` instance. Options can contain the following\n\n``` js\n{\n  multicast: true // use udp multicasting\n  interface: '192.168.0.2' // explicitly specify a network interface. defaults to all\n  port: 5353, // set the udp port\n  ip: '224.0.0.251', // set the udp ip\n  ttl: 255, // set the multicast ttl\n  loopback: true, // receive your own packets\n  reuseAddr: true // set the reuseAddr option when creating the socket (requires node >=0.11.13)\n}\n```\n\n#### `mdns.on('query', (packet, rinfo))`\n\nEmitted when a query packet is received.\n\n``` js\nmdns.on('query', function(query) {\n  if (query.questions[0] && query.questions[0].name === 'brunhilde.local') {\n    mdns.respond(someResponse) // see below\n  }\n})\n```\n\n#### `mdns.on('response', (packet, rinfo))`\n\nEmitted when a response packet is received.\n\nThe response might not be a response to a query you send as this\nis the result of someone multicasting a response.\n\n#### `mdns.query(packet, [cb])`\n\nSend a dns query. The callback will be called when the packet was sent.\n\nThe following shorthands are equivalent\n\n``` js\nmdns.query('brunhilde.local', 'A')\nmdns.query([{name:'brunhilde.local', type:'A'}])\nmdns.query({\n  questions: [{name:'brunhilde.local', type:'A'}]\n})\n```\n\n#### `mdns.respond(packet, [cb])`\n\nSend a dns response. The callback will be called when the packet was sent.\n\n``` js\n// reply with a SRV and a A record as an answer\nmdns.respond({\n  answers: [{\n    name: 'my-service',\n    type: 'SRV',\n    data: {\n      port: 9999,\n      weight: 0,\n      priority: 10,\n      target: 'my-service.example.com'\n    }\n  }, {\n    name: 'brunhilde.local',\n    type: 'A',\n    ttl: 300,\n    data: '192.168.1.5'\n  }]\n})\n```\n\nThe following shorthands are equivalent\n\n``` js\nmdns.respond([{name:'brunhilde.local', type:'A', data:'192.158.1.5'}])\nmdns.respond({\n  answers: [{name:'brunhilde.local', type:'A', data:'192.158.1.5'}]\n})\n```\n\n#### `mdns.destroy()`\n\nDestroy the mdns instance. Closes the udp socket.\n\n# Development\n\nTo start hacking on this module you can use this example to get started\n\n```\ngit clone git://github.com/mafintosh/multicast-dns.git\nnpm install\nnode example.js\nnode cli.js $(hostname).local\n```\n\n## License\n\nMIT\n","publish_time":1428429836870,"_cnpm_publish_time":1428429836870,"dist-tags":{"latest":"7.2.5"}}