use DXLog;
use IO::File;
use File::Copy;
-use Socket qw(inet_pton inet_ntop);
+use Socket qw(AF_INET AF_INET6 inet_pton inet_ntop);
our $active = 0;
our $badipfn = "badip";
sub add
{
+ my $count = 0;
+
for my $ip (@_) {
# protect against stupid or malicious
next if /^127\./;
next;
}
$ipv4->add_any($ip);
+ ++$count;
++$count4;
} elsif (/:/) {
if ($ipv6->find($ip)) {
next;
}
$ipv6->add_any($ip);
+ ++$count;
++$count6;
LogDbg('DXProt', "DXCIDR: Added IPV6 $ip address");
}
$ipv6->prep_find;
_put($ipv6, 6);
}
+ return $count;
}
sub save
my @in;
my @out;
for (@_) {
- push @in, [inet_pton($_), split m|/|];
+ push @in, [inet_pton(m|:|?AF_INET6:AF_INET, $_), split m|/|];
}
@out = sort {$a->[0] <=> $b->[0]} @in;
return map { "$_->[1]/$_->[2]"} @out;