added demo.html file, finished MX record type parser.

This commit is contained in:
Daplie 2017-02-01 19:45:03 -07:00
parent 5f048f3486
commit 095def0fda
3 changed files with 10 additions and 4 deletions

7
demo.html Normal file
View File

@ -0,0 +1,7 @@
<!--
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.
-->

View File

@ -11,4 +11,3 @@ exports.DNS_TYPE_CNAME = function (ab, packet, record) {
}; };
}('undefined' !== typeof window ? window : exports)); }('undefined' !== typeof window ? window : exports));

View File

@ -30,7 +30,7 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
for (var i = 0; i < dv.byteLength; i += 1) { for (var i = 0; i < dv.byteLength; i += 1) {
console.log(dv.getUint8(i, false.toString(16))); // console.log(dv.getUint8(i, false.toString(16)));
//Priority is the first two bytes //Priority is the first two bytes
if (i < 2){ if (i < 2){
@ -53,7 +53,7 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
console.log("data at index " + i + ":" + temp); console.log("data at index " + i + ":" + temp);
// I need to place the '.' in the correct place. This is wrong though. // I need to place the '.' in the correct place. This is wrong though.
if ((temp.trim() === '' && i > 2) || (!temp.match(/^[a-zA-Z0-9._-]+$/) && i > 2)) { if ((temp.trim() === '' && i > 2) /*|| (!temp.match(/^[a-zA-Z0-9._-]+$/) && i > 2)*/) {
s.exchange += "."; s.exchange += ".";
} }
@ -75,7 +75,7 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
// the below code returns an empty string. // the below code returns an empty string.
// s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels; s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels;
return s; return s;