more linting
This commit is contained in:
		
							parent
							
								
									b6f0cff7b8
								
							
						
					
					
						commit
						b4f0cdee78
					
				| @ -16,6 +16,10 @@ var dnspack = exports.DNS_PACKER = { | ||||
|     var header = dnspack.packHeader(packet.header); // 2 bytes
 | ||||
|     total = 12;                                     // 2+2+2+2 bytes ({qd,an,ns,ar}count)
 | ||||
| 
 | ||||
|     if (!id) { | ||||
|       throw new Error("'id' should be set to a crypto random id"); | ||||
|     } | ||||
| 
 | ||||
|     dv.setUint16(0, id, false); | ||||
|     dv.setUint16(2, header, false); | ||||
|     dv.setUint16(4, packet.question.length, false); | ||||
| @ -135,17 +139,25 @@ var dnspack = exports.DNS_PACKER = { | ||||
| 
 | ||||
| , packHeader: function(h) { | ||||
|     var val = 0; | ||||
|     var req = h.opcode; | ||||
|     var res = h.qr || h.aa || h.ra || h.rcode; | ||||
| 
 | ||||
|     val += (h.qr     << 15) & 0x8000; | ||||
|     val += (h.opcode << 11) & 0x7800; | ||||
|     val += (h.aa     << 10) &  0x400; | ||||
|     val += (h.tc     <<  9) &  0x200; | ||||
|     val += (h.rd     <<  8) &  0x100; | ||||
|     val += (h.ra     <<  7) &   0x80; | ||||
|     val += (h.res1   <<  6) &   0x40; | ||||
|     val += (h.res2   <<  5) &   0x20; | ||||
|     val += (h.res3   <<  4) &   0x10; | ||||
|     val += h.rcode          &    0xF; | ||||
|     if (req && res) { | ||||
|       throw new Error("Both request-only and response-only headers are set: " + JSON.stringify(h)); | ||||
|     } | ||||
| 
 | ||||
|     // TODO check if is request or response
 | ||||
| 
 | ||||
|     val += ((h.qr || 0)     << 15) & 0x8000; | ||||
|     val += ((h.opcode || 0) << 11) & 0x7800; | ||||
|     val += ((h.aa || 0)     << 10) &  0x400; | ||||
|     val += ((h.tc || 0)     <<  9) &  0x200; | ||||
|     val += ((h.rd || 0)     <<  8) &  0x100; | ||||
|     val += ((h.ra || 0)     <<  7) &   0x80; | ||||
|     val += ((h.res1 || 0)   <<  6) &   0x40; | ||||
|     val += ((h.res2 || 0)   <<  5) &   0x20; | ||||
|     val += ((h.res3 || 0)   <<  4) &   0x10; | ||||
|     val += (h.rcode || 0)          &    0xF; | ||||
| 
 | ||||
|     return val; | ||||
|   } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user