1 |
jpp |
1.1 |
diff -Nur smeserver-geoip-1.2.old/root/usr/share/qpsmtpd/plugins/check_badcountries smeserver-geoip-1.2/root/usr/share/qpsmtpd/plugins/check_badcountries |
2 |
|
|
--- smeserver-geoip-1.2.old/root/usr/share/qpsmtpd/plugins/check_badcountries 2019-10-18 18:06:57.720000000 -0400 |
3 |
|
|
+++ smeserver-geoip-1.2/root/usr/share/qpsmtpd/plugins/check_badcountries 2019-10-18 18:11:03.629000000 -0400 |
4 |
|
|
@@ -96,6 +96,8 @@ |
5 |
|
|
|
6 |
|
|
=head1 CHANGES |
7 |
|
|
|
8 |
|
|
+2019-10 - JP Pialasse - reintroduce block country functionality with geoip v1 |
9 |
|
|
+ |
10 |
|
|
2019-01 - John Crisp - modify to work correctly with mailstats |
11 |
|
|
|
12 |
|
|
2019-01 - JP Pialasse - make it compatible with old v1 + improve log level |
13 |
|
|
@@ -306,7 +308,8 @@ |
14 |
|
|
sub geoip_lookup { |
15 |
|
|
my $self = shift; |
16 |
|
|
|
17 |
|
|
- return DECLINED if $self->is_localhost($self->qp->connection->remote_ip); |
18 |
|
|
+ my $ip = $self->qp->connection->remote_ip; |
19 |
|
|
+ return DECLINED if $self->is_localhost($ip); |
20 |
|
|
|
21 |
|
|
# reopen the DB if Geo::IP failed due to DB update |
22 |
|
|
$self->open_geoip_db(); |
23 |
|
|
@@ -343,6 +346,30 @@ |
24 |
|
|
} |
25 |
|
|
$self->log(LOGINFO, join(", ", @msg_parts)); |
26 |
|
|
|
27 |
|
|
+ if ( $self->qp->config("badcountries") ) { |
28 |
|
|
+ my @badcountries = $self->qp->config("badcountries"); |
29 |
|
|
+ |
30 |
|
|
+ my $country = $self->qp->connection->notes('geoip_country'); |
31 |
|
|
+ # Returns DECLINED if there are no countries found above |
32 |
|
|
+ return DECLINED unless $country; |
33 |
|
|
+ |
34 |
|
|
+ $self->log(LOGNOTICE, "GeoIP Country: $country"); |
35 |
|
|
+ |
36 |
|
|
+ for (@badcountries) { |
37 |
|
|
+ my ($pattern, $response) = split /\s+/, $_, 2; |
38 |
|
|
+ #my $whitelisthost = $connection->notes('whitelisthost'); |
39 |
|
|
+ my $whitelisthost = $self->qp->connection->notes('whitelisthost'); |
40 |
|
|
+ if ($whitelisthost) { |
41 |
|
|
+ $self->log(LOGNOTICE, "Country $country Pattern $pattern Whitehost $whitelisthost RemoteIP $ip"); |
42 |
|
|
+ $self->log(LOGNOTICE, "Geoip whitelisthost found $whitelisthost"); |
43 |
|
|
+ return OK; |
44 |
|
|
+ } |
45 |
|
|
+ else { |
46 |
|
|
+ return (DENY, "Country is on Blocked List") if ($country eq $pattern); |
47 |
|
|
+ } |
48 |
|
|
+ } |
49 |
|
|
+ } |
50 |
|
|
+ |
51 |
|
|
return DECLINED; |
52 |
|
|
} |
53 |
|
|
|