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.

这个提交包含在:
Daplie 2017-02-01 18:46:09 -07:00
父节点 3600809080
当前提交 5f048f3486

查看文件

@ -45,20 +45,24 @@ exports.DNS_TYPE_MX = function (ab, packet, record) {
} else { } else {
// get data from uint8 array
data = dv.getUint8(i, false); data = dv.getUint8(i, false);
// get the string from the data
temp = String.fromCharCode(data); temp = String.fromCharCode(data);
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.
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 += ".";
} }
// filter out everything that isn't a valid character
temp = temp.match(/^[a-zA-Z0-9._-]+$/); temp = temp.match(/^[a-zA-Z0-9._-]+$/);
// if temp is null, do nothing // if temp is null, do nothing
if (temp === null){ if (temp === null){
// otherwise, append to s.exchange // otherwise, append to s.exchange
}else{ }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: '' }).labels;
}
// s.exchange = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
return s; return s;