{"name":"native-dns","version":"0.3.4","author":{"name":"Timothy J Fontaine","email":"tjfontaine@gmail.com","url":"http://atxconsulting.com"},"description":"Replacement for the core DNS module, includes server implementation","keywords":["dns","bind","native"],"homepage":"http://github.com/tjfontaine/node-dns","bugs":{"url":"http://github.com/tjfontaine/node-dns/issues"},"repository":{"type":"git","url":"http://github.com/tjfontaine/node-dns.git"},"main":"dns.js","engines":{"node":">= 0.5.0"},"scripts":{"test":"nodeunit test"},"devDependencies":{"optimist":"","nodeunit":">= 0.7.4"},"contributors":[{"name":"Timothy J Fontaine","email":"tjfontaine@gmail.com"}],"_id":"native-dns@0.3.4","dist":{"shasum":"4f22deb940f09390663a225757f7cab5bcc7ee1e","tarball":"http://registry-npm.ywwl.com/native-dns/download/native-dns-0.3.4.tgz","integrity":"sha512-OWrX4aTSRRuoP6sECjHGV9Od0lfmf4oCvZihp0O6hYdnO7MB4bWHkfrYbSHllcZ4piYjpsADepbI49QD33reKw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGe5/FEyA9ODAwCPbhKBYU2iIPGfB9lcJT4mW9PUix3xAiBWEsfKe51G7Jj0QqE67G/YkCCdxg9svHhNoyq7o9poDA=="}],"size":32320,"noattachment":false,"key":"/native-dns/-/native-dns-0.3.4.tgz"},"_npmVersion":"1.1.70","_npmUser":{"name":"tjfontaine","email":"tjfontaine@gmail.com"},"maintainers":[{"name":"tjfontaine","email":"tjfontaine@gmail.com"}],"directories":{},"readme":"[![Build Status](https://secure.travis-ci.org/tjfontaine/node-dns.png)](http://travis-ci.org/tjfontaine/node-dns)\n\nnative-dns -- A replacement DNS stack for node.js\n=================================================\n\nInstallation\n------------\n\n`npm install native-dns` and then `var dns = require('native-dns');`\n\nClient\n------\n\nnative-dns exports what should be a 1:1 mapping of the upstream node.js dns\nmodule. That is to say if it's listed in the [docs](http://nodejs.org/docs/latest/api/dns.html)\nit should behave similarly. If it doesn't please file an [issue](https://github.com/tjfontaine/node-dns/issues/new)\n\nRequest\n-------\n\nBeyond matching the upstream module, native-dns also provides a method for\ncustomizing queries.\n\n```javascript\nvar dns = require('../dns'),\n  util = require('util');\n\nvar question = dns.Question({\n  name: 'www.google.com',\n  type: 'A',\n});\n\nvar start = Date.now();\n\nvar req = dns.Request({\n  question: question,\n  server: { address: '8.8.8.8', port: 53, type: 'udp' },\n  timeout: 1000,\n});\n\nreq.on('timeout', function () {\n  console.log('Timeout in making request');\n});\n\nreq.on('message', function (err, answer) {\n  answer.answer.forEach(function (a) {\n    console.log(a.address);\n  });\n});\n\nreq.on('end', function () {\n  var delta = (Date.now()) - start;\n  console.log('Finished processing request: ' + delta.toString() + 'ms');\n});\n\nreq.send();\n```\n\nRequest creation takes an object with the following fields\n\n * `question` -- an instance of Question (required)\n * `server` -- defines the remote end point (required)\n  - as an object it should be\n    * `address` -- a string ip address (required)\n    * `port` -- a number for the remote port (optional, default 53)\n    * `type` -- a string indicating `udp` or `tcp` (optional, default `udp`)\nYou do not need to indicate ipv4 or ipv6, the backend will handle that\n  - a string ip address\n * `timeout` -- a number in milliseconds indicating how long to wait for the\nrequest to finish. (optional, default 4000)\n * `try_edns` -- a boolean indicating whether to use an `EDNSPacket` (optional)\n * `cache` -- can be false to disable caching, or implement the cache model, or\nan instance of Cache but with a different store (optional, default\nplatform.cache)\n\nThere are only two methods\n\n * `send` -- sends the actual request to the remote endpoint\n * `cancel` -- cancels the request and ignores any responses\n\nRequest emits the following events\n\n * `message` -- This is where you get a response, passes `(err, answer)` where\nanswer is an instance of `Packet`\n * `timeout` -- Fired when the timeout is reached\n * `cancelled` -- Fired if the request is cancelled\n * `end` -- Always fired after a request finished, regardless of disposition\n\nPlatform\n--------\n\nIf you want to customize all `resolve` or `lookup`s with the replacement client\nstack you can modify the platform settings accessible in the top level `platform`\nobject.\n\nMethods:\n\n * `reload` -- Re-read system configuration files to populate name servers and\nhosts\n\nProperties:\n\n * `ready` -- Boolean whether requests are safe to transit, true after hosts\nand name servers are filled\n * `watching` -- Boolean indicating if system configuration files are watched\nfor changes, default to false (currently can only be enabled on !win32)\n * `name_servers` -- An array of servers used for resolving queries against\n  - Each entry is an object of `{ address: <string ip>, port: 53 }`\n  - On win32 this is hard coded to be google dns until there's a sane way to get\nthe data\n * `search_path` -- An array of domains to try and append after a failed lookup\n * `attempts` -- The number of retries for a failed lookup/timeout (default: 5)\n * `timeout` -- The time each query is allowed to take before trying another\nserver. (in milliseconds, default: 5000 (5 seconds))\n * `edns` -- Whether to try and send edns queries first (default: false)\n * `cache` -- The system wide cache used by default for `lookup` and `resolve`,\nset this to false to disable caching\n\nEvents:\n\n * `ready` -- Emitted after hosts and name servers have been loaded\n * `unready` -- Emitted when hosts and name servers configuration is being\nreloaded.\n\nServer\n------\n\nThere is also a rudimentary server implementation\n\n```javascript\nvar dns = require('../dns'),\n  server = dns.createServer();\n\nserver.on('request', function (request, response) {\n  //console.log(request)\n  response.answer.push(dns.A({\n    name: request.question[0].name,\n    address: '127.0.0.1',\n    ttl: 600,\n  }));\n  response.answer.push(dns.A({\n    name: request.question[0].name,\n    address: '127.0.0.2',\n    ttl: 600,\n  }));\n  response.additional.push(dns.A({\n    name: 'hostA.example.org',\n    address: '127.0.0.3',\n    ttl: 600,\n  }));\n  response.send();\n});\n\nserver.on('error', function (err, buff, req, res) {\n  console.log(err.stack);\n});\n\nserver.serve(15353);\n```\n\nServer creation\n\n * `createServer` and `createUDPServer` -- both create a `UDP` based server,\nthey accept an optional object for configuration,\n  - `{ dgram_type: 'udp4' }` is the default option, the other is `udp6`\n * `createTCPServer` -- creates a TCP based server\n\nServer methods\n\n * `serve(port, [address])` -- specify which port and optional address to listen\non\n * `close()` -- stop the server/close sockets.\n\nServer events\n\n * `listening` -- emitted when underlying socket is listening\n * `close` -- emitted when the underlying socket is closed\n * `request` -- emitted when a dns message is received, and the packet was\nsuccessfully unpacked, passes `(request, response)`\n  - Both `request` and `response` are instances of `Packet` when you're finished\ncreating the response, you merely need to call `.send()` and the packet will\nDoTheRightThing\n * `error` -- emitted when unable to properly unpack the packet, passed `(err, msg, response)`\n * `socketError` -- remap of the underlying socket for the server, passes `(err, socket)`\n\nPacket\n------\n\nProperties:\n\n * `header`\n  - `id` -- request id\n  - `qdcount` -- the number of questions (inferred from array size)\n  - `ancount` -- the number of questions (inferred from array size)\n  - `nscount` -- the number of questions (inferred from array size)\n  - `arcount` -- the number of questions (inferred from array size)\n  - `qr` -- is a query response\n  - `opcode`\n  - `aa` -- Authoritative Answer\n  - `tc` -- Truncation bit\n  - `rd` -- Recursion Desired\n  - `ra` -- Recursion Available\n  - `res1` -- Reserved field\n  - `res2` -- Reserved field\n  - `res3` -- Reserved field\n  - `rcode` -- Response Code (see `consts.NAME_TO_RCODE`)\n * `question` -- array of `Question`s\n * `answer` -- array of `ResourceRecord`s\n * `authority` -- array of `ResourceRecord`s\n * `additional` -- array of `ResourceRecord`s\n\nMethods:\n\n * `send()` -- Handles sending the packet to the right end point\n\nQuestion\n--------\n\nA `Question` is instantiated by passing an object like:\n\n * `name` -- i.e. 'www.google.com' (required)\n * `type` -- Either the string representation of the record type, or the integer\nvalue, see `consts.NAME_TO_QTYPE` (default: 'A')\n * `class` -- The class of service, default to 1 meaning internet\n\nResourceRecord\n--------------\n\nResourceRecords are what populate `answer`, `authority`, and `additional`.\nThis is a generic type, and each derived type inherits the following properties:\n\n * `name` -- The name of the resource\n * `type` -- The numerical representation of the resource record type\n * `class` -- The numerical representation of the class of service (usually 1 for internet)\n * `ttl` -- The Time To Live for the record, in seconds\n\nAvailable Types:\n\n * `SOA`\n  - `primary` -- string\n  - `admin` -- string\n  - `serial` -- number\n  - `refresh` -- number\n  - `retry` -- number\n  - `expiration` -- number\n  - `minimum` -- number\n * `A` and `AAAA`\n  - `address` -- string\n * `MX`\n  - `priority` -- number\n  - `exchange` -- string\n * `TXT`\n  - `data` -- string\n * `SRV`\n  - `priority` -- number\n  - `weight` -- number\n  - `port` -- number\n  - `target` -- string\n * `NS`\n  - `data` -- string\n * `CNAME`\n  - `data` -- string\n * `PTR`\n  - `data` -- string\n * `NAPTR`\n  - `order` -- number\n  - `preference` -- number\n  - `flags` -- string\n  - `service` -- string\n  - `regexp` -- string\n  - `replacement` -- string\n","publish_time":1356309467341,"_cnpm_publish_time":1356309467341,"dist-tags":{"latest":"0.7.0"}}