updated on Thu Jan 26 16:09:46 UTC 2012
[aur-mirror.git] / transocks_ev-svn / transocks
blob0fe6c977b861af794b924833ecd4c3e2bebcc6f8
1 #!/bin/bash
3 . /etc/rc.conf
4 . /etc/conf.d/transocks
5 . /etc/rc.d/functions
7 case "$1" in
8 start)
9 stat_busy "Enabling transocks"
10 /usr/bin/transocks_ev -p $TRANSOCKS_PORT -s $SOCKS_PORT -S $SOCKS_HOST
12 # Create chain
13 $IPTABLES -t nat -N transocks
15 # Do not redirect traffic for the SOCKS-Server
16 $IPTABLES -t nat -I transocks -p tcp -d $SOCKS_HOST --dport $SOCKS_PORT -j RETURN
18 # Do not redirect local network
19 $IPTABLES -t nat -I transocks -o lo -j RETURN
20 for ip in $LOCAL_IPS; do
21 $IPTABLES -t nat -I transocks -d $ip -j RETURN
22 done
24 # Enable Logging
25 if [ "${ENABLE_LOGGING}" == "y" ]; then
26 $IPTABLES -t nat -A transocks -p tcp -j LOG --syn --log-level info --log-prefix "SOCKSify "
28 # Redirect all traffic that gets to the end of our chain
29 $IPTABLES -t nat -A transocks -p tcp -j REDIRECT --to-port $TRANSOCKS_PORT
31 # Filter all traffic from this computer
32 $IPTABLES -t nat -A OUTPUT -j transocks
34 # Filter all traffic that is routed over this host
35 if [ "${ENABLE_ROUTING}" == "y" ]; then
36 $IPTABLES -t nat -A PREROUTING -j transocks
38 stat_done
39 add_daemon transocks
41 stop)
42 stat_busy "Disabling transocks"
43 /usr/bin/killall transocks_ev
44 $IPTABLES -t nat -D OUTPUT -j transocks
45 if [ "${ENABLE_ROUTING}" == "y" ]; then
46 $IPTABLES -t nat -D PREROUTING -j transocks
48 $IPTABLES -t nat -F transocks
49 $IPTABLES -t nat -X transocks
50 rm_daemon transocks
51 stat_done
53 restart)
54 $0 stop
55 sleep 1
56 $0 start
59 echo "usage: $0 {start|stop|restart}"
61 esac
62 exit 0