forked from mirrors/gecko-dev
		
	These modules are MIT licensed and they're to be used in xpcshell-tests for TRR. They allow us to make moz-http2.js act like a true DoH server - more specifically to answer DNS queries that have actually been asked, not just a dumb character buffer. Differential Revision: https://phabricator.services.mozilla.com/D25672 --HG-- extra : moz-landing-system : lando
		
			
				
	
	
		
			50 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			50 lines
		
	
	
	
		
			1.3 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
'use strict'
 | 
						|
 | 
						|
/*
 | 
						|
 * Traditional DNS header OPCODEs (4-bits) defined by IANA in
 | 
						|
 * https://www.iana.org/assignments/dns-parameters/dns-parameters.xhtml#dns-parameters-5
 | 
						|
 */
 | 
						|
 | 
						|
exports.toString = function (opcode) {
 | 
						|
  switch (opcode) {
 | 
						|
    case 0: return 'QUERY'
 | 
						|
    case 1: return 'IQUERY'
 | 
						|
    case 2: return 'STATUS'
 | 
						|
    case 3: return 'OPCODE_3'
 | 
						|
    case 4: return 'NOTIFY'
 | 
						|
    case 5: return 'UPDATE'
 | 
						|
    case 6: return 'OPCODE_6'
 | 
						|
    case 7: return 'OPCODE_7'
 | 
						|
    case 8: return 'OPCODE_8'
 | 
						|
    case 9: return 'OPCODE_9'
 | 
						|
    case 10: return 'OPCODE_10'
 | 
						|
    case 11: return 'OPCODE_11'
 | 
						|
    case 12: return 'OPCODE_12'
 | 
						|
    case 13: return 'OPCODE_13'
 | 
						|
    case 14: return 'OPCODE_14'
 | 
						|
    case 15: return 'OPCODE_15'
 | 
						|
  }
 | 
						|
  return 'OPCODE_' + opcode
 | 
						|
}
 | 
						|
 | 
						|
exports.toOpcode = function (code) {
 | 
						|
  switch (code.toUpperCase()) {
 | 
						|
    case 'QUERY': return 0
 | 
						|
    case 'IQUERY': return 1
 | 
						|
    case 'STATUS': return 2
 | 
						|
    case 'OPCODE_3': return 3
 | 
						|
    case 'NOTIFY': return 4
 | 
						|
    case 'UPDATE': return 5
 | 
						|
    case 'OPCODE_6': return 6
 | 
						|
    case 'OPCODE_7': return 7
 | 
						|
    case 'OPCODE_8': return 8
 | 
						|
    case 'OPCODE_9': return 9
 | 
						|
    case 'OPCODE_10': return 10
 | 
						|
    case 'OPCODE_11': return 11
 | 
						|
    case 'OPCODE_12': return 12
 | 
						|
    case 'OPCODE_13': return 13
 | 
						|
    case 'OPCODE_14': return 14
 | 
						|
    case 'OPCODE_15': return 15
 | 
						|
  }
 | 
						|
  return 0
 | 
						|
}
 |