]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Allow to specify dkim header type on check
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 May 2017 15:03:22 +0000 (16:03 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Thu, 25 May 2017 15:03:22 +0000 (16:03 +0100)
src/plugins/dkim_check.c

index 8cb5cb6118d761eb7639fbe56a66206acfa1da4e..475b40c7e6776bf4d35818d446bb1a9e512c8197 100644 (file)
@@ -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) {