diff --git a/dns.type.aaaa.js b/dns.type.aaaa.js index bc328a0..8db0337 100644 --- a/dns.type.aaaa.js +++ b/dns.type.aaaa.js @@ -4,28 +4,36 @@ // Value: IP Address // Meaning:Use: 16 octets represting the IP address +exports.DNS_TYPE_AAAA = function (ab, packet, record) { + var ui8 = record.rdata; + console.log("ByteLength: " + ui8.byteLength); + console.log("normal length: " + ui8.length); + var s = ''; + var z = 0; -exports.DNS_TYPE_AAAA = function (rdata) { - console.log('*****************************************'); - - // // var rrTokens = rdata.trim().split(/\s+/g); - // // var len = rrTokens.length; - // // var result = { - // // name: rrTokens[0], - // // ip: rrTokens[len-1] - // // }; - - - // // if(!isNaN(rrTokens[1])) result.ttl = parseInt(rrTokens[1], 10); - // // return result; - // console.log(rdata.length.toString()); - - // var ui8 = new Uint8Array(rdata); - - + for (var i = 0; i < ui8.length; i += 1) { + console.log(ui8[i].toString(16)); + + if (i%2 === 1 && ui8[i].toString(16).length < 2) { + s = s + '0' + ui8[i].toString(16); + } else { + s = s + ui8[i].toString(16); + if (ui8[i].toString(16) === '0' && i%2 === 0){ + s = s.substring(0, s.length-1); + } + } + if (i%2 === 1) { + s = s + ":" + } + if (i === 15) { + s = s.substring(0, s.length-1); + } + } + console.log(s); + return s; }; }('undefined' !== typeof window ? window : exports));