commit ba4c9ba: [Minor] Unify settings checks

Vsevolod Stakhov vsevolod at highsecure.ru
Sun Apr 21 17:07:05 UTC 2019


Author: Vsevolod Stakhov
Date: 2019-04-21 16:58:20 +0100
URL: https://github.com/rspamd/rspamd/commit/ba4c9baa69a7ae1285aeadb40d48a1a9832b1ee8

[Minor] Unify settings checks

---
 lualib/lua_dkim_tools.lua        | 10 ++++++++++
 src/plugins/lua/arc.lua          |  8 +-------
 src/plugins/lua/dkim_signing.lua |  9 ++-------
 3 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/lualib/lua_dkim_tools.lua b/lualib/lua_dkim_tools.lua
index 5733cf81a..9e00fdfb1 100644
--- a/lualib/lua_dkim_tools.lua
+++ b/lualib/lua_dkim_tools.lua
@@ -521,4 +521,14 @@ exports.sign_using_redis = function(N, task, settings, selectors, sign_func, err
   end
 end
 
+exports.validate_signing_settings = function(settings)
+  return settings.use_redis or
+      settings.path or
+      settings.domain or
+      settings.path_map or
+      settings.selector_map or
+      settings.use_http_headers or
+      (settings.signing_table and settings.key_table)
+end
+
 return exports
diff --git a/src/plugins/lua/arc.lua b/src/plugins/lua/arc.lua
index d3fe818da..5dfba662c 100644
--- a/src/plugins/lua/arc.lua
+++ b/src/plugins/lua/arc.lua
@@ -637,13 +637,7 @@ for k,v in pairs(opts) do
   end
 end
 
-if not (settings.use_redis or
-    settings.path or
-    settings.domain or
-    settings.path_map or
-    settings.selector_map or
-    settings.use_http_headers or
-    (settings.signing_table and settings.key_table)) then
+if not dkim_sign_tools.validate_signing_settings(settings) then
   rspamd_logger.infox(rspamd_config, 'mandatory parameters missing, disable arc signing')
   return
 end
diff --git a/src/plugins/lua/dkim_signing.lua b/src/plugins/lua/dkim_signing.lua
index d8e1f7519..05a7739e7 100644
--- a/src/plugins/lua/dkim_signing.lua
+++ b/src/plugins/lua/dkim_signing.lua
@@ -138,17 +138,12 @@ for k,v in pairs(opts) do
   end
 end
 
-if not (settings.use_redis or
-    settings.path or
-    settings.domain or
-    settings.path_map or
-    settings.selector_map or
-    settings.use_http_headers or
-    (settings.signing_table and settings.key_table)) then
+if not dkim_sign_tools.validate_signing_settings(settings) then
   rspamd_logger.infox(rspamd_config, 'mandatory parameters missing, disable dkim signing')
   lua_util.disable_module(N, "config")
   return
 end
+
 if settings.use_redis then
   redis_params = lua_redis.parse_redis_server('dkim_signing')
 


More information about the Commits mailing list