]> source.dussan.org Git - rspamd.git/commitdiff
* Fix statistics of messages in controller
authorcebka@lenovo-laptop <cebka@lenovo-laptop>
Wed, 17 Mar 2010 14:24:35 +0000 (17:24 +0300)
committercebka@lenovo-laptop <cebka@lenovo-laptop>
Wed, 17 Mar 2010 14:24:35 +0000 (17:24 +0300)
* Fix building and installing perl target
* Fix learn command name
* Controller's commands are now case insensitive
* Statfiles can now be selected from popup list in cgi interface
* Password for controller's commands can now be specified in cgi interface

CMakeLists.txt
cgi/rspamd.cgi
perl/lib/Mail/Rspamd/Client.pm
src/controller.c
src/message.c
src/protocol.c

index dc6158b087f10f03919341f48f21b63715e3a9de..37630d51efbe50727297dd8fb02fadabc065e525 100644 (file)
@@ -485,7 +485,7 @@ ADD_CUSTOM_COMMAND(OUTPUT src/modules.c
 
 IF(PERL_EXECUTABLE)
        ADD_CUSTOM_COMMAND(OUTPUT perl/Makefile 
-                                               PRE_BUILD
+                                               DEPENDS perl/Makefile.PL
                                                COMMAND ${PERL_EXECUTABLE} ./Makefile.PL
                                                WORKING_DIRECTORY perl)
        CONFIGURE_FILE(perl/Makefile.PL.in perl/Makefile.PL)
@@ -655,8 +655,6 @@ ENDIF(ENABLE_LUA MATCHES "ON")
 
 # Perl lib
 IF(PERL_EXECUTABLE)
-       INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${PERL_EXECUTABLE} ./Makefile.PL WORKING_DIRECTORY perl)")
-       INSTALL(CODE "EXECUTE_PROCESS(COMMAND make WORKING_DIRECTORY perl)")
        INSTALL(CODE "EXECUTE_PROCESS(COMMAND make install WORKING_DIRECTORY perl)")
 ENDIF(PERL_EXECUTABLE)
 
index 386bf39afa5d5f1adfffc55fca69aef3ebfe1661..2c5f9113af7b76f7120a0efb794ae2ad6c58fdfd 100644 (file)
@@ -17,6 +17,8 @@ use Data::Dumper;
 my %cfg = (
        'hosts'      => ['localhost:11333'],
        'timeout'       => 1,
+       'password'      => '',
+       'statfiles' => ['WINNOW_HAM', 'WINNOW_SPAM'],
 );
 
 sub new {
@@ -128,7 +130,7 @@ sub _show_html {
                             ),
          br,
          "<label for=\"id_statfile\">Statfile:</label>",
-         textfield(-name=>'statfile', -id=>'id_statfile'),
+         popup_menu(-name=>'statfile', -id=>'id_statfile', -values=>$cfg{'statfiles'}),
          br,
          "<label for=\"id_file\">File:</label>",
          filefield(-name=>'upload_file', -id=>'id_file'),
@@ -291,7 +293,7 @@ sub _handle_form {
        if (!@servers || scalar(@servers) == 0) {
                @servers = @{ $cfg{'hosts'} };
        }
-       my $rspamd = Mail::Rspamd::Client->new({hosts => \@servers, timeout=>$cfg{timeout}});
+       my $rspamd = Mail::Rspamd::Client->new({hosts => \@servers, timeout=>$cfg{timeout}, password=>$cfg{password}});
        my $cmd = $cgi->param('command');
        if (!$cmd) {
                return undef;
index 100bfad681bc316798ea93508b6d9f186cf9070d..d5b630118a45ee65febd3ee511db9605803646dd 100644 (file)
@@ -394,7 +394,7 @@ This method makes a call to the spamd learning a statfile with message.
 sub learn {
        my ($self, $msg) = @_;
        
-       $self->{command} = 'LEARN';
+       $self->{command} = 'learn';
        $self->{control} = 1;
 
        return $self->do_all_cmd ($msg);
index 69b5608e76f38cc39f7aa43f3be83d9d8fe263f1..4133aad1274b23c58e490aa439db7bc50f921edf 100644 (file)
@@ -982,6 +982,7 @@ start_controller (struct rspamd_worker *worker)
        }
        comp = g_completion_new (completion_func);
        g_completion_add_items (comp, comp_list);
+       g_completion_set_compare (comp, g_ascii_strncasecmp);
        /* Fill hostname buf */
        hostmax = sysconf (_SC_HOST_NAME_MAX) + 1;
        hostbuf = alloca (hostmax);
index 225125bcc77087f8de3c28126febec90a955b1df..08f1bf5f17bbdfdaa36cbee7b5dfb81bb03def55 100644 (file)
@@ -824,10 +824,6 @@ process_message (struct worker_task *task)
 #endif
        }
 
-       if (task->worker) {
-               task->worker->srv->stat->messages_scanned++;
-       }
-
        return 0;
 }
 
index 1209f37546d53b7aa0d9f10b0cb7de5d79cdc5c7..8da0f174dab606b99d99afe7ae45193863d03d77 100644 (file)
@@ -721,6 +721,7 @@ write_check_reply (struct worker_task *task)
        msg_info ("%s", logbuf);
        rspamd_dispatcher_write (task->dispatcher, CRLF, sizeof (CRLF) - 1, FALSE, TRUE);
 
+       task->worker->srv->stat->messages_scanned++;
        if (default_score >= default_required_score) {
                task->worker->srv->stat->messages_spam ++;
        }
@@ -785,6 +786,7 @@ write_process_reply (struct worker_task *task)
        rspamd_dispatcher_write (task->dispatcher, outbuf, r, TRUE, FALSE);
        rspamd_dispatcher_write (task->dispatcher, outmsg, strlen (outmsg), FALSE, TRUE);
 
+       task->worker->srv->stat->messages_scanned++;
        if (default_score >= default_required_score) {
                task->worker->srv->stat->messages_spam ++;
        }