The following script looks for a file called torTarget.txt, and for each FQDN it:
- If the word "mail" appears in the FQDN, then I assume that this is a webmail service and force port 443
The output needs to be placed in the torrc file by hand and replace any existing policies.
#!/bin/sh
#
# If dig fails, try installing the dnsutils package
# e.g. sudo apt-get install dnsutils
#
echo
echo "# Target List Generated `date`"
echo "#"
echo
cat torTargets.txt | sort -f | while read site
do
if echo $site | grep -q "mail"
then
port="443"
else
port="80"
fi
dig +short $site | sort | head -n 1 | while read ip
do
echo "ExitPolicy accept\t $ip:$port \t# $site "
done
done
echo
echo "ExitPolicy accept\t *:5222 \t# Google Talk"
echo
echo
echo "ExitPolicy reject *:*"
echo
echo "# End of Exit Policy"
echo "#"