|
|
@ -8,7 +8,7 @@ export default {get_qname, get_response, preread_doh_request, preread_dns_reques |
|
|
|
* 2: As 1, but also parse answers. We can log the answers, and also cache responses in HTTP Content-Cache |
|
|
|
* 2: As 1, but also parse answers. We can log the answers, and also cache responses in HTTP Content-Cache |
|
|
|
* 3: Very Verbose, log everything as above, but also write packet data to error log (slowest) |
|
|
|
* 3: Very Verbose, log everything as above, but also write packet data to error log (slowest) |
|
|
|
**/ |
|
|
|
**/ |
|
|
|
var dns_decode_level = 2; |
|
|
|
var dns_decode_level = 3; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* DNS Question Load Balancing |
|
|
|
* DNS Question Load Balancing |
|
|
@ -47,18 +47,17 @@ function process_doh_request(s, decode, scrub) { |
|
|
|
if ( data.length == 0 ) { |
|
|
|
if ( data.length == 0 ) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
data.split("\r\n").forEach( function(line) { |
|
|
|
const lines = data.split("\r\n"); |
|
|
|
var bytes; |
|
|
|
var bytes; |
|
|
|
var packet; |
|
|
|
var packet; |
|
|
|
|
|
|
|
if(lines[0].startsWith("GET")) { |
|
|
|
if ( line.toString('hex').startsWith( '0000') ) { |
|
|
|
var line = lines[0]; |
|
|
|
bytes = line; |
|
|
|
var path = line.split(" ")[1] |
|
|
|
} else if ( line.toString().startsWith("GET /dns-query?") ) { |
|
|
|
var params = path.split("?")[1] |
|
|
|
var qs = line.slice("GET /dns-query?".length, line.length - " HTTP/1.1".length) |
|
|
|
var qs = params.split("&"); |
|
|
|
qs = qs.split("&"); |
|
|
|
|
|
|
|
debug(s, "process_doh_request: QS Params: " + qs ); |
|
|
|
debug(s, "process_doh_request: QS Params: " + qs ); |
|
|
|
qs.some( param => { |
|
|
|
qs.some( param => { |
|
|
|
if ( param.startsWith("dns=") ) { |
|
|
|
if (param.startsWith("dns=") ) { |
|
|
|
bytes = String.bytesFrom(param.slice(4), "base64url"); |
|
|
|
bytes = String.bytesFrom(param.slice(4), "base64url"); |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
@ -66,6 +65,17 @@ function process_doh_request(s, decode, scrub) { |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(lines[0].startsWith("POST")) { |
|
|
|
|
|
|
|
const index = lines.findIndex(line=>{ |
|
|
|
|
|
|
|
if(line.length == 0) { |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
if(index>0 && lines.length >= index + 1){ |
|
|
|
|
|
|
|
bytes = lines[index + 1]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (bytes) { |
|
|
|
if (bytes) { |
|
|
|
debug(s, "process_doh_request: DNS Req: " + bytes.toString('hex') ); |
|
|
|
debug(s, "process_doh_request: DNS Req: " + bytes.toString('hex') ); |
|
|
|
if (decode) { |
|
|
|
if (decode) { |
|
|
@ -90,7 +100,6 @@ function process_doh_request(s, decode, scrub) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function process_dns_request(s, decode, scrub) { |
|
|
|
function process_dns_request(s, decode, scrub) { |
|
|
|