"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "share/arno-iptables-firewall/plugins/traffic-accounting-helper" between
aif-2.1.0.tar.gz and aif-2.1.1.tar.gz

About: Arno’s iptables firewall is a stateful firewall script for both single and multi-homed machines with DSL/ADSL support.

traffic-accounting-helper  (aif-2.1.0):traffic-accounting-helper  (aif-2.1.1)
skipping to change at line 51 skipping to change at line 51
local RETVAL=0 local RETVAL=0
# Touch the log file (just in case it doesn't exist yet): # Touch the log file (just in case it doesn't exist yet):
touch /var/log/traffic-accounting.log touch /var/log/traffic-accounting.log
# Truncate file # Truncate file
printf "" >/tmp/traffic-accounting.new printf "" >/tmp/traffic-accounting.new
# Process the input chain # Process the input chain
if [ "$VERBOSE" = "1" ]; then if [ "$VERBOSE" = "1" ]; then
echo "Traffic Accounting Hosts:" echo "${INDENT}Traffic Accounting Hosts:"
echo "-------------------------" echo "${INDENT}-------------------------"
fi fi
# Also include default unicast route addresses, (0.0.0.0/0 and ::/0) # Also include default unicast route addresses, (0.0.0.0/0 and ::/0)
DEFAULT_ADDR="0.0.0.0/0" DEFAULT_ADDR="0.0.0.0/0"
if [ "$IPV6_SUPPORT" = "1" ]; then if [ "$IPV6_SUPPORT" = "1" ]; then
DEFAULT_ADDR="$DEFAULT_ADDR ::/0" DEFAULT_ADDR="$DEFAULT_ADDR ::/0"
fi fi
IFS=' ,' IFS=' ,'
for host in $TRAFFIC_ACCOUNTING_HOSTS $DEFAULT_ADDR; do for host in $TRAFFIC_ACCOUNTING_HOSTS $DEFAULT_ADDR; do
if [ "$VERBOSE" = "1" ]; then
printf "Host=$host "
fi
old_entry="$(grep "^$host " /var/log/traffic-accounting.log)" old_entry="$(grep "^$host " /var/log/traffic-accounting.log)"
old_ip="$(echo "$old_entry" |cut -s -d' ' -f2)" old_ip="$(echo "$old_entry" |cut -s -d' ' -f2)"
old_in_value="$(echo "$old_entry" |cut -s -d' ' -f3)" old_in_value="$(echo "$old_entry" |cut -s -d' ' -f3)"
old_out_value="$(echo "$old_entry" |cut -s -d' ' -f4)" old_out_value="$(echo "$old_entry" |cut -s -d' ' -f4)"
# If value is non-existant make it zero # If value is non-existant make it zero
if [ -z "$old_in_value" ]; then if [ -z "$old_in_value" ]; then
old_in_value=0 old_in_value=0
fi fi
skipping to change at line 93 skipping to change at line 89
# Parse/get hostname. Try to use host cache if applicable # Parse/get hostname. Try to use host cache if applicable
# NOTE: get_dynamic_host_cached returns hostname in $host_ip # NOTE: get_dynamic_host_cached returns hostname in $host_ip
if ! get_dynamic_host_cached $host || [ -z "$host_ip" ]; then if ! get_dynamic_host_cached $host || [ -z "$host_ip" ]; then
echo "** WARNING: Skipping rule for \"$host\"! **" >&2 echo "** WARNING: Skipping rule for \"$host\"! **" >&2
RETVAL=1 RETVAL=1
continue continue
fi fi
IFS=' ,' IFS=' ,'
for mon_host_ip in $host_ip; do for mon_host_ip in $host_ip; do
echo "${INDENT}Monitoring host \"$host\" with IP(s): $mon_host_ip" echo "${INDENT}Monitoring host \"$host\" with IP: $mon_host_ip"
if [ "$VERBOSE" = "1" ]; then if [ "$VERBOSE" = "1" ]; then
printf "old_ip=$old_ip host_ip=$mon_host_ip " printf "${INDENT}old_ip=$old_ip host_ip=$mon_host_ip "
fi fi
# Process input chain # Process input chain
OLDFOUND=0 OLDFOUND=0
if [ -n "$old_ip" ]; then if [ -n "$old_ip" ]; then
get_numeric_ip_version "$mon_host_ip" get_numeric_ip_version "$mon_host_ip"
case $? in case $? in
4) 4)
LCOUNT=0 LCOUNT=0
IFS=$EOL IFS=$EOL
skipping to change at line 244 skipping to change at line 240
# Create entry in accounting file # Create entry in accounting file
echo "$host $mon_host_ip $new_in_value $new_out_value" >>/tmp/traffic-acco unting.new echo "$host $mon_host_ip $new_in_value $new_out_value" >>/tmp/traffic-acco unting.new
if [ "$VERBOSE" = "1" ]; then if [ "$VERBOSE" = "1" ]; then
printf "\n\n" printf "\n\n"
fi fi
done done
done done
# FIXME: Don't use old-file # FIXME: Don't use old-file
if [ -e /var/log/traffic-accounting.log ]; then if [ -f /var/log/traffic-accounting.log ]; then
if [ -e /var/log/traffic-accounting.log.old ]; then if [ -f /var/log/traffic-accounting.log.old ]; then
rm -f /var/log/traffic-accounting.log.old rm -f /var/log/traffic-accounting.log.old
fi fi
mv /var/log/traffic-accounting.log /var/log/traffic-accounting.log.old mv /var/log/traffic-accounting.log /var/log/traffic-accounting.log.old
fi fi
mv /tmp/traffic-accounting.new /var/log/traffic-accounting.log mv /tmp/traffic-accounting.new /var/log/traffic-accounting.log
return $RETVAL return $RETVAL
} }
skipping to change at line 271 skipping to change at line 267
VERBOSE=1 VERBOSE=1
fi fi
# Check where to find the config file # Check where to find the config file
CONF_FILE="" CONF_FILE=""
if [ -n "$PLUGIN_CONF_PATH" ]; then if [ -n "$PLUGIN_CONF_PATH" ]; then
CONF_FILE="$PLUGIN_CONF_PATH/$PLUGIN_CONF_FILE" CONF_FILE="$PLUGIN_CONF_PATH/$PLUGIN_CONF_FILE"
fi fi
# Check if the config file exists # Check if the config file exists
if [ ! -e "$CONF_FILE" ]; then if [ ! -f "$CONF_FILE" ]; then
echo "** ERROR: Config file \"$CONF_FILE\" not found! **" >&2 echo "** ERROR: Config file \"$CONF_FILE\" not found! **" >&2
PLUGIN_RET_VAL=1 PLUGIN_RET_VAL=1
else else
# Source the plugin config file # Source the plugin config file
. "$CONF_FILE" . "$CONF_FILE"
# Only proceed if environment ok # Only proceed if environment ok
if ! traffic_accounting_helper_sanity_check; then if ! traffic_accounting_helper_sanity_check; then
PLUGIN_RET_VAL=1 PLUGIN_RET_VAL=1
else else
 End of changes. 6 change blocks. 
11 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)