Comparing version 1.0.2 to 1.0.3
@@ -11,3 +11,7 @@ ;(function (exports) { | ||
// backwards compat with node buffer | ||
var ab = nb.buffer || nb; | ||
var ab = nb; | ||
if (nb.buffer) { | ||
// TODO pass byteOffsets to unpacker | ||
ab = nb.buffer.slice(nb.byteOffset, nb.byteOffset + nb.byteLength); | ||
} | ||
var packet = Parser.unpack(ab); | ||
@@ -14,0 +18,0 @@ |
{ | ||
"name": "dns-suite", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "testing dns", | ||
@@ -5,0 +5,0 @@ "main": "dns.js", |
@@ -80,2 +80,5 @@ dns-suite | ||
* CLI | ||
* API | ||
**CLI** | ||
@@ -89,15 +92,2 @@ | ||
Capture mDNS broadcast packets | ||
```bash | ||
# example | ||
# node bin/mdns-capture.js <file-prefix> | ||
node bin/mdns-capture.js mdns-test | ||
``` | ||
```bash | ||
# in another terminal | ||
dig @224.0.0.251 -p 5353 -t PTR _services._dns-sd._udp.local | ||
``` | ||
Parsing a saved packet | ||
@@ -117,5 +107,5 @@ | ||
* `packet = dnsjs.unpack(arrayBuffer)` | ||
* `packet = dnsjs.unpackRdatas(arrayBuffer, packet)` | ||
* `packet.answers[0].data = dnsjs.unpackRdatas(arrayBuffer, packet, packet.answers[0])` | ||
* `DNSPacket.parse(nodeOrArrayBuffer)` returns json (as shown above) | ||
* `DNSPacket.pack(packet)` returns ArrayBuffer (browser and node) | ||
* `DNSPacket.write(packet)` returns NodeBuffer (node only) | ||
@@ -127,6 +117,8 @@ node.js: | ||
var dnsjs = require('dns-suite'); | ||
var packet = dnsjs.unpack(arrayBuffer); | ||
var DNSPacket = require('dns-suite').DNSPacket; | ||
var packet = DNSPacket.parse(arrayBuffer); | ||
var ab = DNSPacket.pack(packet); | ||
console.log(packet); | ||
console.log(new Uint8Array(ab)); | ||
``` | ||
@@ -138,7 +130,26 @@ | ||
var packet = pdns.unpack(arrayBuffer); | ||
var packet = DNSPacket.parse(arrayBuffer); | ||
var ab = DNSPacket.pack(packet); | ||
console.log(packet); | ||
console.log(new Uint8Array(ab)); | ||
``` | ||
Capturing Packets | ||
----- | ||
We have a command line tool for that! See [dig.js](https://git.daplie.com/Daplie/dig.js). | ||
``` | ||
# Install | ||
npm install -g 'git+https://git@git.daplie.com/Daplie/dig.js.git' | ||
# Use with DNS | ||
dig.js A daplie.com --output . | ||
# Use with mDNS | ||
dig.js --mdns PTR _services._dns-sd._udp.local --output . | ||
``` | ||
Contributing and Development | ||
@@ -145,0 +156,0 @@ ============================ |
89560
105
1991
244