From 7e576663b854afbdb8ecffe38f0e6b0b012a5ead Mon Sep 17 00:00:00 2001 From: Eneko Nieto Date: Fri, 9 Jul 2021 11:14:38 +0200 Subject: [PATCH] EXCLUDE_NETWORK3 --- limitator | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/limitator b/limitator index 26f2368..dd64e8e 100644 --- a/limitator +++ b/limitator @@ -19,6 +19,7 @@ config_get END_TIME limitator end_time '23:00' # Ending time of internet plan li 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. +config_get EXCLUDE_NETWORK3 limitator exclude_network3 # Traffic originated in specified network does not count for quota. config_get USED_BYTES_FILE limitator used_bytes_file '/root/limitator/used_bytes' # A persistent file to save used bytes value. config_get LOG_FILE limitator log_file '/root/limitator/log' # A persistent file to log. config_get IPTABLES_CHAIN limitator iptables_chain 'LIMITATOR' # Name of iptables chain. @@ -39,7 +40,11 @@ get_saved_used_bytes(){ get_iptables_quota_rule_num(){ if [ -n "$EXCLUDE_NETWORK" ];then if [ -n "$EXCLUDE_NETWORK2" ];then - echo -n 5 + if [ -n "$EXCLUDE_NETWORK3" ];then + echo -n 7 + else + echo -n 5 + fi else echo -n 3 fi @@ -125,6 +130,10 @@ set_iptables_rule(){ iptables -I $IPTABLES_CHAIN 3 -s $EXCLUDE_NETWORK2 -j ACCEPT iptables -I $IPTABLES_CHAIN 4 -d $EXCLUDE_NETWORK2 -j ACCEPT fi + if [ -n "$EXCLUDE_NETWORK3" ];then + iptables -I $IPTABLES_CHAIN 5 -s $EXCLUDE_NETWORK3 -j ACCEPT + iptables -I $IPTABLES_CHAIN 6 -d $EXCLUDE_NETWORK3 -j ACCEPT + fi 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