codekasten/web-splash/update-rules.sh
2005-05-16 23:37:23 +00:00

41 lines
669 B
Bash
Executable file

#!/bin/sh
. web-splash.conf
get_IPs()
# prints out all active forwards line by line
# every line consists of: "Number of Packets" and "IP"
{
iptables -L "$SPLASH_CHAIN" -vnx | sed "1,2d; s/ */ /g" | cut -d " " -f 2,9
# get all active forward chains
# remove the first two lines
# remove multiple spaces
# take only the number of packets and the IP
}
register_IP()
# add a new allowed IP
{
`echo "$RULE_ADD" | sed "s/_IP_/$1/g"`
}
unregister_IP()
# remove the specified IP
{
`echo "$RULE_DEL" | sed "s/_IP_/$1/g"`
}
refresh_IP_list()
{
local NUM
local IP
get_IPs | while read NUM IP
do [ "$NUM" = "0" ] && remove_IP "$IP"
done
}
refresh_IP_list