From: Vsevolod Stakhov Date: Sun, 23 Apr 2017 09:59:34 +0000 (+0100) Subject: [Minor] Add Lua 5.3 workaround X-Git-Tag: 1.5.7~24 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=67497b9f636e9d61814084d1232345c7ffe2edee;p=rspamd.git [Minor] Add Lua 5.3 workaround --- diff --git a/src/plugins/lua/greylist.lua b/src/plugins/lua/greylist.lua index 37ebf6f02..079ed550d 100644 --- a/src/plugins/lua/greylist.lua +++ b/src/plugins/lua/greylist.lua @@ -40,6 +40,7 @@ greylist { local redis_params local whitelisted_ip local whitelist_domains_map = nil +local toint =math.ifloor or math.floor local settings = { expire = 86400, -- 1 day by default timeout = 300, -- 5 minutes by default @@ -324,18 +325,18 @@ local function greylist_set(task) true, -- is write redis_set_cb, --callback 'EXPIRE', -- command - {body_key, tostring(settings['expire'])} -- arguments + {body_key, tostring(toint(settings['expire']))} -- arguments ) -- Update greylisting record expire if ret then conn:add_cmd('EXPIRE', { - meta_key, tostring(settings['expire']) + meta_key, tostring(toint(settings['expire'])) }) else rspamd_logger.errx(task, 'got error while connecting to redis') end elseif do_greylisting or do_greylisting_required then - local t = tostring(math.floor(rspamd_util.get_time())) + local t = tostring(toint(rspamd_util.get_time())) local end_time = rspamd_util.time_to_string(t + settings['timeout']) rspamd_logger.infox(task, 'greylisted until "%s", new record', end_time) task:insert_result(settings['symbol'], 0.0, 'greylisted', end_time, @@ -350,12 +351,12 @@ local function greylist_set(task) true, -- is write redis_set_cb, --callback 'SETEX', -- command - {body_key, tostring(settings['expire']), t} -- arguments + {body_key, tostring(toint(settings['expire'])), t} -- arguments ) if ret then conn:add_cmd('SETEX', { - meta_key, tostring(settings['expire']), t + meta_key, tostring(toint(settings['expire'])), t }) else rspamd_logger.errx(task, 'got error while connecting to redis')