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> &lt;<a href="mailto:u-281@vif.com">u-281@vif.com</a>&gt; 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.&nbsp;&nbsp;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=&quot;CN|FR|GB|HK&quot;; # Those countries will be rejected.<br>COUNTRIES_TO_ACCEPT=&quot;AR|BR|CA|DE|IL|JP|MX|US&quot;; # All other countries will be rejected, those only will be accepted.
<br><br># Where to find a routers list:<br>ROUTERS=&quot;<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>&quot;<br><br># Location of your torrc file:
<br>TORRC=/etc/tor/torrc<br><br># Command to reload your torrc:<br>RELOAD=&quot;/etc/init.d/tor reload&quot;<br><br><br>####&nbsp;&nbsp;No need to modify nothing after this line ####<br><br>set -e<br><br>LOCRC=&quot;.tmp_torrc&quot;
<br>LOCROUT=&quot;.routers.txt&quot;<br><br>test -z $TORRC &amp;&amp; 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 &gt; $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 &quot;Countries &quot; &gt; $file<br>for i in `cat $LOCROUT | cut -f 1 -d &quot; &quot;| grep -v Tor | sort -u`; do
<br>&nbsp;&nbsp;&nbsp;&nbsp;echo -n &quot;$i &quot; &gt;&gt; $file<br>done<br><br>file=$LOCRC<br>echo -n &quot;ExcludeNodes &quot; &gt;&gt; $file<br>if [ &quot;$COUNTRIES_TO_ACCEPT&quot; != &quot;&quot; ]; then<br>&nbsp;&nbsp;&nbsp;&nbsp;for i in `cat $LOCROUT | egrep -v &quot;^($COUNTRIES_TO_ACCEPT)&quot; | cut -f 2 \
<br>-d &quot; &quot; | egrep -v &quot;^(\[|Network)&quot; | sed s/*//`; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo -n &quot;$i, &quot; &gt;&gt; $file<br>&nbsp;&nbsp;&nbsp;&nbsp;done<br>elif [ &quot;$COUNTRIES_TO_REJECT&quot; != &quot;&quot; ]; then<br>&nbsp;&nbsp;&nbsp;&nbsp;for i in `cat $LOCROUT | egrep &quot;^($COUNTRIES_TO_REJECT)&quot; | cut -f 2 -d \
<br>&quot; &quot; | egrep -v &quot;^\[&quot; | sed s/*//`; do<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo -n &quot;$i, &quot; &gt;&gt; $file<br>&nbsp;&nbsp;&nbsp;&nbsp;done<br>else exit 0<br>fi<br>echo finished &gt;&gt; $file<br><br>cp $LOCRC $TORRC<br><br># Have Tor to reload its config
<br>$RELOAD<br></blockquote></div><br>