From 36008090800a70b1dc5fdca5758e210c9c518ae3 Mon Sep 17 00:00:00 2001 From: Daplie Date: Wed, 1 Feb 2017 18:41:33 -0700 Subject: [PATCH] almost --- dns.type.mx.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/dns.type.mx.js b/dns.type.mx.js index d98771e..13a05cd 100644 --- a/dns.type.mx.js +++ b/dns.type.mx.js @@ -20,8 +20,8 @@ exports.DNS_TYPE_MX = function (ab, packet, record) { var data = ''; var s = { - priority: '' - , exchange: '' + priority: '' // also known as preference + , exchange: '' // }; var temp = '' @@ -48,13 +48,22 @@ exports.DNS_TYPE_MX = function (ab, packet, record) { data = dv.getUint8(i, false); temp = String.fromCharCode(data); 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._-]+$/); + + // if temp is null, do nothing if (temp === null){ + + // otherwise, append to s.exchange }else{ 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;