#! /bin/sh
#

echo daemon
echo noforce
echo maxconn 250
echo nserver 1.1.1.1
echo nserver 1.0.0.1
echo nserver 8.8.8.8
echo nserver 8.4.4.8
echo nscache 65536
echo nscache6 65536
echo timeouts 1 5 30 60 180 1800 15 60
# echo setgid 13
# echo setuid 13
echo stacksize 6000

echo config  'c:\\3proxy\\conf\\3proxy.cfg'
echo monitor 'c:\\3proxy\\conf\\3proxy.cfg'

echo log 'c:\\3proxy\\logs\\3proxy-%y%m%d.log' D
echo rotate 60
echo counter 'c:\\3proxy\\count\\3proxy.3cf'

echo users '$c:\\3proxy\\conf\\passwd'
# echo users admin:CL:pass

echo include 'c:\\3proxy\\conf\\counters'
echo include 'c:\\3proxy\\conf\\bandlimiters'

echo authcache user 600
echo auth strong cache
#echo auth none
#echo deny * * 127.0.0.1
#echo allow *
echo deny '*'
#echo 'deny * * 127.0.0.0/8,192.168.1.1'
#echo 'allow * * * 80-88,8080-8088 HTTP'
#echo 'allow * * * 443,8443 HTTPS'

#echo allow admin
#./add3proxyuser.sh me Haxx0r
#echo 'allow me *'
echo flush

#sockopt="-osTCP_NODELAY -ocTCP_NODELAY"
sockopt=
eip="88.119.175.54"
ipv4s="88.119.175.54"
num_ipv4s=`echo $ipv4s | wc -w`

ip()
{
    echo $ipv4s | awk -v n=$n '{print $(n + 1)}'
}

numports=500
hport=24000
sport=34000
count=0

echo >passwd

for i in `cat ip.list`; do
    n=`expr $count % $num_ipv4s`
    j=`ip n`

    rec=`cat socks-proxies.lst | grep $sport`
    user=`echo $rec | awk 'BEGIN {FS=":"} {print $3}'`
    pass=`echo $rec | awk 'BEGIN {FS=":"} {print $4}'`

    echo ""
    #echo users "$user:CL:$pass"
    echo allow $user
    #echo connlim 20 0 $user
    echo "proxy -64 -n -p$hport -i$eip -e$i -e$j $sockopt"
    echo flush

    #echo users "$user:CL:$pass"
    echo allow $user
    #echo connlim 20 0 $user
    echo "socks -64 -n -p$sport -i$eip -e$i -e$j $sockopt"
    echo flush

    echo "$user:CL:$pass" >>passwd

    hport=`expr $hport + 1`
    sport=`expr $sport + 1`
    count=`expr $count + 1`

    if [ $count -eq $numports ]; then
        break
    fi
done
