From 0dad88c186150ce803c4e198ef61bdd804dd5240 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Thu, 25 May 2017 16:03:22 +0100 Subject: [PATCH] [Minor] Allow to specify dkim header type on check --- src/plugins/dkim_check.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/plugins/dkim_check.c b/src/plugins/dkim_check.c index 8cb5cb611..475b40c7e 100644 --- a/src/plugins/dkim_check.c +++ b/src/plugins/dkim_check.c @@ -1443,12 +1443,35 @@ lua_dkim_verify_handler (lua_State *L) rspamd_dkim_key_t *key; gint ret; GError *err = NULL; + const gchar *type_str = NULL; + enum rspamd_dkim_type type = RSPAMD_DKIM_NORMAL; if (task && sig && lua_isfunction (L, 3)) { + if (lua_isstring (L, 4)) { + type_str = lua_tostring (L, 4); + + if (type_str) { + if (strcmp (type_str, "dkim") == 0) { + type = RSPAMD_DKIM_NORMAL; + } + else if (strcmp (type_str, "arc-sign") == 0) { + type = RSPAMD_DKIM_ARC_SIG; + } + else if (strcmp (type_str, "arc-seal") == 0) { + type = RSPAMD_DKIM_ARC_SEAL; + } + else { + lua_settop (L, 0); + return luaL_error (L, "unknown sign type: %s", + type_str); + } + } + } + ctx = rspamd_create_dkim_context (sig, task->task_pool, dkim_module_ctx->time_jitter, - RSPAMD_DKIM_NORMAL, + type, &err); if (ctx == NULL) { -- 2.39.5