pushed wrong dns.type.mx.js

This commit is contained in:
dwes7 2017-02-01 20:48:41 -07:00
parent 88e6779641
commit bb87a2ea63
1 changed files with 2 additions and 53 deletions

View File

@ -17,65 +17,14 @@ 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 data = '';
var s = { var s = {
priority: '' // also known as preference priority: dv.getUint16(0, false)
, exchange: '' // , exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
}; };
var temp = ''
var stuff = '';
console.log("dataview length: " + dv.byteLength);
for (var i = 0; i < dv.byteLength; i += 1) {
// console.log(dv.getUint8(i, false.toString(16)));
//Priority is the first two bytes
if (i < 2){
s.priority += dv.getUint8(i, false).toString(10);
// take off an padded zeros
if (s.priority.substr(0, 1) === '0') {
s.priority = s.priority.slice(1, s.priority.length);
}
} else {
// get data from uint8 array
data = dv.getUint8(i, false);
// get the string from the data
temp = String.fromCharCode(data);
console.log("data at index " + i + ":" + temp);
// 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)*/) {
s.exchange += ".";
}
// filter out everything that isn't a valid character
temp = temp.match(/^[a-zA-Z0-9._-]+$/);
// if temp is null, do nothing
if (temp === null){
// otherwise, append to s.exchange
}else{
s.exchange += temp;
}
}
}
// the below code returns an empty string.
s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels;
return s; return s;