[or-cvs] r14871: Moving to GeoIP built in cache (torstatus/trunk)
kasimir at seul.org
kasimir at seul.org
Sat May 31 16:45:49 UTC 2008
Author: kasimir
Date: 2008-05-31 12:45:49 -0400 (Sat, 31 May 2008)
New Revision: 14871
Modified:
torstatus/trunk/tns_update.pl
Log:
Moving to GeoIP built in cache
Modified: torstatus/trunk/tns_update.pl
===================================================================
--- torstatus/trunk/tns_update.pl 2008-05-31 16:42:45 UTC (rev 14870)
+++ torstatus/trunk/tns_update.pl 2008-05-31 16:45:49 UTC (rev 14871)
@@ -57,7 +57,6 @@
# Caching constansts for increased speed
my %CACHE;
-my %geoIPCache;
# Counter for updating mirror list
my $updateCounter = 0;
@@ -95,6 +94,9 @@
use RRDs;
}
+# Geo::IP needs to be loaded - include a built-in cache
+my $gi = Geo::IP->open($config{'GEOIP_Database_Path'} . "GeoIP.dat",GEOIP_MEMORY_CACHE | GEOIP_CHECK_CACHE);
+
# Loop through until killed
while (1 == 1)
{
@@ -681,9 +683,6 @@
############ Updating network status #########################################
-# Geo::IP needs to be loaded
-my $gi = Geo::IP->open($config{'GEOIP_Database_Path'} . "GeoIP.dat",GEOIP_STANDARD);
-
# Delete all of the records from the network status table that is going to be
# modified
$dbh->do("TRUNCATE TABLE NetworkStatus${descriptorTable};");
@@ -769,15 +768,7 @@
$currentRouter{'DirPort'} = $8;
# We need to find the country of the IP
- if ($geoIPCache{$6})
- {
- $currentRouter{'Country'} = $geoIPCache{$6};
- }
- else
- {
- $currentRouter{'Country'} = $gi->country_code_by_addr($6);
- $geoIPCache{$6} = $currentRouter{'Country'};
- }
+ $currentRouter{'Country'} = $gi->country_code_by_addr($6);
# And the host by addr
$currentRouter{'Hostname'} = lookup($6);
More information about the tor-commits
mailing list