diff --git a/README.md b/README.md index 1a34ef2..9474dde 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Similar API to `dns.js` and `native-dns-packet`. ```json { "header": { - "id": 54231 + "id": 5423 , "qr": 0 , "opcode": 0 , "aa": 0 @@ -133,15 +133,15 @@ How to add a new parser Each RR (aka Resource Record or RData) parser is individual. Examples include: -* A (`dns.type.a.js`) -* AAAA (`dns.type.aaaa.js`) -* CNAME (`dns.type.cname.js`) -* TXT (`dns.type.txt.js`) -* SRV (`dns.type.srv.js`) +* A (`parser/type.a.js`) +* AAAA (`parser/type.aaaa.js`) +* CNAME (`parser/type.cname.js`) +* TXT (`parser/type.txt.js`) +* SRV (`parser/type.srv.js`) Let's say that To create a parser for a type which we don't currently support, just add the appropriate information to `dns.types.js` and create a file for -the name of the type in the format `dns.type..js`. +the name of the type in the format `parser/type..js`. For example, if `CNAME` wasn't already supported and I wanted to add support for it I would follow these steps: @@ -172,14 +172,14 @@ like and should place that in `test/fixtures/...json` node bin/capture-query.js --name www.google.com --type CNAME ``` -3) Create `dns.type.cname.js` +3) Create `parser/type.cname.js` -Copy `dns.type.TEMPLATE.js` to the type for which you wish to create support -(`dns.type.cname.js` in this example) and fill in the blanks. +Copy `parser/type.TEMPLATE.js` to the type for which you wish to create support +(`parser/type.cname.js` in this example) and fill in the blanks. ``` var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS; -exports.DNS_TYPE_CNAME = function (ab, packet, record) { +exports.DNS_PARSER_TYPE_CNAME = function (ab, packet, record) { // record = { rdstart, rdlength, type, class } // example of not parsing and just leaving as binary data record.data = new Uint8Array(ab.slice(record.rdstart, record.rdstart + record.rdlength)); @@ -208,9 +208,12 @@ At the very least someone can follow a few links you followed and your thought p ├── doc | └── cname.txt ├── dns.classes.js (not necessarily, but potentially) -├── dns.type.cname.js ├── dns.types.js ├── package.json (bump the minor version) +├── packer +| └── type.cname.js +├── parser +| └── type.cname.js └── test └── fixtures    ├── www.google.com.cname.bin diff --git a/demo.html b/demo.html index 264d7d9..0e17117 100644 --- a/demo.html +++ b/demo.html @@ -32,18 +32,23 @@ JSON (Uint8Array):

--> - - + + - + + + + + + diff --git a/parser/type.TEMPLATE.js b/parser/type.TEMPLATE.js index 97502a5..c4bf6a0 100644 --- a/parser/type.TEMPLATE.js +++ b/parser/type.TEMPLATE.js @@ -2,8 +2,8 @@ 'use strict'; // Put some documentation here in these comments. -// See examples of documentation in dns.type.a.js -// and dns.type.mx.js +// See examples of documentation in parser/type.a.js +// and parser/type.mx.js // If the data type you're wanting to unpack contains labels // (meaning text that will be represented as a period-separated