From 7dead01aaebfb606884a513687445a8b41ce5678 Mon Sep 17 00:00:00 2001 From: Daplie Date: Thu, 2 Feb 2017 14:10:40 -0700 Subject: [PATCH] txt record passes native dns test. --- dns.type.txt.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 dns.type.txt.js diff --git a/dns.type.txt.js b/dns.type.txt.js new file mode 100644 index 0000000..9732a6c --- /dev/null +++ b/dns.type.txt.js @@ -0,0 +1,30 @@ +(function (exports) { +'use strict'; + +// Used to provide the ability to associate some arbitrary and unformatted text +// with a host or other name, such as a human readable information about a server +// network, data center, and other accounting information. + + + +var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS; + +exports.DNS_TYPE_TXT = function (ab, pack, record) { + + + var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength); + var dv = new DataView(rdataAb); + var s = ''; + var data = ''; + for (var i = 0; i < dv.byteLength; i +=1){ + + s = dv.getUint8(i, false); + data = String.fromCharCode(s); + console.log("data at " + i + " is: " + data); + + } + + + return unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name; +}; +}('undefined' !== typeof window ? window : exports));