# Script by Jake Vickers (jake@v2gnu.com) to test the response times of # blacklists used by mailers, and remove ones that have a high latency # www.v2gnu.com # Initial release - December 19, 2006 - Version 0.1 # The file that gets changed is PURPOSELY not set to your real blacklists file; # you can set it for that once you feel comfortable that it will work for you. #!/bin/bash BLS="zen.spamhaus.org list.dsbl.org" # Blacklists we want to use CEILING=5 # Number of seconds to set as our max before we dump a BL BLFILENAME=/root/blacklists # name of the blacklists file # You shouldn't need to change anything below this line LOEND=1 # lowest IP number to use HIEND=253 # highest IP number to use RANDMAX=32767 # for random number generator TIMEFORMAT="%R" # needed for time to output a whole number we can use # Generate our IP octets ANUMBER=$(( $LOEND + ($HIEND * $RANDOM) / ($RANDMAX + 1) )) BNUMBER=$(( $LOEND + ($HIEND * $RANDOM) / ($RANDMAX + 1) )) CNUMBER=$(( $LOEND + ($HIEND * $RANDOM) / ($RANDMAX + 1) )) DNUMBER=$(( $LOEND + ($HIEND * $RANDOM) / ($RANDMAX + 1) )) # See if we're in test mode or not if [ "$BLS" = "/root/blacklists" ] ; then echo "We are in test mode. No changes will be made to the system." fi #Test the BLs, and change our list if [ "$BLS" != "" ] ; then rm -f $BLFILENAME # Remove old blacklist file for blcheck in ${BLS} ; do NBR=$(time dig +time=$CEILING +short $ANUMBER.$BNUMBER.$CNUMBER.$DNUMBER.$blcheck) if [ `expr '$NBR' \<= '$CEILING'` ] ; then echo -n "-r "$blcheck" " >> $BLFILENAME fi done fi /usr/bin/qmailctl reload