Convert networks addresses to CIDR

tags/0.0.1
Daniel Berteaud 12 years ago
parent 5e358594af
commit 41dab44026
  1. 15
      root/etc/e-smith/templates/etc/fail2ban/jail.conf/05IgnoreIP

@ -1,24 +1,33 @@
{
use esmith::NetworksDB;
use Net::IPv4Addr;
my $n = esmith::NetworksDB->open_ro() ||
die "Couldn't open networks DB\n";
my @ip = ("127.0.0.0/8");
# Add hosts which can access the server-manager to the whitelist
push @ip, $_ foreach (split /[,;]/, (${'httpd-admin'}{'ValidFrom'} || ''));
foreach (split /[,;]/, (${'httpd-admin'}{'ValidFrom'} || '')){
my ($ip,$bits) = Net::IPv4Addr::ipv4_parse("$_");
push @ip, "$ip/$bits";
}
unless (($fail2ban{FilterLocalNetworks} || 'disabled') eq 'enabled'){
foreach my $net ($n->networks){
my $key = $net->key;
my $mask = $net->prop('Mask');
push @ip, "$key/$mask";
my ($ip,$bits) = Net::IPv4Addr::ipv4_parse("$key/$mask");
push @ip, "$ip/$bits";
}
}
# Add a local whitelist
push @ip, $_ foreach (split /[,;]/, ($fail2ban{'IgnoreIP'} || ''));
foreach (split /[,;]/, ($fail2ban{'IgnoreIP'} || '')){
my ($ip,$bits) = Net::IPv4Addr::ipv4_parse("$_");
push @ip, "$ip/$bits";
}
$OUT .= "ignoreip = " . join(" ", @ip);

Loading…
Cancel
Save