Thanks. I've been looking for something like this.<br><br><div><span class="gmail_quote">On 7/17/06, <b class="gmail_sendername">Marcel</b> <<a href="mailto:u-281@vif.com">u-281@vif.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi fellow tor users.<br><br>I made a little script to exclude the tor routers in some countries.<br>Either choose the countries you want, or those you don't. You can put this<br>script anywhere but in your torrc directory.
<br><br><br><br>#!/bin/sh<br><br><br># Set one or another, but not both, alphabetical order plz:<br>#COUNTRIES_TO_REJECT="CN|FR|GB|HK"; # Those countries will be rejected.<br>COUNTRIES_TO_ACCEPT="AR|BR|CA|DE|IL|JP|MX|US"; # All other countries will be rejected, those only will be accepted.
<br><br># Where to find a routers list:<br>ROUTERS="<a href="http://serifos.eecs.harvard.edu/cgi-bin/exit.pl?textonly=1">http://serifos.eecs.harvard.edu/cgi-bin/exit.pl?textonly=1</a>"<br><br># Location of your torrc file:
<br>TORRC=/etc/tor/torrc<br><br># Command to reload your torrc:<br>RELOAD="/etc/init.d/tor reload"<br><br><br>#### No need to modify nothing after this line ####<br><br>set -e<br><br>LOCRC=".tmp_torrc"
<br>LOCROUT=".routers.txt"<br><br>test -z $TORRC && exit 0<br><br># create a backup of the torrc file<br>cp $TORRC ${LOCRC}.bak<br><br># Remove ExcludeNodes line from torrc<br>cat $TORRC | grep -vi Excludenodes > $LOCRC
<br><br># Download routers list.<br>wget -O $LOCROUT $ROUTERS || exit 0<br><br># Write list of actual countries to a text file for reference<br>file=Countries.txt<br>echo -n "Countries " > $file<br>for i in `cat $LOCROUT | cut -f 1 -d " "| grep -v Tor | sort -u`; do
<br> echo -n "$i " >> $file<br>done<br><br>file=$LOCRC<br>echo -n "ExcludeNodes " >> $file<br>if [ "$COUNTRIES_TO_ACCEPT" != "" ]; then<br> for i in `cat $LOCROUT | egrep -v "^($COUNTRIES_TO_ACCEPT)" | cut -f 2 \
<br>-d " " | egrep -v "^(\[|Network)" | sed s/*//`; do<br> echo -n "$i, " >> $file<br> done<br>elif [ "$COUNTRIES_TO_REJECT" != "" ]; then<br> for i in `cat $LOCROUT | egrep "^($COUNTRIES_TO_REJECT)" | cut -f 2 -d \
<br>" " | egrep -v "^\[" | sed s/*//`; do<br> echo -n "$i, " >> $file<br> done<br>else exit 0<br>fi<br>echo finished >> $file<br><br>cp $LOCRC $TORRC<br><br># Have Tor to reload its config
<br>$RELOAD<br></blockquote></div><br>