From 8d97b2ad32ec9acfdf5a81850a9eb2a2b09dd615 Mon Sep 17 00:00:00 2001 From: Eneko Nieto Date: Mon, 19 Apr 2021 18:08:22 +0200 Subject: [PATCH] bugfix: iptables wait for lock --- README.md | 4 ++++ limitator | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index de3b9c5..8e75788 100644 --- a/README.md +++ b/README.md @@ -13,3 +13,7 @@ 9) Run `crontab -e` and copy&paste contents in `crontab` file. 10) Run `/etc/init.d/limitator enable` 11) Reboot. + +### Additional steps for Backfire 10.03 +1) Install iptables-mod-ipopt +2) Delete /bin/date link diff --git a/limitator b/limitator index 4f21479..bde5e1d 100644 --- a/limitator +++ b/limitator @@ -111,6 +111,7 @@ del_iptables_rule(){ [ -n "$(echo $line|grep -E ^[[:digit:]]+$)" ] && iptables -D $chain_name $line || break done done + iptables -D $IPTABLES_FORWARD 1 iptables -X $IPTABLES_CHAIN } @@ -124,15 +125,15 @@ set_iptables_rule(){ iptables -I $IPTABLES_CHAIN 3 -s $EXCLUDE_NETWORK2 -j ACCEPT iptables -I $IPTABLES_CHAIN 4 -d $EXCLUDE_NETWORK2 -j ACCEPT fi - iptables -I $IPTABLES_CHAIN $(get_iptables_quota_rule_num) -c 0 $(get_saved_used_bytes) -m quota --quota $(get_remaining_quota) -j ACCEPT - iptables -I $IPTABLES_CHAIN $(($(get_iptables_quota_rule_num) + 1)) -j REJECT + iptables -I --wait $IPTABLES_CHAIN $(get_iptables_quota_rule_num) -c 0 $(get_saved_used_bytes) -m quota --quota $(get_remaining_quota) -j ACCEPT 2>> $LOG_FILE + iptables -I --wait $IPTABLES_CHAIN $(($(get_iptables_quota_rule_num) + 1)) -j REJECT 2>> $LOG_FILE # Iptables requires UTC time local start_time_utc=$(date -u +%H:%M --date=@$(date -d "today $START_TIME" +%s)) local end_time_utc=$(date -u +%H:%M --date=@$(date -d "today $END_TIME" +%s)) - iptables -I $IPTABLES_FORWARD -i $WAN_DEV ! -s $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN - iptables -I $IPTABLES_FORWARD -o $WAN_DEV ! -d $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN + iptables -I $IPTABLES_FORWARD 1 -d $INTRANET -s $INTRANET -j ACCEPT + iptables -I $IPTABLES_FORWARD 2 -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN iptables -I $IPTABLES_INPUT -i $WAN_DEV ! -s $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN iptables -I $IPTABLES_OUTPUT -o $WAN_DEV ! -d $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN }