dnsbl - disable checks when IP is local
This commit is contained in:
parent
74fb015366
commit
445032406b
|
@ -1,6 +1,7 @@
|
|||
local M = {}
|
||||
local dns = require "dns"
|
||||
local M = {}
|
||||
local dns = require "dns"
|
||||
local logger = require "logger"
|
||||
local iputils = require "resty.iputils"
|
||||
|
||||
function M.cached_ko ()
|
||||
return ngx.shared.dnsbl_cache:get(ngx.var.remote_addr) == "ko"
|
||||
|
@ -11,6 +12,11 @@ function M.cached ()
|
|||
end
|
||||
|
||||
function M.check (dnsbls, resolvers)
|
||||
local local_ips = iputils.parse_cidrs({"127.0.0.0/8", "172.16.0.0/12", "192.168.0.0/16"})
|
||||
if iputils.ip_in_cidrs(ngx.var.remote_addr, local_ips) then
|
||||
ngx.shared.dnsbl_cache:set(ngx.var.remote_addr, "ok", 86400)
|
||||
return false
|
||||
end
|
||||
local rip = dns.ip_to_arpa()
|
||||
for k, v in ipairs(dnsbls) do
|
||||
local req = rip .. "." .. v
|
||||
|
|
Loading…
Reference in New Issue