--- policyd-weight 2007-08-02 10:37:31.000000000 +0200 +++ policyd-weight.geoip 2007-08-02 10:45:04.000000000 +0200 @@ -255,6 +255,7 @@ use IO::Select; use Config; use POSIX; +use Geo::IP; # # store signal-name to number conversions for better accessibility @@ -352,6 +353,9 @@ 'abuse.rfc-ignorant.org', 0.1, 0, 'ABUSE_RFCI' ); +## GeoIP settings +my @geoip_score = (); + ## cache stuff my $LOCKPATH = '/tmp/.policyd-weight/'; # must be a directory (add # trailing slash) @@ -742,6 +746,9 @@ exit; } +our $geoip = Geo::IP->new(GEOIP_STANDARD); + + # ---------------------------------------------------------- # main # ---------------------------------------------------------- @@ -1727,6 +1734,33 @@ $helo_ok = 2; } +## GeoIP check ############################################################### + + my $country = $geoip->country_code_by_addr("$ip"); + + if(defined($country)) + { + for($i=0; $i < @geoip_score; $i += 4) + { + if($country eq $geoip_score[$i]) + { + my $score = $geoip_score[$i+2]; + if ($score != 0) { + $RET .= " IN_".$geoip_score[$i+3]."=" . $score; + $rate += $score;; + } + } + else + { + my $score = $geoip_score[$i+1]; + if ($score != 0) { + $RET .= " NOT_IN_".$geoip_score[$i+3]."=" . $score; + $rate += $score;; + } + } + } + } + ## Reverse IP == dynhost check ###############################################