From 5f048f34863b50672bc3a3b25b344116abe3cdec Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 1 Feb 2017 18:46:09 -0700 Subject: [PATCH] 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. --- dns.type.mx.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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;