diff options
author | cebka@lenovo-laptop <cebka@lenovo-laptop> | 2010-02-08 19:23:53 +0300 |
---|---|---|
committer | cebka@lenovo-laptop <cebka@lenovo-laptop> | 2010-02-08 19:23:53 +0300 |
commit | 341a236aa614d66bd76764e3eb315b6df0688ef5 (patch) | |
tree | 8db27485dbf87bc338cf311d4b6c70070774a618 /rspamc.pl.in | |
parent | 10c8ad2246130d77b19ee7036e3f0a74c47425a1 (diff) | |
download | rspamd-341a236aa614d66bd76764e3eb315b6df0688ef5.tar.gz rspamd-341a236aa614d66bd76764e3eb315b6df0688ef5.zip |
* Add ability to add weight for fuzzy hashes, this can be very useful for autolearning fuzzy storage by users
Diffstat (limited to 'rspamc.pl.in')
-rwxr-xr-x | rspamc.pl.in | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/rspamc.pl.in b/rspamc.pl.in index ad2de90b8..40fad293b 100755 --- a/rspamc.pl.in +++ b/rspamc.pl.in @@ -22,6 +22,7 @@ my %cfg = ( 'control' => 0, 'statfile' => '', 'deliver_to'=> '', + 'weight' => 1, ); $main::VERSION = '@RSPAMD_VERSION@'; @@ -35,7 +36,8 @@ Usage: rspamc.pl [-h host] [-p port] [-P password] [-c conf_file] [-s statfile] -c config file to parse -s statfile to use for learn commands -d define deliver-to header -imap format: imap:user:<username>:password:<password>:host:<hostname>:mbox:<mboxname> +-w define weight for fuzzy operations +imap format: imap:user:<username>:password:[<password>]:host:<hostname>:mbox:<mboxname> Version: @RSPAMD_VERSION@ EOD }; @@ -146,16 +148,19 @@ sub do_rspamc_command { sub do_ctrl_auth { my ($sock) = @_; + my $res = 0; syswrite $sock, "password $cfg{'password'}" . $CRLF; if (defined (my $reply = <$sock>)) { - my $end = <$sock>; if ($reply =~ /^password accepted/) { - return 1; + $res = 1; } } + + # END + return 0 unless <$sock>; - return 0; + return $res; } sub do_control_command { @@ -205,7 +210,7 @@ sub do_control_command { if (do_ctrl_auth ($sock)) { my $len = length ($input); print "Sending $len bytes...\n"; - syswrite $sock, $cfg{'command'} . " $len" . $CRLF; + syswrite $sock, $cfg{'command'} . " $len $cfg{'weight'}" . $CRLF; syswrite $sock, $input . $CRLF; if (defined (my $reply = <$sock>)) { if ($reply =~ /^OK/) { @@ -436,7 +441,7 @@ sub do_cmd { ############################# Main part ########################################### my %args; -getopt('c:h:p:P:s:d:', \%args); +getopt('c:h:p:P:s:d:w:', \%args); my $cmd = shift; my @path = shift; my $do_parse_config = 1; @@ -480,6 +485,9 @@ if (defined ($args{P})) { if (defined ($args{d})) { $cfg{'deliver_to'} = $args{d}; } +if (defined ($args{w})) { + $cfg{'weight'} = $args{w}; +} if ($cmd =~ /(SYMBOLS|SCAN|PROCESS|CHECK|REPORT_IFSPAM|REPORT|URLS|EMAILS)/i) { $cfg{'command'} = $1; |