Use local variable instead of global

This commit is contained in:
Jérôme Schneider 2011-06-23 16:53:25 +02:00
parent 0749affec5
commit 584c4b8aa6
1 changed files with 21 additions and 21 deletions

View File

@ -75,10 +75,10 @@ forward_port()
return return
fi fi
source=$1 local source=$1
port=$2 local port=$2
destination=$3 local destination=$3
proto=$4 local proto=$4
if echo "$destination" | grep -q ":"; then if echo "$destination" | grep -q ":"; then
dest_ip=$(echo $destination | cut -d ":" -f1) dest_ip=$(echo $destination | cut -d ":" -f1)
@ -97,13 +97,13 @@ forward_port()
open_port() open_port()
{ {
if [ $# == 4 ]; then if [ $# == 4 ]; then
destination=$2 local destination=$2
proto=$3 local proto=$3
ports=$4 local ports=$4
elif [ $# == 3 ]; then elif [ $# == 3 ]; then
destination=$IP local destination=$IP
proto=$2 local proto=$2
ports=$3 local ports=$3
else else
echo "!!! CRITICAL Open port bad syntax : $*" echo "!!! CRITICAL Open port bad syntax : $*"
stop && exit 1 stop && exit 1
@ -123,10 +123,10 @@ port_redirection()
return return
fi fi
if=$1 local if=$1
proto=$2 local proto=$2
srcport=$3 local srcport=$3
destport=$4 local destport=$4
echo "+ Redirect $if port $srcport to $destport for portocol $proto" echo "+ Redirect $if port $srcport to $destport for portocol $proto"
iptables -t nat -A PREROUTING -i $if -p $proto --dport $srcport -j REDIRECT --to-port $destport iptables -t nat -A PREROUTING -i $if -p $proto --dport $srcport -j REDIRECT --to-port $destport
@ -139,11 +139,11 @@ port_knocking()
return return
fi fi
port=$1 local port=$1
knock_ports=$2 local knock_ports=$2
knock_number=$3 local knock_number=$3
local i=0
i=0
for kport in $(echo $knock_ports | sed 's/,/ /g'); do for kport in $(echo $knock_ports | sed 's/,/ /g'); do
((i++)) ((i++))
tock_number=$knock_number$i tock_number=$knock_number$i
@ -253,10 +253,10 @@ start()
done done
## Port knocking ## Port knocking
j=1 local i=1
for args in "${PORT_KNOCK[@]}"; do for args in "${PORT_KNOCK[@]}"; do
port_knocking $args $j port_knocking $args $i
((j++)) ((i++))
done done
## Port forwading ## Port forwading