2017-02-16 22:52:07 +00:00
|
|
|
(function (exports) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
// An 'A' record is a 32-bit value representing the IP address
|
|
|
|
|
|
|
|
exports.DNS_PACKER_TYPE_A = function (ab, dv, total, record) {
|
|
|
|
if (!record.address) {
|
|
|
|
throw new Error("no address on A record");
|
|
|
|
}
|
|
|
|
|
2017-02-16 23:29:23 +00:00
|
|
|
// RDLENGTH
|
2017-02-17 22:14:14 +00:00
|
|
|
var IP_LEN = 4;
|
|
|
|
dv.setUint16(total, IP_LEN, false);
|
2017-02-16 23:29:23 +00:00
|
|
|
total += 2;
|
|
|
|
|
|
|
|
// RDATA
|
2017-02-16 22:52:07 +00:00
|
|
|
// i.e. 127.0.0.1 => 0x7F, 0x00, 0x00, 0x01
|
|
|
|
record.address.split('.').forEach(function (octet) {
|
|
|
|
dv.setUint8(total, parseInt(octet, 10), false);
|
|
|
|
total += 1;
|
|
|
|
});
|
|
|
|
|
|
|
|
return total;
|
|
|
|
};
|
|
|
|
|
|
|
|
}('undefined' !== typeof window ? window : exports));
|