From 267342c82c4a7cfa9b9f967e3260feb9daac0d4e Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sat, 21 Jan 2017 14:39:26 -0700 Subject: [PATCH] add A record parser --- dns.rdata.parse.js | 2 +- dns.type.a.js | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 dns.type.a.js diff --git a/dns.rdata.parse.js b/dns.rdata.parse.js index 894c808..d360974 100644 --- a/dns.rdata.parse.js +++ b/dns.rdata.parse.js @@ -27,7 +27,7 @@ exports.DNS_RDATA_PARSE = function (ab, packet, record) { try { parser = exports['DNS_TYPE_' + record.typeName] - || require('./dns.type.' + record.typeName.toLowerCase()); + || require('./dns.type.' + record.typeName.toLowerCase())['DNS_TYPE_' + record.typeName]; } catch (e) { /*console.error(e)*/ } diff --git a/dns.type.a.js b/dns.type.a.js new file mode 100644 index 0000000..906af75 --- /dev/null +++ b/dns.type.a.js @@ -0,0 +1,11 @@ +(function (exports) { +'use strict'; + +exports.DNS_TYPE_A = function (rdata) { + var ui8 = new Uint8Array(rdata); + + // i.e. 127.0.0.1 + return ui8[0] + '.' + ui8[1] + '.' + ui8[2] + '.' + ui8[3]; +}; + +}('undefined' !== typeof window ? window : exports));