diff --git a/dns.type.mx.js b/dns.type.mx.js index 13a05cd..2761cb2 100644 --- a/dns.type.mx.js +++ b/dns.type.mx.js @@ -45,20 +45,24 @@ exports.DNS_TYPE_MX = function (ab, packet, record) { } 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{ @@ -66,16 +70,12 @@ exports.DNS_TYPE_MX = function (ab, packet, record) { } - - - } - - - } - // s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; + // the below code returns an empty string. + + // s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels; return s;