Commit 7086992b authored by Franco Fichtner's avatar Franco Fichtner

filter: localise time_based_rules variable usage

Even though we take a hit for running through the filter rules
array again, it's the first step for sidestepping the need to
use the config to inject our cron job and flush the rules in
mid-reload...
parent c43fcea6
...@@ -30,9 +30,6 @@ ...@@ -30,9 +30,6 @@
POSSIBILITY OF SUCH DAMAGE. POSSIBILITY OF SUCH DAMAGE.
*/ */
/* For installing cron job of schedules */
$time_based_rules = false;
/* Create a global array to avoid errors on rulesets. */ /* Create a global array to avoid errors on rulesets. */
$GatewaysList = array(); $GatewaysList = array();
...@@ -162,11 +159,14 @@ function filter_delete_states_for_down_gateways() ...@@ -162,11 +159,14 @@ function filter_delete_states_for_down_gateways()
function filter_configure_sync() function filter_configure_sync()
{ {
global $config, $time_based_rules, $filterdns, $aliases; global $config, $filterdns, $aliases;
/* holds the tables to be flushed *AFTER* the filter is fully loaded */ /* holds the tables to be flushed *AFTER* the filter is fully loaded */
$after_filter_configure_run = array(); $after_filter_configure_run = array();
/* For installing cron job of schedules */
$time_based_rules = false;
$FilterIflist = filter_generate_optcfg_array(); $FilterIflist = filter_generate_optcfg_array();
/* Use filter lock to not allow concurrent filter reloads during this run. */ /* Use filter lock to not allow concurrent filter reloads during this run. */
...@@ -364,10 +364,14 @@ function filter_configure_sync() ...@@ -364,10 +364,14 @@ function filter_configure_sync()
} }
/* if time based rules are enabled then swap in the set */ /* if time based rules are enabled then swap in the set */
if ($time_based_rules == true) { if (isset($config['filter']['rule'])) {
filter_tdr_install_cron(true); foreach ($config['filter']['rule'] as $rule) {
} else { if (isset($rule['sched']) && !empty($rule['sched'])) {
filter_tdr_install_cron(false); $time_based_rules = true;
break;
}
}
filter_tdr_install_cron($time_based_rules);
} }
if (file_exists("/var/run/booting")) { if (file_exists("/var/run/booting")) {
...@@ -2748,7 +2752,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule) ...@@ -2748,7 +2752,7 @@ function filter_generate_user_rule(&$FilterIflist, $rule)
function filter_rules_generate(&$FilterIflist) function filter_rules_generate(&$FilterIflist)
{ {
global $config, $time_based_rules, $GatewaysList; global $config, $GatewaysList;
$fix_rule_label = 'fix_rule_label'; $fix_rule_label = 'fix_rule_label';
...@@ -3248,9 +3252,6 @@ EOD; ...@@ -3248,9 +3252,6 @@ EOD;
$rule_arr3[] = filter_generate_user_rule_arr($FilterIflist, $rule); $rule_arr3[] = filter_generate_user_rule_arr($FilterIflist, $rule);
} }
} }
if (isset($rule['sched']) && !empty($rule['sched'])) {
$time_based_rules = true;
}
} }
$ipfrules .= "\n# User-defined rules follow\n"; $ipfrules .= "\n# User-defined rules follow\n";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment