SRV parser passes test native-dns test
This commit is contained in:
parent
bb87a2ea63
commit
8c8ddceddc
|
@ -4,10 +4,38 @@
|
||||||
|
|
||||||
// SRV identifies the host(s) that will support a particular service. It
|
// SRV identifies the host(s) that will support a particular service. It
|
||||||
// is a general purpose RR to discover any service.
|
// is a general purpose RR to discover any service.
|
||||||
|
var unpackLabels = exports.DNS_UNPACK_LABELS || require('./dns.unpack-labels.js').DNS_UNPACK_LABELS;
|
||||||
|
|
||||||
|
|
||||||
exports.DNS_TYPE_SRV = function (rdata) {
|
exports.DNS_TYPE_SRV = function (ab, packet, record) {
|
||||||
|
|
||||||
|
var rdataAb = ab.slice(record.rdstart,record.rdstart + record.rdlength)
|
||||||
|
var dv = new DataView(rdataAb);
|
||||||
|
// var string = '';
|
||||||
|
// var data = '';
|
||||||
|
// for (var i = 0; i < dv.byteLength; i+=1){
|
||||||
|
// data = dv.getUint8(i, false);
|
||||||
|
|
||||||
|
// string = String.fromCharCode(data);
|
||||||
|
// console.log("data at index " + i + " is " + string);
|
||||||
|
// }
|
||||||
|
|
||||||
|
console.log("***************************");
|
||||||
|
console.log("printing dataView!!!");
|
||||||
|
for (var i = 0; i < dv.byteLength; i+=1) {
|
||||||
|
|
||||||
|
console.log(dv.getUint8(i, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
var s = {
|
||||||
|
priority: dv.getUint16(0, false)
|
||||||
|
, weight: dv.getUint16(2, false)
|
||||||
|
, port: dv.getUint16(4, false)
|
||||||
|
, target: unpackLabels(new Uint8Array(ab), record.rdstart+6, { byteLength: 0, cpcount: 0, labels: [], name: '' }).name
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return s;
|
||||||
|
|
||||||
};
|
};
|
||||||
}('undefined' !== typeof window ? window : exports));
|
}('undefined' !== typeof window ? window : exports));
|
||||||
|
|
Loading…
Reference in New Issue