/** * reconfigure IDS */ public function reconfigureAction() { $status = "failed"; if ($this->request->isPost()) { // close session for long running action $this->sessionClose(); $mdlIDS = new IDS(); $runStatus = $this->statusAction(); // we should always have a cron item configured for IDS, let's create one upon first reconfigure. if ((string) $mdlIDS->general->UpdateCron == "") { $mdlCron = new Cron(); // update cron relation (if this doesn't break consistency) $mdlIDS->general->UpdateCron = $mdlCron->newDailyJob("IDS", "ids update", "ids rule updates", "0"); if ($mdlCron->performValidation()->count() == 0) { $mdlCron->serializeToConfig(); // save data to config, do not validate because the current in memory model doesn't know about the // cron item just created. $mdlIDS->serializeToConfig($validateFullModel = false, $disable_validation = true); Config::getInstance()->save(); } } if ($runStatus['status'] == "running" && (string) $mdlIDS->general->enabled == 0) { $this->stopAction(); } $backend = new Backend(); $bckresult = trim($backend->configdRun("template reload OPNsense.IDS")); if ($bckresult == "OK") { if ((string) $mdlIDS->general->enabled == 1) { $bckresult = trim($backend->configdRun("ids install rules")); if ($bckresult == "OK") { if ($runStatus['status'] == 'running') { $status = $this->restartAction()['response']; } else { $status = $this->startAction()['response']; } } else { $status = "error installing ids rules (" . $bckresult . ")"; } } else { $status = "OK"; } } else { $status = "error generating ids template (" . $bckresult . ")"; } } return array("status" => $status); }
/** * create new cron item for remote acl or return already available one * @return array status action */ public function fetchRBCronAction() { $result = array("result" => "failed"); if ($this->request->isPost()) { $mdlProxy = new Proxy(); if ((string) $mdlProxy->forward->acl->remoteACLs->UpdateCron == "") { $mdlCron = new Cron(); // update cron relation (if this doesn't break consistency) $uuid = $mdlCron->newDailyJob("Proxy", "proxy fetchacls", "fetch proxy acls", "1"); $mdlProxy->forward->acl->remoteACLs->UpdateCron = $uuid; if ($mdlCron->performValidation()->count() == 0) { $mdlCron->serializeToConfig(); // save data to config, do not validate because the current in memory model doesn't know about the // cron item just created. $mdlProxy->serializeToConfig($validateFullModel = false, $disable_validation = true); Config::getInstance()->save(); $result['result'] = "new"; $result['uuid'] = $uuid; } else { $result['result'] = "unable to add cron"; } } else { $result['result'] = "existing"; $result['uuid'] = (string) $mdlProxy->forward->acl->remoteACLs->UpdateCron; } } return $result; }