still working on it

This commit is contained in:
Daplie 2017-03-09 19:34:27 -07:00
parent 16dd91ace0
commit 12cb2887fa
8 changed files with 90 additions and 232 deletions

View File

@ -2,7 +2,27 @@
'use strict';
exports.DNS_PACKER_TYPE_SOA = function (ab, dv, total, record) {
if(!record.sn){
throw new Error("no serial number for SOA record");
}
if(!record.ref){
throw new Error("no serial number for SOA record");
}
if(!record.ret){
throw new Error("no serial number for SOA record");
}
if(!record.ex){
throw new Error("no serial number for SOA record");
}
if(!record.nx){
throw new Error("no serial number for SOA record");
}
return total;
};

38
packer/type.txt.js Normal file
View File

@ -0,0 +1,38 @@
(function (exports) {
'use strict';
// Record type is just any text.
exports.DNS_PACKER_TYPE_TXT = function (ab, dv, total, record) {
// if (!record.data){
// throw new Error("no data for TXT record");
// }
// console.log("record data is: " + record.data);
// var txtLen = 0;
// var rdLenIndex = total;
// total += 2;
// //RDATA
// // a sequence of labels
// record.data.split('.').forEach(function (label) {
// txtLen += 1 + label.length;
// dv.setUint8(total, label.length, false);
// total += 1;
// label.split('').forEach(function (ch) {
// dv.setUint8(total, ch.charCodeAt(0), false);
// total += 1;
// });
// });
// // RDLENGTH
// dv.setUint16(rdLenIndex, record.data.length + 1, false);
// return total;
};
}('undefined' !== typeof window ? window : exports));

View File

@ -1,7 +1,7 @@
(function (exports) {
'use strict';
// TODO. Not yet implemented
// 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
@ -12,11 +12,33 @@
// 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 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;
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
//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);
// Refresh Interval

Binary file not shown.

View File

@ -1,203 +0,0 @@
{
"header": {
"id": 23924,
"qr": 1,
"opcode": 0,
"aa": 0,
"tc": 0,
"rd": 1,
"ra": 1,
"res1": 0,
"res2": 0,
"res3": 0,
"rcode": 0
},
"qdcount": 1,
"ancount": 1,
"nscount": 4,
"arcount": 4,
"question": [
{
"name": "google.com",
"type": 6,
"typeName": "SOA",
"class": 1,
"className": "IN",
"byteLength": 16,
"labels": [
"google",
"com"
],
"cpcount": 0
}
],
"answer": [
{
"name": "google.com",
"type": 6,
"typeName": "SOA",
"class": 1,
"className": "IN",
"byteLength": 50,
"labels": [
"google",
"com"
],
"cpcount": 1,
"rdstart": 40,
"rdlength": 38,
"ttl": 60,
"sn": 149208434,
"ref": 900,
"ret": 900,
"ex": 1800,
"nx": 60
}
],
"authority": [
{
"name": "google.com",
"type": 2,
"typeName": "NS",
"class": 1,
"className": "IN",
"byteLength": 18,
"labels": [
"google",
"com"
],
"cpcount": 1,
"rdstart": 90,
"rdlength": 6,
"ttl": 57847,
"data": "ns2.google.com"
},
{
"name": "google.com",
"type": 2,
"typeName": "NS",
"class": 1,
"className": "IN",
"byteLength": 14,
"labels": [
"google",
"com"
],
"cpcount": 1,
"rdstart": 108,
"rdlength": 2,
"ttl": 57847,
"data": "ns4.google.com"
},
{
"name": "google.com",
"type": 2,
"typeName": "NS",
"class": 1,
"className": "IN",
"byteLength": 18,
"labels": [
"google",
"com"
],
"cpcount": 1,
"rdstart": 122,
"rdlength": 6,
"ttl": 57847,
"data": "ns1.google.com"
},
{
"name": "google.com",
"type": 2,
"typeName": "NS",
"class": 1,
"className": "IN",
"byteLength": 18,
"labels": [
"google",
"com"
],
"cpcount": 1,
"rdstart": 140,
"rdlength": 6,
"ttl": 57847,
"data": "ns3.google.com"
}
],
"edns_options": [],
"additional": [
{
"name": "ns1.google.com",
"type": 1,
"typeName": "A",
"class": 1,
"className": "IN",
"byteLength": 16,
"labels": [
"ns1",
"google",
"com"
],
"cpcount": 2,
"rdstart": 158,
"rdlength": 4,
"ttl": 57850,
"address": "216.239.32.10"
},
{
"name": "ns2.google.com",
"type": 1,
"typeName": "A",
"class": 1,
"className": "IN",
"byteLength": 16,
"labels": [
"ns2",
"google",
"com"
],
"cpcount": 2,
"rdstart": 174,
"rdlength": 4,
"ttl": 57839,
"address": "216.239.34.10"
},
{
"name": "ns3.google.com",
"type": 1,
"typeName": "A",
"class": 1,
"className": "IN",
"byteLength": 16,
"labels": [
"ns3",
"google",
"com"
],
"cpcount": 2,
"rdstart": 190,
"rdlength": 4,
"ttl": 57861,
"address": "216.239.36.10"
},
{
"name": "ns4.google.com",
"type": 1,
"typeName": "A",
"class": 1,
"className": "IN",
"byteLength": 16,
"labels": [
"ns4",
"google",
"com"
],
"cpcount": 2,
"rdstart": 206,
"rdlength": 4,
"ttl": 57850,
"address": "216.239.38.10"
}
],
"byteLength": 210
}

View File

@ -1,19 +0,0 @@
{
"header": {
"id": 23924,
"qr": 0,
"opcode": 0,
"aa": 0,
"tc": 0,
"rd": 1,
"ra": 0,
"rcode": 0
},
"question": [
{
"name": "google.com",
"typeName": "SOA",
"className": "IN"
}
]
}