34 lines
		
	
	
		
			737 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			34 lines
		
	
	
		
			737 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| (function (exports) {
 | |
| 'use strict';
 | |
| 
 | |
| // NS name for the supplied domain. May be label, pointer or any combination
 | |
| 
 | |
| exports.DNS_PACKER_TYPE_NS = function (ab, dv, total, record) {
 | |
|   if (!record.data) {
 | |
|       throw new Error("no data on NS record");
 | |
|   }
 | |
| 
 | |
|   var rdLenIndex = total;
 | |
|   total +=2;
 | |
| 
 | |
|   // RDATA
 | |
|   // a sequence of labels
 | |
|   record.data.split('.').forEach(function (label) {
 | |
| 
 | |
|       dv.setUint8(total, label.length, false);
 | |
|       total += 1;
 | |
| 
 | |
|       label.split('').forEach(function (ch) {
 | |
|           dv.setUint8(total, ch.charCodeAt(0), false);
 | |
|           total += 1;
 | |
|       });
 | |
|   });
 | |
| 
 | |
|   // RDLENGTH
 | |
|   dv.setUint16(rdLenIndex, record.data.length + 1, false);
 | |
| 
 | |
|   return total;
 | |
| };
 | |
| 
 | |
| }('undefined' !== typeof window ? window : exports));
 |