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.

rspamd.lua 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. --[[
  2. Copyright (c) 2022, Vsevolod Stakhov <vsevolod@rspamd.com>
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ]]--
  13. -- This is main lua config file for rspamd
  14. require "global_functions" ()
  15. config['regexp'] = {}
  16. rspamd_maps = {} -- Global maps
  17. local local_conf = rspamd_paths['LOCAL_CONFDIR']
  18. local local_rules = rspamd_paths['RULESDIR']
  19. local rspamd_util = require "rspamd_util"
  20. dofile(local_rules .. '/regexp/headers.lua')
  21. dofile(local_rules .. '/regexp/misc.lua')
  22. dofile(local_rules .. '/regexp/upstream_spam_filters.lua')
  23. dofile(local_rules .. '/regexp/compromised_hosts.lua')
  24. dofile(local_rules .. '/html.lua')
  25. dofile(local_rules .. '/headers_checks.lua')
  26. dofile(local_rules .. '/subject_checks.lua')
  27. dofile(local_rules .. '/misc.lua')
  28. dofile(local_rules .. '/forwarding.lua')
  29. dofile(local_rules .. '/mid.lua')
  30. dofile(local_rules .. '/bitcoin.lua')
  31. dofile(local_rules .. '/bounce.lua')
  32. dofile(local_rules .. '/content.lua')
  33. dofile(local_rules .. '/controller/init.lua')
  34. if rspamd_util.file_exists(local_conf .. '/rspamd.local.lua') then
  35. dofile(local_conf .. '/rspamd.local.lua')
  36. else
  37. -- Legacy lua/rspamd.local.lua
  38. if rspamd_util.file_exists(local_conf .. '/lua/rspamd.local.lua') then
  39. dofile(local_conf .. '/lua/rspamd.local.lua')
  40. end
  41. end
  42. if rspamd_util.file_exists(local_conf .. '/local.d/rspamd.lua') then
  43. dofile(local_conf .. '/local.d/rspamd.lua')
  44. end
  45. local rmaps = rspamd_config:get_all_opt("lua_maps")
  46. if rmaps and type(rmaps) == 'table' then
  47. local rspamd_logger = require "rspamd_logger"
  48. for k,v in pairs(rmaps) do
  49. local status,map_or_err = pcall(rspamd_config:add_map(v))
  50. if not status then
  51. rspamd_logger.errx(rspamd_config, "cannot add map %s: %s", k, map_or_err)
  52. else
  53. rspamd_maps[k] = map_or_err
  54. end
  55. end
  56. end