Merge branch 'master' of git.daplie.com:Daplie/dns-lint
This commit is contained in:
commit
1d513519b7
|
@ -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);
|
||||||
|
|
||||||
|
}());
|
31
demo.html
31
demo.html
|
@ -1,7 +1,30 @@
|
||||||
<!--
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<!--
|
||||||
|
|
||||||
This demo is meant to have 3 feilds that accept base-64, hex and array values the user
|
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
|
can copy in, and a button that will call the dns parser to parse the input and display
|
||||||
the output in a seperate field.
|
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>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
(function (exports) {
|
(function (exports) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var pdns = module.exports.DNS_PACK = function () {
|
var pdns = exports.DNS_PACK = function () {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
;(function (exports) {
|
;(function (exports) {
|
||||||
'use strict';
|
'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 classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
|
||||||
var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
|
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) {
|
function unpackQuestion(ab, dv, ui8, total) {
|
||||||
var ototal = total;
|
var ototal = total;
|
||||||
var q = pdns._unpackLabels(ui8, total, {
|
var q = pdns._unpackLabels(ui8, total, {
|
||||||
name: ''
|
name: '' // ex: daplie.com
|
||||||
, type: 0
|
, type: 0 // ex: 1
|
||||||
, typeName: ''
|
, typeName: '' // ex: A
|
||||||
, class: 0
|
, class: 0 // ex: 1
|
||||||
, className: ''
|
, className: '' // ex: IN
|
||||||
, byteLength: 0
|
, byteLength: 0 // the total byte length (including pointers, but not their labels)
|
||||||
, labels: []
|
, labels: [] // an array of the labels individually
|
||||||
, cpcount: 0
|
, cpcount: 0 // the number of compression pointers traversed
|
||||||
});
|
});
|
||||||
//console.log('unpackQuestion QNAME:');
|
//console.log('unpackQuestion QNAME:');
|
||||||
//console.log(q);
|
//console.log(q);
|
||||||
|
|
|
@ -12,21 +12,14 @@
|
||||||
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||||
exports.DNS_TYPE_MX = function (ab, packet, record) {
|
exports.DNS_TYPE_MX = function (ab, packet, record) {
|
||||||
|
|
||||||
|
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
|
||||||
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength)
|
|
||||||
var dv = new DataView(rdataAb);
|
var dv = new DataView(rdataAb);
|
||||||
|
|
||||||
var s = {
|
return {
|
||||||
priority: dv.getUint16(0, false)
|
priority: dv.getUint16(0, false)
|
||||||
, exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
|
, exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return s;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}('undefined' !== typeof window ? window : exports));
|
}('undefined' !== typeof window ? window : exports));
|
||||||
|
|
Loading…
Reference in New Issue