Skip Menu |

This queue is for tickets about the IP-Country CPAN distribution.

Report information
The Basics
Id: 99359
Status: open
Priority: 0/
Queue: IP-Country

People
Owner: Nobody in particular
Requestors: m.grau [...] kcc.state.ks.us
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: 165.201.nnn.nnn is US, not EU
Date: Tue, 07 Oct 2014 14:57:44 -0500
To: bug-IP-Country [...] rt.cpan.org
From: Mike Grau <m.grau [...] kcc.state.ks.us>
165.201.nnn.nnn is US, not EU
Subject: [rt.cpan.org #99359] Possible solution for incorrect countries for IPs
Date: Thu, 16 Oct 2014 09:40:55 -0700
To: bug-IP-Country [...] rt.cpan.org
From: LinuxMagic Development Team <developers [...] linuxmagic.com>
Hello, I ran into this problem as well for certain IPs, and I believe I have an explanation and a solution to it. Cause: In the RIPE file used when building the database, there are blocks listed in this way: inetnum: 158.48.0.0 - 158.48.255.255 netname: NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK descr: IPv4 address block not managed by the RIPE NCC [..snip..] This is apparently causing such blocks to be listed as EU when building the database, though they are not. Solution: ipcc_loader.pl should ignore these blocks in the RIPE file. Once modified, rebuilding the database should no longer show such IPs as EU. Here is the patch I applied to ignore them: --- ipcc_loader.pl_2.28 2014-10-14 09:32:50.000000000 -0700 +++ ipcc_loader.pl 2014-10-14 09:32:50.000000000 -0700 @@ -324,34 +324,54 @@ { print STDERR "loading data from ripe.db.inetnum\n"; my $ripe_inet_line = qr/^inetnum:\s+(\S+)\s*-\s*(\S+)/o; + # NOTE: /o means compile only once. + my $ripe_non_managed_line = qr/^netname:\s+NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK/o; my $ripe_cc_line = qr/^country:\s+(\S\S)/o; open (REG,"< $reg_dir/ripe.db.inetnum") or die("can't open $reg_dir/ripe.db.inetnum: $!"); binmode REG, ':crlf'; { - my $start; - my $end; - my $cc; - my $status; - while (my $line = <REG>){ - if (defined $start){ - next unless $line =~ $ripe_cc_line; - $cc = uc $1; - $cc = 'GB' if ($cc eq 'UK'); - insert_raw($start,$end-$start+1,$cc,$end-$start+1); - $start = undef; - $end = undef; - } elsif ($line =~ $ripe_inet_line){ - my ($a_start,$a_end) = ($1,$2); - if ($a_start =~ $ip_match){ - $start = ($1 * 16777216) + ($2 * 65536) + ($3 * 256) + $4; - } - if ($a_end =~ $ip_match){ - $end = ($1 * 16777216) + ($2 * 65536) + ($3 * 256) + $4; - } - die($line) unless ((defined $start) && (defined $end)); - } else { - } - } + my $start; + my $end; + my $cc; + my $status; + my $non_managed = 0; + while (my $line = <REG>) { + if (defined $start) { + # sometimes we have blocks indicating the block is not managed. + # e.g. + # inetnum: 158.48.0.0 - 158.48.255.255 + # netname: NON-RIPE-NCC-MANAGED-ADDRESS-BLOCK + if ($line =~ $ripe_non_managed_line) { + $non_managed = 1; + next; + } + next unless $line =~ $ripe_cc_line; + # not managed, don't insert! + if ($non_managed) { + $start = undef; + $end = undef; + print "skipping non-managed...\n"; + next; + } + $cc = uc $1; + $cc = 'GB' if ($cc eq 'UK'); + insert_raw($start,$end-$start+1,$cc,$end-$start+1); + $start = undef; + $end = undef; + } elsif ($line =~ $ripe_inet_line) { + my ($a_start,$a_end) = ($1,$2); + if ($a_start =~ $ip_match){ + $start = ($1 * 16777216) + ($2 * 65536) + ($3 * 256) + $4; + } + if ($a_end =~ $ip_match){ + $end = ($1 * 16777216) + ($2 * 65536) + ($3 * 256) + $4; + } + die($line) unless ((defined $start) && (defined $end)); + # non-managed line is after inetnum line. so reset here. + $non_managed = 0; + } else { + } + } } close REG || warn("can't close $reg_dir/ripe.db.inetnum, but continuing: $!"); } -- "Catch the Magic of Linux..." www.linuxmagic.com -------------------------------------------- Development Services - LinuxMagic Inc. A Wizard IT company - For More Info http://www.wizard.ca "LinuxMagic" is a Registered TradeMark of Wizard Tower TechnoServices Ltd. "Wizard IT" is a company TradeMark of Wizard Tower TechnoServices Ltd. ------------------------------------------- 604-682-0300 Beautiful British Columbia, Canada This email and any electronic data contained are confidential and intended solely for the use of the individual or entity to which they are addressed. Please note that any views or opinions presented in this email are solely those of the author and are not intended to represent those of the company.
I can confirm this patch works with the latest gif files from mailfud. otherwise there are numerous erroneous EU results. Any change of a new release? We'll patch in the meantime 214.24.26.84 56.0.84.93 56.0.84.98 56.0.143.47 34.208.149.229 107.150.62.250