dns-suite.js/parser/type.srv.js

24 lines
810 B
JavaScript
Raw Normal View History

2017-01-27 02:18:46 +00:00
(function (exports) {
'use strict';
// TODO. Not yet implemented
// SRV identifies the host(s) that will support a particular service. It
// is a general purpose RR to discover any service.
2017-02-02 05:10:21 +00:00
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
2017-01-27 02:18:46 +00:00
2017-02-17 23:13:57 +00:00
exports.DNS_PARSER_TYPE_SRV = function (ab, packet, record) {
2017-01-27 02:18:46 +00:00
2017-02-02 05:10:21 +00:00
var rdataAb = ab.slice(record.rdstart,record.rdstart + record.rdlength)
var dv = new DataView(rdataAb);
record.priority = dv.getUint16(0, false);
record.weight = dv.getUint16(2, false);
record.port = dv.getUint16(4, false);
record.target = unpackLabels(new Uint8Array(ab), record.rdstart+6, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name;
2017-02-17 23:13:57 +00:00
return record;
2017-01-27 02:18:46 +00:00
};
}('undefined' !== typeof window ? window : exports));