]> source.dussan.org Git - rspamd.git/commitdiff
* Add logging urls as it was required by rambler search
authorVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 6 Nov 2009 17:47:07 +0000 (20:47 +0300)
committerVsevolod Stakhov <vsevolod@rambler-co.ru>
Fri, 6 Nov 2009 17:47:07 +0000 (20:47 +0300)
src/cfg_file.h
src/cfg_file.l
src/cfg_file.y
src/protocol.c
src/util.c

index b165e82f263b011d49c4dcc098c5424c9bb3c3df..f2cd97e235aaa91c84c7c3f6c49e8db2e6e4fc72 100644 (file)
@@ -205,6 +205,7 @@ struct config_file {
        char *log_file;                                                                 /**< path to logfile in case of file logging                    */
        int log_fd;                                                                             /**< log descriptor in case of file logging                             */
        FILE *logf;
+       gboolean log_urls;                                                              /**< whether we should log URLs                         */
 
        size_t max_statfile_size;                                               /**< maximum size for statfile                                                  */
 
index 822cab3fae9914a4ff2978ca439ad06cbb1bebef..bc46bbc1f07fb237a4a62395d53d3d9c64609a70 100644 (file)
@@ -88,6 +88,7 @@ log_type                                              return LOG_TYPE;
 console                                                        return LOG_TYPE_CONSOLE;
 syslog                                                 return LOG_TYPE_SYSLOG;
 file                                                   return LOG_TYPE_FILE;
+log_urls                                               return LOG_URLS;
 
 log_level                                              return LOG_LEVEL;
 DEBUG                                                  return LOG_LEVEL_DEBUG;
index 8ac9cb6a526177e79e86b684a6d82001b29a8d38..dbee3a0bde5ff144fda86103c0a6f7b04268523d 100644 (file)
@@ -54,7 +54,7 @@ struct rspamd_view *cur_view = NULL;
 %token  FILTERS FACTORS METRIC NAME CACHE_FILE
 %token  REQUIRED_SCORE REJECT_SCORE FUNCTION FRACT COMPOSITES CONTROL PASSWORD
 %token  LOGGING LOG_TYPE LOG_TYPE_CONSOLE LOG_TYPE_SYSLOG LOG_TYPE_FILE
-%token  LOG_LEVEL LOG_LEVEL_DEBUG LOG_LEVEL_INFO LOG_LEVEL_WARNING LOG_LEVEL_ERROR LOG_FACILITY LOG_FILENAME
+%token  LOG_LEVEL LOG_LEVEL_DEBUG LOG_LEVEL_INFO LOG_LEVEL_WARNING LOG_LEVEL_ERROR LOG_FACILITY LOG_FILENAME LOG_URLS
 %token  STATFILE ALIAS PATTERN WEIGHT STATFILE_POOL_SIZE SIZE TOKENIZER CLASSIFIER
 %token DELIVERY LMTP ENABLED AGENT SECTION LUACODE RAW_MODE PROFILE_FILE COUNT
 %token  VIEW IP FROM SYMBOLS CLIENT_IP
@@ -563,6 +563,7 @@ loggingcmd:
        | logginglevel
        | loggingfacility
        | loggingfile
+       | loggingurls
        ;
 
 loggingtype:
@@ -650,6 +651,13 @@ loggingfile:
        }
        ;
 
+loggingurls:
+       LOG_URLS EQSIGN FLAG {
+               if ($3 != 0) {
+                       cfg->log_urls = TRUE;
+               }
+       }
+       ;
 
 classifier:
     CLASSIFIER OBRACE classifierbody EBRACE {
index 3758de8a2ba4153012b3a96944792bf3dd3b7e83..b89d5767a9258dc8729eb4d7cbb2852e861d5b8c 100644 (file)
@@ -87,6 +87,9 @@
 
 static GList                   *custom_commands = NULL;
 
+/* For default metric, dirty hack, but much faster than hash lookup */
+static double default_score, default_required_score;
+
 static char                    *
 separate_command (f_str_t * in, char c)
 {
@@ -414,6 +417,10 @@ show_url_header (struct worker_task *task)
        cur = task->urls;
        while (cur) {
                url = cur->data;
+        if (task->cfg->log_urls) {
+            /* Write this url to log as well */
+            msg_info ("process_message: url found: <%s>, score: [%.2f / %.2f]", struri (url), default_score, default_required_score);
+        }
                host.begin = url->host;
                host.len = url->hostlen;
                /* Skip long hosts to avoid protocol coollisions */
@@ -530,7 +537,9 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
 
 
        if (metric_name == NULL || metric_value == NULL) {
-               m = g_hash_table_lookup (task->cfg->metrics, "default");
+               m = g_hash_table_lookup (task->cfg->metrics, DEFAULT_METRIC);
+        default_required_score = m->required_score;
+        default_score = 0;
                if (!check_metric_settings (task, m, &ms, &rs)) {
                        ms = m->required_score;
                        rs = m->reject_score;
@@ -559,6 +568,12 @@ show_metric_result (gpointer metric_name, gpointer metric_value, void *user_data
         }
        }
        else {
+        /* XXX: dirty hack */
+        if (strcmp (metric_res->metric->name, DEFAULT_METRIC) == 0) {
+            default_required_score = metric_res->metric->required_score;
+            default_score = metric_res->score;
+        }
+
                if (!check_metric_settings (task, metric_res->metric, &ms, &rs)) {
                        ms = metric_res->metric->required_score;
                        rs = metric_res->metric->reject_score;
index 425aed43915f1c9d38dd9a9cdefb85875d285f25..732d67386359a579e4de71bfc400ca129923d793 100644 (file)
@@ -749,8 +749,6 @@ close_log (struct config_file *cfg)
                                msg_err ("close_log: error syncing log file: %s", strerror (errno));
                        }
                        fclose (cfg->logf);
-                       /* XXX: I think this is not needed */
-                       close (cfg->log_fd);
                }
                break;
        }