diff --git a/firewall/firewall-add b/firewall/firewall-add index c29be73..cf48385 100755 --- a/firewall/firewall-add +++ b/firewall/firewall-add @@ -1,16 +1,32 @@ #!/bin/sh +# Debugging function +debug() { + if [ $DEBUG -eq 1 ]; then + echo "DEBUG: "$1 $2 $3 + fi; +} + # Task type variables NSENTER=$NSENTER PREROUTING=$PREROUTING POSTROUTING=$POSTROUTING # Mandatory task variables -NAME=$NAME-$COMMENT CHAIN=$CHAIN +NAME=$NAME COMMENT=$COMMENT +NAME=$NAME-$COMMENT PROTOCOL=$TYPE +EXTRA_OPTIONS="$2 $3 $4" + + # turn on debug mode by extra option "debug" + if [[ "$(echo "$EXTRA_OPTIONS" | grep debug)" != "" ]] ; then + DEBUG=1 + fi; + + ############################## echo 1 > /proc/sys/net/ipv4/ip_forward @@ -81,6 +97,8 @@ if [[ "$NSENTER" == "true" ]] ; then if [[ "$PREROUTING" == "true" ]] || [[ "$POSTROUTING" == "true" ]] ; then iptables="nsenter -t $(docker inspect --format {{.State.Pid}} $NAME) -n -- $IPTABLES -t nat"; + debug "iptables: "$IPTABLES; + if [[ "$PREROUTING" == "true" ]] ; then prerouting;