73 lines
3.3 KiB
JavaScript
73 lines
3.3 KiB
JavaScript
(function (exports) {
|
|
'use strict';
|
|
|
|
// TODO. Not yet implemented. Do we need to include the name server and email address record properties???
|
|
|
|
// Value Meaning/Use
|
|
// Primary NS Variable length. The name of the Primary Master for the domain. May be a label, pointer, or any combination
|
|
// Admin MB Variable length. The administrator's mailbox. May be a label, pointer, or any combination
|
|
// Serial Number Unsigned 32-bit integer
|
|
// Refresh Interval Unsigned 32-bit integer
|
|
// Retry Interval Unsigned 32-bit integer
|
|
// Expiration Limit Unsigned 32-bit integer
|
|
// Minimum TTL Unsigned 32-bit integer
|
|
|
|
var unpackLabels = exports.DNS_UNPACK_LABELS || require('../dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
|
|
|
exports.DNS_PARSER_TYPE_SOA = function (ab, packet, record) {
|
|
|
|
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
|
|
var dv = new DataView(rdataAb);
|
|
var cpcount = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).cpcount;
|
|
var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength;
|
|
var labels = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).labels;
|
|
console.log("offset is: " + offset);
|
|
console.log("cpcount is: " + cpcount);
|
|
console.log("the labels are : " + labels);
|
|
console.log("rdstart is: " + record.rdstart);
|
|
for(var i = 0; i < dv.byteLength;i++){
|
|
|
|
console.log(parseInt(dv.getUint8(i), 10).toString(16));
|
|
}
|
|
|
|
// Primary NS
|
|
record.name_server = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
|
|
// var offset = unpackLabels(new Uint8Array(ab), record.rdstart, { byteLength: 0, cpcount: 0, labels: [], name: '' }).byteLength;
|
|
// Admin MB. This email address is always preceeded by 6 Bytes of the name_server data and email_addr length.
|
|
// ie: ns1.example.com, where ns1 is 3 bytes, example.com represented by 2 bytes (c0 0c - compression pointer) and then
|
|
// 1 more byte representing the email_addr length.
|
|
// TODO: email_addr probably shouldn't be parsed this way. The email_addr length byte is probably there to parse this in a more robust way
|
|
// we just have to figure that out
|
|
|
|
|
|
if (cpcount > 0){
|
|
// do something awesome with compression pointers to get the email address
|
|
|
|
console.log("name server length is: " + record.name_server.length);
|
|
var email_len = parseInt(dv.getUint8(0), 10) + ;dv.getUint16(0)
|
|
console.log("email_start is: " + email_len);
|
|
record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart , { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
|
|
|
|
}
|
|
else {
|
|
|
|
record.email_addr = unpackLabels(new Uint8Array(ab), record.rdstart + offset, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
|
|
}
|
|
// Serial Number
|
|
record.sn = dv.getUint32(dv.byteLength - 20, false);
|
|
// Refresh Interval
|
|
record.ref = dv.getUint32(dv.byteLength - 16, false);
|
|
// Retry Interval
|
|
record.ret = dv.getUint32(dv.byteLength - 12, false);
|
|
// Expiration Limit
|
|
record.ex = dv.getUint32(dv.byteLength - 8, false);
|
|
// Minimum TTL
|
|
record.nx = dv.getUint32(dv.byteLength - 4, false);
|
|
|
|
|
|
return record;
|
|
|
|
};
|
|
|
|
}('undefined' !== typeof window ? window : exports));
|