looks good

This commit is contained in:
lars 2005-05-17 00:26:11 +00:00
parent d30d9dba6d
commit 941be53e2b
4 changed files with 93 additions and 82 deletions

View file

@ -1,45 +1,9 @@
#!/bin/sh
set -ue
. web-splash.conf
remove_old()
{
# remove the rules from PREROUTING
$IPT -t nat -D PREROUTING -j $CHAIN_ALL
# empty and remove chains if they exist
for a in $CHAIN_FORWARD $CHAIN_REDIRECT $CHAIN_ALL
do $IPT -F $a 2>/dev/null && $IPT -X $a
done
}
init_chains()
{
# create chains
for a in $CHAIN_FORWARD $CHAIN_REDIRECT $CHAIN_ALL
do $IPT -N $a
done
# all packets from the specified interface go to the general chain
$IPT -t nat -A PREROUTING -i $IF_SRC -j $CHAIN_ALL
# default rules for CHAIN_ALL
# excetions will be handled by rules that are inserted before them
$IPT -A $CHAIN_ALL -p tcp --dport 80 -j $CHAIN_REDIRECT
$IPT -A $CHAIN_ALL -p tcp --dport 80 -j ACCEPT
$IPT -A $CHAIN_ALL -j $REJECT_ACTION
# all registered senders are simply accepted
$IPT -A $CHAIN_FORWARD -j ACCEPT
# all unregistered senders get redirected
$IPT -A $CHAIN_REDIRECT -j DNAT --to-destination $SPLASH_SERVER
$IPT -A $CHAIN_REDIRECT -j ACCEPT
}
set -uex
. /etc/web-splash.conf
. /test/splash-functions.inc
ACTION="--help"
[ $# -gt 0 ] && ACTION="$1"
@ -52,6 +16,14 @@ case "$ACTION" in
stop )
remove_old
;;
register )
[ $# -gt 2 ] && echo "[WEB_SPLASH] too many parameters: only one IP address is allowed" && exit 1
[ $# -lt 2 ] && echo "[WEB_SPLASH] you have to specify an IP address" && exit 2
register_IP "$2"
;;
update )
refresh_IP_list
;;
* )
echo "Syntax: $0 {start|stop|restart}"
echo