Time limitation re-enabled
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
config limitator 'limitator'
|
||||
option monthly_quota '90'
|
||||
option wan_dev 'eth1.1'
|
||||
option exclude_network '10.0.2.0/24'
|
||||
option exclude_network '10.0.3.0/24'
|
||||
option iptables_forward 'FORWARD'
|
||||
option iptables_input 'INPUT'
|
||||
option iptables_output 'OUTPUT'
|
||||
15
limitator
15
limitator
@@ -13,7 +13,9 @@ EOF
|
||||
config_load "limitator"
|
||||
config_get MONTHLY_QUOTA limitator quota 15 # Monthly quota in GB
|
||||
config_get WAN_DEV limitator wan_dev 'wlan0' # Interface name for WAN
|
||||
config_get FIRST_DAY limitator first_day 13 # Day of month when internet plan starts accounting.
|
||||
config_get FIRST_DAY limitator first_day 13 # Day of month when internet plan starts accounting..
|
||||
config_get START_TIME limitator start_time '08:00' # Starting time of internet plan limited hours.
|
||||
config_get END_TIME limitator end_time '22:00' # Ending time of internet plan limited hours.
|
||||
config_get INTRANET limitator intranet '10.0.0.0/8' # Traffic in Intranet does not count for quota.
|
||||
config_get EXCLUDE_NETWORK limitator exclude_network # Traffic originated in specified network does not count for quota.
|
||||
config_get EXCLUDE_NETWORK2 limitator exclude_network2 # Traffic originated in specified network does not count for quota.
|
||||
@@ -135,10 +137,15 @@ set_iptables_rule(){
|
||||
iptables --wait -I $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 --wait -I $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 --wait -I $IPTABLES_FORWARD 1 -d $INTRANET -s $INTRANET -j ACCEPT
|
||||
iptables --wait -I $IPTABLES_FORWARD 2 -j $IPTABLES_CHAIN
|
||||
iptables --wait -I $IPTABLES_INPUT -i $WAN_DEV ! -s $INTRANET -j $IPTABLES_CHAIN
|
||||
iptables --wait -I $IPTABLES_OUTPUT -o $WAN_DEV ! -d $INTRANET -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_OUTPUT -o $WAN_DEV ! -d $INTRANET -m time --timestart $start_time_utc --timestop $end_time_utc -j $IPTABLES_CHAIN
|
||||
}
|
||||
|
||||
start() {
|
||||
|
||||
Reference in New Issue
Block a user