Fix small bugs
authorheiko
Wed, 01 Jun 2016 00:41:52 +0200
changeset 59 8088c95fac5d
parent 58 27440e1334b7
child 60 bb36de81da32
Fix small bugs
bin/exigrey
exim.conf.ex
lib/Exim/Grey.pm
--- a/bin/exigrey	Tue May 31 23:20:08 2016 +0200
+++ b/bin/exigrey	Wed Jun 01 00:41:52 2016 +0200
@@ -28,6 +28,7 @@
 use constant ME => basename $0;
 use FindBin qw/$Bin/;
 use POSIX qw/strftime mktime/;
+use if $ENV{DEBUG} => 'Smart::Comments';
 
 use Exim::Grey qw(:all);
 
@@ -178,13 +179,13 @@
 
 	connectDB(\my %h, $db);
 	if (not exists $h{$key}) {
-	    warn "$0: not found\n";
+	    warn "$0: key `$key' not found\n";
 	}
 	else {
-	    $_ = $h{$key};
-	    s/\0$/\n/;
-	    delete $h{$key};
-	    print;
+	    $_ = $h{$key};	# delete from tied hashes
+	    delete $h{$key};	# doesn't return anything always
+	    chop;
+	    print "$key: $_\n";
 	}
 	exit 0;
     }
@@ -201,6 +202,8 @@
     my ($hash, $sub) = @_;
     while (my ($k, $v) = each %$hash) {
         chop($k, $v);
+### $k
+### $v
         &$sub($k, (split(' ', $v), 0, 0)[ 0 .. 3 ]);    # 0 for filling
     }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/exim.conf.ex	Wed Jun 01 00:41:52 2016 +0200
@@ -0,0 +1,17 @@
+######################################################################
+#                    MAIN CONFIGURATION SETTINGS                     #
+######################################################################
+...
+
+perl_startup = use Exim::Grey qw(unseen);
+GREYLISTED = ${perl{unseen}{<$sender_address>:<$local_part@$domain>/$sender_host_address}{60}}
+
+acl_check_rcpt:
+
+  ...
+
+  defer  
+	 condition      = GREYLISTED
+         condition      = ${if <{$message_size}{1M}}
+	 log_message    = grey listed exigrey
+
--- a/lib/Exim/Grey.pm	Tue May 31 23:20:08 2016 +0200
+++ b/lib/Exim/Grey.pm	Wed Jun 01 00:41:52 2016 +0200
@@ -5,7 +5,7 @@
 use base 'Exporter';
 use Carp;
 
-our @EXPORT_OK = qw(unseen getDBDir getDBs connectDB);
+our @EXPORT_OK = qw(unseen getDBDir connectDB getDefault);
 our %EXPORT_TAGS = (
     all => \@EXPORT_OK,
 );
@@ -75,7 +75,7 @@
         return 'yes';
     }
 
-    my ($created, undef, $count) = split ' ', $h{$key};
+    my ($created, undef, $count) = split /[ \0]/, $h{$key};
 
     # we know the client, but last contact was recently (too fast)
     if ($now - $created < $delay) { 
@@ -117,7 +117,7 @@
 
     return 0 if not exists $h->{$key};
     
-    my ($t0, undef, $cnt, $flag) = split ' ', $h->{$key};
+    my ($t0, undef, $cnt, $flag) = split /[ \0]/, $h->{$key};
     $h->{$key} = join(' ' => $t0, time, ++$cnt, $flag ? $flag : ()) . "\0";
 
     return 1;