aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/lua/asn.lua
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-27 17:14:43 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2016-12-27 17:14:43 +0000
commitc356b89f8c1679b57b701a64eaefab171fb8f735 (patch)
tree1727e7e9aa7cf60b02bc19044d2368b4540e5715 /src/plugins/lua/asn.lua
parent0d4c60d3ca58175284d9236851c66f840cdac705 (diff)
downloadrspamd-c356b89f8c1679b57b701a64eaefab171fb8f735.tar.gz
rspamd-c356b89f8c1679b57b701a64eaefab171fb8f735.zip
[Minor] Disable redis cache for ASN module
Diffstat (limited to 'src/plugins/lua/asn.lua')
-rw-r--r--src/plugins/lua/asn.lua79
1 files changed, 1 insertions, 78 deletions
diff --git a/src/plugins/lua/asn.lua b/src/plugins/lua/asn.lua
index 512f59a56..32f3871a7 100644
--- a/src/plugins/lua/asn.lua
+++ b/src/plugins/lua/asn.lua
@@ -28,7 +28,6 @@ local options = {
expire = 86400, -- 1 day by default
key_prefix = 'rasn',
}
-local redis_params
local rspamd_re = rspamd_regexp.create_cached("[\\|\\s]")
@@ -63,32 +62,6 @@ local function asn_check(task)
local parts = rspamd_re:split(results[1])
-- "15169 | 8.8.8.0/24 | US | arin |" for 8.8.8.8
asn_set(parts[1], parts[2], parts[3])
-
- if redis_params then
- local redis_key = options.key_prefix .. ip:to_string()
- local ret,conn,upstream
- local function redis_asn_set_cb(redis_err)
- if redis_err then
- rspamd_logger.errx(task, 'got error %s when setting asn record on server %s',
- redis_err, upstream:get_addr())
- end
- end
- ret,conn,upstream = rspamd_redis_make_request(task,
- redis_params, -- connect params
- redis_key, -- hash key
- true, -- is write
- redis_asn_set_cb, --callback
- 'HMSET', -- command
- {redis_key, "asn", parts[1], "net", parts[2], "country", parts[3]} -- arguments
- )
- if ret then
- conn:add_cmd('EXPIRE', {
- redis_key, tostring(options['expire'])
- })
- else
- rspamd_logger.errx(task, 'got error while connecting to redis')
- end
- end
end
local dnsbl = options['provider_info']['ip' .. ip:get_version()]
local req_name = rspamd_logger.slog("%1.%2",
@@ -97,58 +70,9 @@ local function asn_check(task)
req_name, rspamd_dns_cb)
end
- local function asn_check_cache(ip, continuation_func)
- local key = options.key_prefix .. ip:to_string()
-
- local function redis_asn_get_cb(err, data)
- if err or not data or type(data[1]) ~= 'string' then
- continuation_func(ip)
- else
- asn_set(data[1], data[2], data[3])
- -- Refresh key
- local function redis_asn_expire_cb(redis_err)
- if redis_err then
- rspamd_logger.errx(task, 'Error setting expire: %s',
- redis_err)
- end
- end
-
- local ret = rspamd_redis_make_request(task,
- redis_params, -- connect params
- key, -- hash key
- true, -- is write
- redis_asn_expire_cb, --callback
- 'EXPIRE', -- command
- {key, tostring(options.expire)} -- arguments
- )
- if not ret then
- rspamd_logger.errx(task, 'got error connecting to redis')
- end
- end
- end
-
- local ret = rspamd_redis_make_request(task,
- redis_params, -- connect params
- key, -- hash key
- false, -- is write
- redis_asn_get_cb, --callback
- 'HMGET', -- command
- {key, "asn", "net", "country"} -- arguments
- )
-
- if not ret then
- continuation_func(ip)
- end
- end
-
local ip = task:get_from_ip()
if not (ip and ip:is_valid()) then return end
-
- if not redis_params then
- asn_check_func[options['provider_type']](ip)
- else
- asn_check_cache(ip, asn_check_func[options['provider_type']])
- end
+ asn_check_func[options['provider_type']](ip)
end
-- Configuration options
@@ -169,7 +93,6 @@ local configure_asn_module = function()
rspamd_logger.errx("Unknown provider_type: %s", options['provider_type'])
return false
end
- redis_params = rspamd_parse_redis_server('asn')
return true
end