cleanup
This commit is contained in:
parent
f3a3c477a5
commit
607296c8bb
40
README.md
40
README.md
|
@ -17,10 +17,36 @@ Details error checking makes it great for
|
|||
|
||||
Similar API to `dns.js` and `native-dns-packet`.
|
||||
|
||||
```json
|
||||
{ "id": 54231
|
||||
, "qr": 0
|
||||
, "opcode": 0
|
||||
, "aa": 0
|
||||
, "tc": 0
|
||||
, "rd": 1
|
||||
, "ra": 0
|
||||
, "res1": 0
|
||||
, "res2": 0
|
||||
, "res3": 0
|
||||
, "rcode": 0
|
||||
, "questions": [
|
||||
{ "name": "bowie._sftp-ssh._tcp.local"
|
||||
, "type": 1
|
||||
, "class": 1
|
||||
, "byteLength": 32
|
||||
}
|
||||
]
|
||||
, "answers": []
|
||||
, "authority": []
|
||||
, "additional": []
|
||||
, "byteLength": 44
|
||||
}
|
||||
```
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
```
|
||||
```bash
|
||||
npm install git+https://git@git.daplie.com:Daplie/dns-lint
|
||||
```
|
||||
|
||||
|
@ -31,26 +57,26 @@ Usage
|
|||
|
||||
You can work directly from `node_modules/dns-lint`:
|
||||
|
||||
```
|
||||
```bash
|
||||
pushd node_modules/dns-lint/
|
||||
```
|
||||
|
||||
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
|
||||
|
||||
```
|
||||
```bash
|
||||
# example
|
||||
# node bin/dns-parse.js </path/to/packet.dns.bin>
|
||||
node bin/dns-parse.js samples/a-0.mdns.bin
|
||||
|
@ -63,7 +89,7 @@ node bin/dns-parse.js samples/a-0.mdns.bin
|
|||
* `packet.answers[0].data = dnsjs.unpackRdatas(arrayBuffer, packet, packet.answers[0])`
|
||||
|
||||
node.js:
|
||||
```
|
||||
```js
|
||||
var nodeBuffer = fs.readFileSync('./samples/a-0.mdns.bin');
|
||||
var arrayBuffer = nodeBuffer.buffer;
|
||||
|
||||
|
@ -74,7 +100,7 @@ console.log(packet);
|
|||
```
|
||||
|
||||
Browser:
|
||||
```
|
||||
```js
|
||||
var arrayBuffer = new Uint8Array.from([ /* bytes */ ]).buffer;
|
||||
|
||||
var packet = pdns.unpack(arrayBuffer);
|
||||
|
|
|
@ -14,7 +14,7 @@ if (!filename) {
|
|||
|
||||
var PromiseA = require('bluebird');
|
||||
var fs = PromiseA.promisifyAll(require('fs'));
|
||||
var pdns = require('./pure-parser');
|
||||
var pdns = require('../');
|
||||
|
||||
fs.readFileAsync(filename, null).then(function (nb) {
|
||||
//
|
||||
|
@ -48,5 +48,5 @@ fs.readFileAsync(filename, null).then(function (nb) {
|
|||
packet.additional.forEach(tryParseRdata);
|
||||
|
||||
console.log('[packet]', nb.byteLength, 'bytes:');
|
||||
console.log(packet);
|
||||
console.log(JSON.stringify(packet, null, 2));
|
||||
});
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "dns-testing",
|
||||
"version": "1.0.0",
|
||||
"description": "testing dns",
|
||||
"main": "dns_test.js",
|
||||
"main": "pure-parser.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
|
|
|
@ -128,7 +128,7 @@ pdns.unpack = function (ab) {
|
|||
total += 2;
|
||||
q.class = dv.getUint16(total);
|
||||
total += 2;
|
||||
q.qtotal = total - ototal;
|
||||
q.byteLength = total - ototal;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ pdns.unpack = function (ab) {
|
|||
total += q.rdlength;
|
||||
console.log('total', total);
|
||||
|
||||
q.qtotal = total - ototal;
|
||||
q.byteLength = total - ototal;
|
||||
return q;
|
||||
}
|
||||
|
||||
|
@ -177,7 +177,7 @@ pdns.unpack = function (ab) {
|
|||
header.questions = [];
|
||||
for (i = 0; i < qdcount; i += 1) {
|
||||
rec = unpackQuestion(ab, dv, total);
|
||||
total += rec.qtotal;
|
||||
total += rec.byteLength;
|
||||
header.questions.push(rec);
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ pdns.unpack = function (ab) {
|
|||
header.answers = [];
|
||||
for (i = 0; i < ancount; i += 1) {
|
||||
rec = unpackAnswer(ab, dv, total);
|
||||
total += rec.qtotal;
|
||||
total += rec.byteLength;
|
||||
header.answers.push(rec);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ pdns.unpack = function (ab) {
|
|||
header.authority = [];
|
||||
for (i = 0; i < nscount; i += 1) {
|
||||
rec = unpackAnswer(ab, dv, total);
|
||||
total += rec.qtotal;
|
||||
total += rec.byteLength;
|
||||
header.authority.push(rec);
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ pdns.unpack = function (ab) {
|
|||
header.additional = [];
|
||||
for (i = 0; i < arcount; i += 1) {
|
||||
rec = unpackAnswer(ab, dv, total);
|
||||
total += rec.qtotal;
|
||||
total += rec.byteLength;
|
||||
header.additional.push(rec);
|
||||
}
|
||||
|
||||
|
@ -210,7 +210,7 @@ pdns.unpack = function (ab) {
|
|||
"Parsed " + total + " bytes, but packet is " + ab.byteLength + " bytes."
|
||||
);
|
||||
}
|
||||
header.total = total;
|
||||
header.byteLength = total;
|
||||
return header;
|
||||
};
|
||||
pdns.unpackRdata = require('./dns.rdata.parse.js').DNS_RDATA_PARSE;
|
||||
|
|
Loading…
Reference in New Issue