[Rspamd-Users] cannot execute /etc/rspamd/custom-ratelimit.lua: attempt to call a nil value

George Asenov george.asenov at wpx.net
Wed Aug 31 08:38:00 UTC 2022


Hello,

I'm trying to write custom ratelimit script but it keeps failing at 
start with:
###########
lua; ratelimit.lua:852: cannot execute /etc/rspamd/custom-ratelimit.lua: 
attempt to call a nil value
2022-08-31 08:56:57 #128103(main) <j5qrcn>; cfg; 
rspamd_init_lua_filters: init lua module ratelimit from 
/usr/share/rspamd/plugins/ratelimit.lua; digest: 3a60a963ae
############

here is the script:
######################################
local custom_keywords = {}

function mysplit (inputstr, sep)
         if sep == nil then
                 sep = "%s"
         end
         local t={}
         for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
                 table.insert(t, str)
         end
         return t
end

custom_keywords.customrl = function(task)
   local rspamd_logger = require "rspamd_logger"
  mta_ip = task:get_client_ip()
  user = ""
  if task:get_header('X-PHP-Originating-Script') then
   local script_header = task:get_header('X-PHP-Originating-Script')
   local user_tables = mysplit(script_header, ":")
          user = user_tables[1]
         else
         user = task:get_user()
         else
         user = "NA"
         end

  local  bucket = {
                 burst = 30;
                 rate = "15 / 30m";
                 message = "Message rate limit exceeded!! Try again later";
   }
   if not user then
           return  -- no user, return nil
   else
         rspamd_logger.infox(rspamd_config, "User %s on Server %s, 
ratelimit %s", user, tostring(mta_ip) , bucket)
   return "rs_customrl_" .. tostring(mta_ip) .. "_" .. user, bucket
   end


return custom_keywords
###################

Also how can I get [Envelope from] address i.e. the real sender even if 
the user is sending trough sendmail (not authenticated)?




More information about the Users mailing list