Commit 1ac3f123 authored by Ad Schellevis's avatar Ad Schellevis

flush ipfw when captiveportal is disabled

parent f3d9e10b
......@@ -152,6 +152,27 @@ class CPClient {
}
}
/**
* check if captiveportal is enabled (traverse zones, if none active return false )
* @return bool
*/
public function isEnabled()
{
$enabled_zones = 0 ;
foreach ($this->config->object()->captiveportal->children() as $cpzonename => $zone) {
if (isset($zone->enable)) {
$enabled_zones++;
}
}
if ($enabled_zones > 0) {
return true;
} else {
return false ;
}
}
/**
*
* @param $zoneid
......@@ -255,7 +276,9 @@ class CPClient {
/**
* Reconfigure zones ( generate and load ruleset )
*/
public function reconfigure(){
public function reconfigure()
{
if ( $this->isEnabled() ) {
$ruleset_filename = \Phalcon\DI\FactoryDefault::getDefault()->get('config')->globals->temp_path."/ipfw.rules";
$this->rules->generate($ruleset_filename);
......@@ -267,6 +290,10 @@ class CPClient {
// after reinit all accounting rules are vanished, reapply them for active sessions
$this->loadAccounting();
} else {
// captiveportal is disabled, flush all rules to be sure
$this->shell->exec("/sbin/ipfw -f flush" );
}
}
/**
......
......@@ -294,7 +294,6 @@ class Rules {
}
/**
* load ruleset
*/
......
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