left some comments to explain code and my error. Code is kind of confusing for outside readers, but you can kind of see what I'm trying to do.

This commit is contained in:
Daplie 2017-02-01 18:46:09 -07:00
parent 3600809080
commit 5f048f3486
1 changed files with 8 additions and 8 deletions

View File

@ -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) {
}
}
}
// the below code returns an empty string.
}
// s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
// s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels;
return s;