[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: How to remove some useless nodes



On Jan 29, 2008 6:47 PM, Jackie <g06b08120301@xxxxxxxxxxxxxxxx> wrote:
> To remove these fucking nodes mannually one by one is a boring job!!!
> I wonder where to get a router list which contains information about
> country, or just a exit nodes list is much more better!
> Does Tor keep a copy of router list on my PC?
>
Yes, it does. The router list and the geolocation data are kept
separately. If you are using Windows, the Tor configuration directory
which keeps the router list is likely to be
"[your-system-drive]\Documents and
Settings\[your-username]\Application Data\Tor". The Vidalia
configuration directory which keeps the geolocation data would be
"[your-system-drive]\Documents and
Settings\[your-username]\Application Data\Vidalia".

My previous script makes use of the file "cached-descriptors" in your
Tor configuration directory, and the file "geoip-cache" in your
Vidalia configuration directory. If you're using Tor 0.2.x, here's a
more efficient Perl script that uses
[Tor-config-directory]\cached-consensus and
[Vidalia-config-directory]\geoip-cache.

Cheers,
John
#!/usr/bin/perl

# Usage
if (@ARGV != 3) {
  print "Usage: $ENV{'_'} [2-letter-country-code] [consensus-file] [geoip-file] \n";
  exit(1);
}

$ARGV[0] = uc($ARGV[0]);

# Build ip-to-country hash table from geoip cache
open(GEOIP,$ARGV[2]);
while (<GEOIP>) {
  ($ip,undef,undef,$country,undef) = split(/,/);
  $geoip{$ip} = $country;
}

# Parse descriptor file and extract fingerprints
open(CONSENSUS,$ARGV[1]);
$switch = false;
while (<CONSENSUS>) {
  chomp;
  @params = split(/ /);
  if ($params[0] eq 'r') {
    $switch = $geoip{$params[6]} eq $ARGV[0];
    $fingerprint = $params[2];
  } elsif ($switch && $params[0] eq 's') {
    $switch = $switch && grep(/Exit/,@params);
  } elsif ($switch && $params[0] eq 'v') {
    $fingerprint =~ tr#A-Za-z0-9+/##cd;
    $fingerprint =~ tr#A-Za-z0-9+/# -_#;
    $len = pack('c', 32 + 0.75*length($fingerprint));
    $fingerprint = uc(unpack('H*',unpack('u', $len . $fingerprint)));
    push(@exclude,"\$$fingerprint");
  }
}
print 'ExcludeNodes ',join(',',@exclude),"\n";