fix file scope var packet bug
This commit is contained in:
parent
bd433a8ddf
commit
6ecb2882dc
|
@ -7,7 +7,6 @@ var classes = exports.DNS_CLASSES || require('./dns.classes.js').DNS_CLASSES;
|
|||
var types = exports.DNS_TYPES || require('./dns.types.js').DNS_TYPES;
|
||||
|
||||
// Order http://www.zytrax.com/books/dns/ch15/
|
||||
var packet = {};
|
||||
pdns.unpackHeader = function (i) {
|
||||
// i is one element from a Uint16Array (as a 16-bit unsigned integer)
|
||||
|
||||
|
@ -32,7 +31,7 @@ pdns.unpackHeader = function (i) {
|
|||
|
||||
pdns._unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||
|
||||
pdns.unpackOpt = function (ab, rec) {
|
||||
pdns.unpackOpt = function (ab, packet, rec) {
|
||||
var dv;
|
||||
|
||||
// https://tools.ietf.org/html/rfc6891#section-6
|
||||
|
@ -94,6 +93,7 @@ pdns.unpack = function (ab) {
|
|||
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DataView
|
||||
var dv = new DataView(ab);
|
||||
var id = dv.getUint16(0, false);
|
||||
var packet = {};
|
||||
packet.header = pdns.unpackHeader(dv.getUint16(2, false));
|
||||
packet.qdcount = dv.getUint16(4, false); // query count
|
||||
packet.ancount = dv.getUint16(6, false); // answer count
|
||||
|
@ -238,7 +238,7 @@ pdns.unpack = function (ab) {
|
|||
total += rec.byteLength;
|
||||
if (0x29 === rec.type) {
|
||||
// OPT 41 (0x29)
|
||||
pdns.unpackOpt(ab, rec);
|
||||
pdns.unpackOpt(ab, packet, rec);
|
||||
continue;
|
||||
}
|
||||
packet.additional.push(rec);
|
||||
|
|
Loading…
Reference in New Issue