diff --git a/rootfs/etc/knot-resolver/knot-aliases-alt.conf b/rootfs/etc/knot-resolver/knot-aliases-alt.conf index 9015241..4c66ba4 100644 --- a/rootfs/etc/knot-resolver/knot-aliases-alt.conf +++ b/rootfs/etc/knot-resolver/knot-aliases-alt.conf @@ -1,4 +1,4 @@ -- Dummy file. Filled by antizapret script. blocked_hosts = {} -regex_blocked = '^$' -regex_allowed = '^$' \ No newline at end of file +regex_blocked = '' +regex_allowed = '' \ No newline at end of file diff --git a/rootfs/etc/knot-resolver/kresd.conf b/rootfs/etc/knot-resolver/kresd.conf index a880ef1..c22f1df 100644 --- a/rootfs/etc/knot-resolver/kresd.conf +++ b/rootfs/etc/knot-resolver/kresd.conf @@ -48,32 +48,30 @@ local adguard = os.getenv('ADGUARD') -- if not dns then dns = '127.0.0.11' end -- if not dns_ru then dns = '77.88.8.8' end -policy.add( - function (_, query) - if (regex_allowed == '' or regex_allowed == nil) and (regex_blocked == '' or regex_blocked == nil) then - return nil - end +if (regex_allowed ~= '' or regex_blocked ~= '') then + policy.add( + function (_, query) + local command = string.format( + '/etc/knot-resolver/regex.sh "%s" "%s" "%s"', + kres.dname2str(query.sname), + regex_allowed, + regex_blocked + ) + local handle = io.popen(command) + local result = handle:read("*line") + handle:close() - local command = string.format( - '/etc/knot-resolver/regex.sh "%s" "%s" "%s"', - kres.dname2str(query.sname), - regex_allowed, - regex_blocked - ) - local handle = io.popen(command) - local result = handle:read("*line") - handle:close() - - if result == 'blocked' then - return policy.STUB({'127.0.0.4'}) - elseif result == 'allowed' then - return policy.FORWARD({dns}) - end + if result == 'blocked' then + return policy.STUB({'127.0.0.4'}) + elseif result == 'allowed' then + return policy.FORWARD({dns}) + end - -- filter did not match, continue with next filter - return nil - end -) + -- filter did not match, continue with next filter + return nil + end + ) +end -- Forward blocked domains to dnsmap policy.add(