Use local variable instead of global
This commit is contained in:
parent
0749affec5
commit
584c4b8aa6
42
firewall
42
firewall
|
@ -75,10 +75,10 @@ forward_port()
|
|||
return
|
||||
fi
|
||||
|
||||
source=$1
|
||||
port=$2
|
||||
destination=$3
|
||||
proto=$4
|
||||
local source=$1
|
||||
local port=$2
|
||||
local destination=$3
|
||||
local proto=$4
|
||||
|
||||
if echo "$destination" | grep -q ":"; then
|
||||
dest_ip=$(echo $destination | cut -d ":" -f1)
|
||||
|
@ -97,13 +97,13 @@ forward_port()
|
|||
open_port()
|
||||
{
|
||||
if [ $# == 4 ]; then
|
||||
destination=$2
|
||||
proto=$3
|
||||
ports=$4
|
||||
local destination=$2
|
||||
local proto=$3
|
||||
local ports=$4
|
||||
elif [ $# == 3 ]; then
|
||||
destination=$IP
|
||||
proto=$2
|
||||
ports=$3
|
||||
local destination=$IP
|
||||
local proto=$2
|
||||
local ports=$3
|
||||
else
|
||||
echo "!!! CRITICAL Open port bad syntax : $*"
|
||||
stop && exit 1
|
||||
|
@ -123,10 +123,10 @@ port_redirection()
|
|||
return
|
||||
fi
|
||||
|
||||
if=$1
|
||||
proto=$2
|
||||
srcport=$3
|
||||
destport=$4
|
||||
local if=$1
|
||||
local proto=$2
|
||||
local srcport=$3
|
||||
local destport=$4
|
||||
|
||||
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
|
||||
|
@ -139,11 +139,11 @@ port_knocking()
|
|||
return
|
||||
fi
|
||||
|
||||
port=$1
|
||||
knock_ports=$2
|
||||
knock_number=$3
|
||||
local port=$1
|
||||
local knock_ports=$2
|
||||
local knock_number=$3
|
||||
local i=0
|
||||
|
||||
i=0
|
||||
for kport in $(echo $knock_ports | sed 's/,/ /g'); do
|
||||
((i++))
|
||||
tock_number=$knock_number$i
|
||||
|
@ -253,10 +253,10 @@ start()
|
|||
done
|
||||
|
||||
## Port knocking
|
||||
j=1
|
||||
local i=1
|
||||
for args in "${PORT_KNOCK[@]}"; do
|
||||
port_knocking $args $j
|
||||
((j++))
|
||||
port_knocking $args $i
|
||||
((i++))
|
||||
done
|
||||
|
||||
## Port forwading
|
||||
|
|
Reference in New Issue