/[smecontribs]/rpms/smeserver-geoip/contribs10/smeserver-geoip-1.2-bz10820-geoipv1-blockvountries-qpsmtpd.patch
ViewVC logotype

Contents of /rpms/smeserver-geoip/contribs10/smeserver-geoip-1.2-bz10820-geoipv1-blockvountries-qpsmtpd.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Tue Oct 6 13:45:11 2020 UTC (4 years, 1 month ago) by brianr
Branch: MAIN
CVS Tags: smeserver-geoip-1_2-15_el7_sme, smeserver-geoip-1_2-18_el7_sme, smeserver-geoip-1_2-16_el7_sme, smeserver-geoip-1_2-17_el7_sme, HEAD
Initial import

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

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed