Skip to content

Commit

Permalink
fix the iptables bug
Browse files Browse the repository at this point in the history
  • Loading branch information
roubo committed Oct 13, 2014
1 parent bec8a36 commit 2f3b295
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"package_id" : "com.modouwifi.vpnss",
"os_version" : "0.6.33",
"name" : "魔豆shadowsocks",
"author" : "shadow",
"author" : "yinkeedai",
"author_mail" : "[email protected]",
"homepage" : "shadowsocks.org",
"version" : "0.2.0",
Expand Down
8 changes: 3 additions & 5 deletions sbin/ss-transp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ passwd=$4
ssIptablesAdd()
{
# create new chain
iptables -t nat -N SHADOWSOCKS
iptables -t nat -N SHADOWSOCKS 1>/dev/null 2>&1
# ignore server addr
iptables -t nat -A SHADOWSOCKS -d $serveraddr -j RETURN
# ignore LANs addr
Expand All @@ -20,15 +20,13 @@ ssIptablesAdd()
# anything else will be redirected to ss local port
iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 1080
# apply the rules
#iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
iptables -t nat -I PREROUTING -p tcp -j SHADOWSOCKS
return 0
}

ssIptablesClear()
{
iptables -t nat -F SHADOWSOCKS
iptables -t nat -F OUTPUT
iptables -t nat -D PREROUTING -p tcp -j SHADOWSOCKS
}
ssRedirStop()
Expand All @@ -38,11 +36,11 @@ ssRedirStop()

ssRedirStart()
{
$CURWDIR/../bin/ss-redir -s $serveraddr -p $serverport -l 1080 -k $passwd -b 0.0.0.0 -m $secmode -v
$CURWDIR/../bin/ss-redir -s $serveraddr -p $serverport -l 1080 -k $passwd -b 0.0.0.0 -m $secmode -v &
}

# main
ssIptablesClear;
ssRedirStop;
ssRedirStart;
ssIptablesClear;
ssIptablesAdd;
8 changes: 4 additions & 4 deletions sbin/ss.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ ssStart()
secmode=`head -n 3 $SETCONF | tail -n 1 | cut -d ' ' -f2-`;
passwd=`head -n 4 $SETCONF | tail -n 1 | cut -d ' ' -f2-`;
$SSSHELL $serveraddr $serverport $secmode $passwd &
sleep 1
sleep 2
genCustomConfig;
pid=`cat $PIDFILE 2>/dev/null`;
kill -SIGUSR1 $pid >/dev/null 2>&1;
Expand All @@ -146,9 +146,9 @@ ssStart()
ssStop()
{
killall ss-redir 1>/dev/null 2>&1;
iptables -t nat -F SHADOWSOCKS
iptables -t nat -F OUTPUT
iptables -t nat -D PREROUTING -p tcp -j SHADOWSOCKS
iptables -t nat -F SHADOWSOCKS 1>/dev/null 2>&1
iptables -t nat -F OUTPUT 1>/dev/null 2>&1
iptables -t nat -D PREROUTING -p tcp -j SHADOWSOCKS 1>/dev/null 2>&1
genCustomConfig;
pid=`cat $PIDFILE 2>/dev/null`;
kill -SIGUSR1 $pid >/dev/null 2>&1;
Expand Down

0 comments on commit 2f3b295

Please sign in to comment.