]> source.dussan.org Git - rspamd.git/commitdiff
* Add option redirector_symbol to surbl module.
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 18 Mar 2011 14:40:15 +0000 (17:40 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 18 Mar 2011 14:40:15 +0000 (17:40 +0300)
src/plugins/surbl.c
src/plugins/surbl.h

index ed7bc28fa3017919dcd93f4bb95cc32a5642b1ae..d3763822c7310fc569613a0ede170e026bb579d0 100644 (file)
@@ -225,6 +225,7 @@ surbl_module_init (struct config_file *cfg, struct module_ctx **ctx)
        register_protocol_command ("urls", urls_command_handler);
        /* Register module options */
        register_module_opt ("surbl", "redirector", MODULE_OPT_TYPE_STRING);
+       register_module_opt ("surbl", "redirector_symbol", MODULE_OPT_TYPE_STRING);
        register_module_opt ("surbl", "url_expire", MODULE_OPT_TYPE_TIME);
        register_module_opt ("surbl", "redirector_connect_timeout", MODULE_OPT_TYPE_TIME);
        register_module_opt ("surbl", "redirector_read_timeout", MODULE_OPT_TYPE_TIME);
@@ -313,6 +314,13 @@ surbl_module_config (struct config_file *cfg)
                surbl_module_ctx->use_redirector = (surbl_module_ctx->redirectors_number != 0);
                g_strfreev (strvec);
        }
+       if ((value = get_module_opt (cfg, "surbl", "redirector_symbol")) != NULL) {
+               surbl_module_ctx->redirector_symbol = memory_pool_strdup (surbl_module_ctx->surbl_pool, value);
+               register_virtual_symbol (&cfg->cache, surbl_module_ctx->redirector_symbol, 1.0);
+       }
+       else {
+               surbl_module_ctx->redirector_symbol = NULL;
+       }
        if ((value = get_module_opt (cfg, "surbl", "weight")) != NULL) {
                surbl_module_ctx->weight = atoi (value);
        }
@@ -998,6 +1006,9 @@ surbl_tree_url_callback (gpointer key, gpointer value, void *data)
                                        re = g_hash_table_lookup (surbl_module_ctx->redirector_hosts, red_domain);
                                        if (re != NULL && (re == NO_REGEXP || g_regex_match (re, url->string, 0, NULL))) {
                                                /* If no regexp found or founded regexp matches url string register redirector's call */
+                                               if (surbl_module_ctx->redirector_symbol != NULL) {
+                                                       insert_result (param->task, surbl_module_ctx->redirector_symbol, 1, g_list_prepend (NULL, red_domain));
+                                               }
                                                register_redirector_call (url, param->task, param->suffix, red_domain);
                                                param->task->save.saved++;
                                                return FALSE;
index 3760f58081f647b275b44cb9b90ad4869a99da6f..21bb98df06f179c5d6b94e26c5285e67683333d1 100644 (file)
@@ -37,6 +37,7 @@ struct surbl_ctx {
        gchar *metric;
        const gchar *tld2_file;
        const gchar *whitelist_file;
+       gchar *redirector_symbol;
        GHashTable **exceptions;
        GHashTable *whitelist;
        GHashTable *redirector_hosts;