Rapid spam filtering system https://rspamd.com/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.6 KiB

  1. -- This directory is used to define user specific rules and plugins for Rspamd in Lua
  2. -- Each *.lua file is executed and added to the Rspamd
  3. -- Example of regexp rule:
  4. local reconf = config['regexp'] -- Create alias for regexp configs
  5. local re1 = 'From=/foo@/H' -- Mind local here
  6. local re2 = '/blah/P'
  7. reconf['SYMBOL'] = {
  8. re = string.format('(%s) && !(%s)', re1, re2), -- use string.format to create expression
  9. score = 1.2,
  10. description = 'some description',
  11. condition = function(task)
  12. -- run this rule only if some condition is satisfied
  13. return true
  14. end,
  15. }
  16. -- Example of a simple lua rule:
  17. rspamd_config.SYMBOL = {
  18. callback = function(task)
  19. return true
  20. end,
  21. score = 1.2,
  22. description = 'some description',
  23. condition = function(task)
  24. -- run this rule only if some condition is satisfied
  25. return true
  26. end,
  27. }
  28. -- Example of a plugin with configuration:
  29. local redis_params
  30. local lua_redis = require "lua_redis"
  31. local function symbol_cb(task)
  32. local function redis_set_cb(err)
  33. if err ~= nil then
  34. rspamd_logger.errx(task, 'redis_set_cb received error: %1', err)
  35. end
  36. end
  37. -- Create hash of message-id and store to redis
  38. local key = make_key(task)
  39. local ret = lua_redis.redis_make_request(task,
  40. redis_params, -- connect params
  41. key, -- hash key
  42. true, -- is write
  43. redis_set_cb, --callback
  44. 'SETEX', -- command
  45. { key, tostring(settings['expire']), "1" } -- arguments
  46. )
  47. end
  48. -- Load redis server for module named 'module'
  49. redis_params = lua_redis.parse_redis_server('module')
  50. if redis_params then
  51. -- Register symbol
  52. end