Updated from `js_include` to `js_import` in nginx which has been deprecated

master
Meliurwen 3 years ago
parent 97bfcb47cd
commit 7f9d43c5ce
Signed by: meliurwen
GPG Key ID: 818A8B35E9F1CE10
  1. 4
      nginx/root/etc/nginx/nginx.template
  2. 27
      nginx/root/etc/nginx/njs.d/dns/dns.js

@ -99,7 +99,7 @@ stream {
access_log /var/log/nginx/dns-access.log dns;
# Include the NJS module
js_include /etc/nginx/njs.d/nginx_stream.js;
js_import /etc/nginx/njs.d/dns/dns.js;
# The $dns_qname variable can be populated by preread calls, and can be used for DNS routing
js_set $dns_qname dns_get_qname;
@ -129,7 +129,7 @@ stream {
# DNS over HTTPS (gateway) Service
server {
listen 127.0.0.1:8053;
js_filter dns_filter_doh_request;
js_filter dns.filter_doh_request;
proxy_pass dns;
}

@ -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
* 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
@ -47,15 +47,14 @@ function process_doh_request(s, decode, scrub) {
if ( data.length == 0 ) {
return;
}
data.split("\r\n").forEach( function(line) {
const lines = data.split("\r\n");
var bytes;
var packet;
if ( line.toString('hex').startsWith( '0000') ) {
bytes = line;
} else if ( line.toString().startsWith("GET /dns-query?") ) {
var qs = line.slice("GET /dns-query?".length, line.length - " HTTP/1.1".length)
qs = qs.split("&");
if(lines[0].startsWith("GET")) {
var line = lines[0];
var path = line.split(" ")[1]
var params = path.split("?")[1]
var qs = params.split("&");
debug(s, "process_doh_request: QS Params: " + qs );
qs.some( param => {
if (param.startsWith("dns=") ) {
@ -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) {
debug(s, "process_doh_request: DNS Req: " + bytes.toString('hex') );
if (decode) {
@ -90,7 +100,6 @@ function process_doh_request(s, decode, scrub) {
}
}
});
});
}
function process_dns_request(s, decode, scrub) {

Loading…
Cancel
Save