Skip to content

Instantly share code, notes, and snippets.

@stefb69
Last active August 19, 2016 13:34
Show Gist options
  • Save stefb69/64a52a4bcde96abb1459 to your computer and use it in GitHub Desktop.
Save stefb69/64a52a4bcde96abb1459 to your computer and use it in GitHub Desktop.
GeoIP postfwd2 plugin
#Example usage
id=SASL_003
HIT_dnsbls >= 2
sasl_username =~ /^(.+)$/
client_country_code !~ /^(FR|IL|US|UK|CA|BE|CH|IT)$/
action = rcpt(sasl_username/3/86400/REJECT your is ip listed as trojaned, only 3 recipient per DAY for $$sasl_username)
#!/usr/bin/perl
use Geo::IP;
my $gi = Geo::IP->new(GEOIP_MEMORY_CACHE);
%postfwd_items_plugin = (
"client_country_code" => sub {
my(%request) = @_;
my(%result) = ();
$result{client_country_code} = $gi->country_code_by_addr($request{client_address});
return %result;
},
);
1;
## EOF postfwd.plugins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment