added PTR record packer
This commit is contained in:
parent
43360a75da
commit
05beaa480b
|
@ -16,7 +16,6 @@ exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) {
|
|||
|
||||
// RDATA
|
||||
// a sequence of labels
|
||||
|
||||
record.data.split('.').forEach(function(label) {
|
||||
nsLen += 1 + label.length;
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
(function (exports) {
|
||||
'use strict';
|
||||
|
||||
// The host name that represents the supplied UP address
|
||||
// May be a label, pointer or any combination
|
||||
|
||||
exports.DNS_PACKER_TYPE_PTR = function (ab, dv, total, record) {
|
||||
if (!record.data) {
|
||||
throw new Error("no data for PTR record");
|
||||
}
|
||||
|
||||
var ptrLen = 0;
|
||||
var rdLenIndex = total;
|
||||
total += 2;
|
||||
|
||||
// RDATA
|
||||
// a sequence of labels
|
||||
record.data.split('.').forEach(function (label){
|
||||
console.log("the labels are: " + label);
|
||||
ptrLen += 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));
|
Loading…
Reference in New Issue