bugfix: iptables wait for lock

This commit is contained in:
2021-04-19 18:08:22 +02:00
parent 12b8bdbc25
commit 8d97b2ad32
2 changed files with 9 additions and 4 deletions

View File

@@ -13,3 +13,7 @@
9) Run `crontab -e` and copy&paste contents in `crontab` file. 9) Run `crontab -e` and copy&paste contents in `crontab` file.
10) Run `/etc/init.d/limitator enable` 10) Run `/etc/init.d/limitator enable`
11) Reboot. 11) Reboot.
### Additional steps for Backfire 10.03
1) Install iptables-mod-ipopt
2) Delete /bin/date link

View File

@@ -111,6 +111,7 @@ del_iptables_rule(){
[ -n "$(echo $line|grep -E ^[[:digit:]]+$)" ] && iptables -D $chain_name $line || break [ -n "$(echo $line|grep -E ^[[:digit:]]+$)" ] && iptables -D $chain_name $line || break
done done
done done
iptables -D $IPTABLES_FORWARD 1
iptables -X $IPTABLES_CHAIN 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 3 -s $EXCLUDE_NETWORK2 -j ACCEPT
iptables -I $IPTABLES_CHAIN 4 -d $EXCLUDE_NETWORK2 -j ACCEPT iptables -I $IPTABLES_CHAIN 4 -d $EXCLUDE_NETWORK2 -j ACCEPT
fi 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 --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 $IPTABLES_CHAIN $(($(get_iptables_quota_rule_num) + 1)) -j REJECT iptables -I --wait $IPTABLES_CHAIN $(($(get_iptables_quota_rule_num) + 1)) -j REJECT 2>> $LOG_FILE
# Iptables requires UTC time # Iptables requires UTC time
local start_time_utc=$(date -u +%H:%M --date=@$(date -d "today $START_TIME" +%s)) 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)) 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 1 -d $INTRANET -s $INTRANET -j ACCEPT
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 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_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 iptables -I $IPTABLES_OUTPUT -o $WAN_DEV ! -d $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN
} }