[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r15013: (ticket:98) Not penalizing unknown data (in torstatus/trunk: . geoip)
Author: kasimir
Date: 2008-06-07 13:30:43 -0400 (Sat, 07 Jun 2008)
New Revision: 15013
Modified:
torstatus/trunk/geoip/GeoIP.dat
torstatus/trunk/tns_update.pl
Log:
(ticket:98) Not penalizing unknown data
Modified: torstatus/trunk/geoip/GeoIP.dat
===================================================================
(Binary files differ)
Modified: torstatus/trunk/tns_update.pl
===================================================================
--- torstatus/trunk/tns_update.pl 2008-06-07 17:18:13 UTC (rev 15012)
+++ torstatus/trunk/tns_update.pl 2008-06-07 17:30:43 UTC (rev 15013)
@@ -467,6 +467,7 @@
{
$currentRouter{'bandwidthcounter'} += $num;
}
+ $currentRouter{'readnumber'} = scalar(@readhistory);
}
@@ -502,6 +503,7 @@
{
$currentRouter{'bandwidthcounter'} += $num;
}
+ $currentRouter{'writenumber'} = scalar(@writehistory);
}
# Format for the router-signature line
@@ -595,6 +597,7 @@
{
$currentRouter{'bandwidthcounter'} += $num;
}
+ $currentRouter{'readnumber'} = scalar(@readhistory);
}
# Format for the write-history line
@@ -629,6 +632,7 @@
{
$currentRouter{'bandwidthcounter'} += $num;
}
+ $currentRouter{'writenumber'} = scalar(@writehistory);
}
}
# Close the new Tor connection
@@ -636,7 +640,13 @@
}
# Calculate the bandwidth
- $currentRouter{'BandwidthOBSERVED'} = $currentRouter{'bandwidthcounter'}/172800;
+ my $divisor = 900*($currentRouter{'writenumber'} + $currentRouter{'readnumber'});
+ # Ensure that no division by zero occurs
+ if ($divisor == 0)
+ {
+ $divisor = 172800;
+ }
+ $currentRouter{'BandwidthOBSERVED'} = $currentRouter{'bandwidthcounter'}/$divisor;
# Save the data to the MySQL database
$dbresponse->execute( $currentRouter{'nickname'},
@@ -785,21 +795,21 @@
}
# And the host by addr (using caching)
- if ($hostnameCache{$6})
- {
- $currentRouter{'Hostname'} = $hostnameCache{$6};
- }
- else
- {
+# if ($hostnameCache{$6})
+# {
+# $currentRouter{'Hostname'} = $hostnameCache{$6};
+# }
+# else
+# {
$currentRouter{'Hostname'} = lookup($6);
# If the hostname was not found, it should be an IP
unless ($currentRouter{'Hostname'})
{
$currentRouter{'Hostname'} = $6;
}
- $hostnameCache{$6} = $currentRouter{'Hostname'};
+# $hostnameCache{$6} = $currentRouter{'Hostname'};
+# }
}
- }
}
# Format for the "s" line