2017-10-09 19:19:54 +00:00
|
|
|
// NOTE: this should be EXACTLY the same as NS
|
|
|
|
|
2017-03-09 01:59:33 +00:00
|
|
|
(function (exports) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// The host name that represents the supplied UP address
|
2017-10-09 19:19:54 +00:00
|
|
|
// May be a label, pointer or any combination
|
2017-03-09 01:59:33 +00:00
|
|
|
|
|
|
|
exports.DNS_PACKER_TYPE_PTR = function (ab, dv, total, record) {
|
|
|
|
if (!record.data) {
|
|
|
|
throw new Error("no data for PTR record");
|
|
|
|
}
|
|
|
|
|
2017-10-09 19:19:54 +00:00
|
|
|
// RDLENGTH
|
|
|
|
// leading len and length of string and trailing null (all dots become lengths)
|
|
|
|
dv.setUint16(total, record.data.length + 2, false);
|
2017-03-09 01:59:33 +00:00
|
|
|
total += 2;
|
|
|
|
|
2017-10-09 19:19:54 +00:00
|
|
|
// RDATA
|
2017-03-09 01:59:33 +00:00
|
|
|
// a sequence of labels
|
2017-10-09 19:19:54 +00:00
|
|
|
record.data.split('.').forEach(function (label) {
|
2017-03-09 01:59:33 +00:00
|
|
|
|
|
|
|
dv.setUint8(total, label.length, false);
|
|
|
|
total += 1;
|
|
|
|
|
2017-10-09 19:19:54 +00:00
|
|
|
label.split('').forEach(function (ch) {
|
2017-03-09 01:59:33 +00:00
|
|
|
dv.setUint8(total, ch.charCodeAt(0), false);
|
|
|
|
total += 1;
|
|
|
|
});
|
|
|
|
});
|
2017-10-09 19:19:54 +00:00
|
|
|
dv.setUint8(total, 0x00, false);
|
|
|
|
total += 1;
|
2017-03-09 01:59:33 +00:00
|
|
|
|
|
|
|
return total;
|
|
|
|
};
|
|
|
|
|
|
|
|
}('undefined' !== typeof window ? window : exports));
|