Here is a general configuration for POP-B4-SMTP:
change your host_accept_relay to something that includes a file.
host_accept_relay = \
127.0.0.1 : \
A.B.C.0/24 : \
E.F.G.0/23 : \
/path/to/pop_b4_smtp
The format for the pop_b4_smtp file will just have one IP per line as
follows:
65.163.61.43
65.163.61.5
65.163.61.56
65.163.61.95
66.1.184.254
68.104.172.107
So the last step is to generate the pop_b4_smtp file. Currently, my POP3
daemon (which I wrote myself) generates this file for me. However, here is
a Perl script that I wrote several years ago that will do the same thing by
tailing a cucipop log file. You will need to hack it to work for whatever
POP3 daemon you use. Just start the script running in the background when
the system starts.
#!/usr/bin/perl -w
use strict;
use File::Tail;
#pop log
my $poplog = "/var/log/maillog";
#timeout in seconds
my $timeout = 900;
#output file
my $outfile = '/path/to/pop_b4_smtp';
#don't change anything below this
#-------------------------------------------
my $LOCK_SH = 1;
my $LOCK_EX = 2;
my $LOCK_NB = 4;
my $LOCK_UN = 8;
my (%ipList, $line, $ip, $seconds);
my $logfile = File::Tail->new(name => $poplog,
tail => -1);
while(defined($line = $logfile->read)) {
#set the current time
$seconds = time();
if(($line !~ m/failure/) && ($line =~ m|\d+\.\d+\.\d+\.\d+|)) {
($ip) = ($line =~ m|(\d+\.\d+\.\d+\.\d+)|);
$ipList{$ip} = $seconds;
}
#now go through and delete all timed out ip's
foreach $ip (keys(%ipList)) {
if($seconds - $ipList{$ip} > $timeout) {
delete $ipList{$ip};
}
}
#now print the ip's out to the $outfile
open(OUT, ">$outfile");
flock(OUT, $LOCK_EX);
seek(OUT, 0, 0); #just in case
while(($ip) = each(%ipList)) {
print OUT "$ip\n";
}
flock(OUT, $LOCK_UN);
close(OUT);
}