Merge branch 'master' of git.daplie.com:Daplie/dns-lint

This commit is contained in:
dwes7 2017-02-01 22:11:42 -07:00
commit 1d513519b7
5 changed files with 62 additions and 29 deletions

17
browser.js Normal file
View File

@ -0,0 +1,17 @@
;(function () {
'use strict';
var dnsjs = window.DNSPacket;
// I got the test data by running this in the node console:
// JSON.stringify(fs.readFileSync('./test/fixtures/www.google.com.a.bin', null))
var arr = [
191,164,129,128,0,1,0,5,0,0,0,0,3,119,119,119,6,103,111,111,103,108,101,3,99
,111,109,0,0,1,0,1,192,12,0,1,0,1,0,0,0,29,0,4,74,125,239,112,192,12,0,1,0,1,0
,0,0,29,0,4,74,125,239,116,192,12,0,1,0,1,0,0,0,29,0,4,74,125,239,113,192,12,0
,1,0,1,0,0,0,29,0,4,74,125,239,115,192,12,0,1,0,1,0,0,0,29,0,4,74,125,239,114
];
var ab = Uint8Array.from(arr).buffer;
var result = dnsjs.parse(ab);
console.log(result);
}());

View File

@ -1,7 +1,30 @@
<!--
This demo is meant to have 3 feilds that accept base-64, hex and array values the user
can copy in, and a button that will call the dns parser to parse the input and display
the output in a seperate field.
<!DOCTYPE html>
<html>
<body>
<!--
-->
This demo is meant to have 3 feilds that accept base-64, hex and array values the user
can copy in, and a button that will call the dns parser to parse the input and display
the output in a seperate field.
-->
<!-- run `serve-https` to test at https://localhost.daplie.me:8443/demo.html -->
<!-- put form here -->
<!-- I added some of the library files for you -->
<script src="./dns.types.js"></script>
<script src="./dns.classes.js"></script>
<script src="./dns.type.a.js"></script>
<script src="./dns.rdata.parse.js"></script>
<script src="./dns.unpack-labels.js"></script>
<script src="./dns.parser.js"></script>
<script src="./dns.packer.js"></script>
<script src="./dns.js"></script>
<!-- put jquery here -->
<!-- application code in here -->
<script src="./browser.js"></script>
</body>
</html>

View File

@ -1,7 +1,7 @@
(function (exports) {
'use strict';
var pdns = module.exports.DNS_PACK = function () {
var pdns = exports.DNS_PACK = function () {
};

View File

@ -1,7 +1,7 @@
;(function (exports) {
'use strict';
var pdns = module.exports.DNS_PARSER = {};
var pdns = exports.DNS_PARSER = {};
var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
@ -72,14 +72,14 @@ pdns.unpack = function (ab) {
function unpackQuestion(ab, dv, ui8, total) {
var ototal = total;
var q = pdns._unpackLabels(ui8, total, {
name: ''
, type: 0
, typeName: ''
, class: 0
, className: ''
, byteLength: 0
, labels: []
, cpcount: 0
name: '' // ex: daplie.com
, type: 0 // ex: 1
, typeName: '' // ex: A
, class: 0 // ex: 1
, className: '' // ex: IN
, byteLength: 0 // the total byte length (including pointers, but not their labels)
, labels: [] // an array of the labels individually
, cpcount: 0 // the number of compression pointers traversed
});
//console.log('unpackQuestion QNAME:');
//console.log(q);

View File

@ -12,20 +12,13 @@
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
exports.DNS_TYPE_MX = function (ab, packet, record) {
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
var dv = new DataView(rdataAb);
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength)
var dv = new DataView(rdataAb);
var s = {
priority: dv.getUint16(0, false)
, exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
};
return s;
return {
priority: dv.getUint16(0, false)
, exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
};
};