dns-suite.js/dns.type.mx.js

27 lines
832 B
JavaScript
Raw Normal View History

2017-01-27 02:18:46 +00:00
(function (exports) {
'use strict';
// Value: Preference
// Meaning/Use: Unsigned 16-bit integer
//-------------------------------------
// Value: Mail Exchanger
// Meaning/Use: The name host name that provides the service.
// May be a label, pointer or any combination
// ab is arrayBuffer, packet is Object, Record is Object
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
exports.DNS_TYPE_MX = function (ab, packet, record) {
2017-01-27 02:18:46 +00:00
2017-02-02 04:41:33 +00:00
var rdataAb = ab.slice(record.rdstart, record.rdstart + record.rdlength);
var dv = new DataView(rdataAb);
2017-02-02 04:41:33 +00:00
return {
priority: dv.getUint16(0, false)
, exchange: unpackLabels(new Uint8Array(ab), record.rdstart+2, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
};
2017-01-27 02:18:46 +00:00
};
}('undefined' !== typeof window ? window : exports));