This commit is contained in:
Daplie 2017-02-01 18:41:33 -07:00
parent faddeb3b88
commit 3600809080
1 changed files with 12 additions and 3 deletions

View File

@ -20,8 +20,8 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
var data = ''; var data = '';
var s = { var s = {
priority: '' priority: '' // also known as preference
, exchange: '' , exchange: '' //
}; };
var temp = '' var temp = ''
@ -48,13 +48,22 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
data = dv.getUint8(i, false); data = dv.getUint8(i, false);
temp = String.fromCharCode(data); temp = String.fromCharCode(data);
console.log("data at index " + i + ":" + temp); console.log("data at index " + i + ":" + temp);
if ((temp.trim() === '' && i > 2) || (!temp.match(/^[a-zA-Z0-9._-]+$/) && i > 2)) {
s.exchange += ".";
}
temp = temp.match(/^[a-zA-Z0-9._-]+$/); temp = temp.match(/^[a-zA-Z0-9._-]+$/);
// if temp is null, do nothing
if (temp === null){ if (temp === null){
// otherwise, append to s.exchange
}else{ }else{
s.exchange += temp; s.exchange += temp;
} }
@ -66,7 +75,7 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
} }
// s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels; // s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
return s; return s;