mirror of
git://git.code.sf.net/p/xtables-addons/xtables-addons
synced 2025-09-13 16:14:57 +02:00
geoipdb builder: separate into functions
This commit is contained in:
@@ -35,6 +35,11 @@ foreach (qw(LE BE)) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&collect();
|
||||||
|
&dump();
|
||||||
|
|
||||||
|
sub collect
|
||||||
|
{
|
||||||
while (my $row = $csv->getline(*ARGV)) {
|
while (my $row = $csv->getline(*ARGV)) {
|
||||||
if (!defined($country{$row->[4]})) {
|
if (!defined($country{$row->[4]})) {
|
||||||
$country{$row->[4]} = {
|
$country{$row->[4]} = {
|
||||||
@@ -56,8 +61,18 @@ while (my $row = $csv->getline(*ARGV)) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print STDERR "\r\e[2K$. entries total\n";
|
print STDERR "\r\e[2K$. entries total\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
sub dump
|
||||||
|
{
|
||||||
foreach my $iso_code (sort keys %country) {
|
foreach my $iso_code (sort keys %country) {
|
||||||
|
&dump_one($iso_code);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub dump_one
|
||||||
|
{
|
||||||
|
my $iso_code = shift @_;
|
||||||
my($file, $fh_le, $fh_be);
|
my($file, $fh_le, $fh_be);
|
||||||
|
|
||||||
printf "%5u IPv6 ranges for %s %s\n",
|
printf "%5u IPv6 ranges for %s %s\n",
|
||||||
|
Reference in New Issue
Block a user