diff --git a/plist b/plist index 0d40b64f6..96d139663 100644 --- a/plist +++ b/plist @@ -621,7 +621,7 @@ /usr/local/opnsense/scripts/proxy/generate_cert.php /usr/local/opnsense/scripts/proxy/setup.sh /usr/local/opnsense/scripts/remote_backup.php -/usr/local/opnsense/scripts/routes/routes_wrapper +/usr/local/opnsense/scripts/routes/gateways.php /usr/local/opnsense/scripts/routes/show_routes.py /usr/local/opnsense/scripts/suricata/__init__.py /usr/local/opnsense/scripts/suricata/dropAlertLog.py diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php index ce4b65915..bda5b0da5 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Routes/Api/RoutesController.php @@ -1,32 +1,32 @@ getNodeByReference('route.'.$uuid); if ($node != null) { - $this->backend_execute_route('delete', $node); $node->setNodes($this->request->getPost('route')); $validations = $mdlRoute->validate($node->__reference, 'route'); if (count($validations)) { @@ -68,9 +67,6 @@ class RoutesController extends ApiControllerBase } else { // serialize model to config and save $mdlRoute->serializeToConfig(); - if ((string)$node->disabled != '1') { - $this->backend_execute_route('add', $node); - } Config::getInstance()->save(); $result['result'] = 'saved'; } @@ -94,9 +90,6 @@ class RoutesController extends ApiControllerBase // serialize model to config and save $mdlRoute->serializeToConfig(); Config::getInstance()->save(); - if ((string)$node->disabled != '1') { - $this->backend_execute_route('add', $node); - } $result['result'] = 'saved'; } } @@ -131,9 +124,6 @@ class RoutesController extends ApiControllerBase $mdlRoute->serializeToConfig(); Config::getInstance()->save(); $result['result'] = 'deleted'; - if ((string)$node->disabled != '1') { - $this->backend_execute_route('delete', $node); - } } else { $result['result'] = 'not found'; } @@ -152,10 +142,8 @@ class RoutesController extends ApiControllerBase $node->disabled = (string)$disabled; } elseif ($node->disabled->__toString() == '1') { $node->disabled = '0'; - $this->backend_execute_route('add', $node); } else { $node->disabled = '1'; - $this->backend_execute_route('delete', $node); } $result['result'] = (string)$node->disabled == '1' ? 'Disabled' : 'Enabled'; // if item has toggled, serialize to config and save @@ -165,10 +153,24 @@ class RoutesController extends ApiControllerBase } return $result; } - private function backend_execute_route($action, $node) + + public function reconfigureAction() { - $backend = new Backend(); - $command = "interface routes $action " . $node->network . ' ' . $node->gateway; - $backend->configdRun($command, false); + if ($this->request->isPost()) { + // close session for long running action + $this->sessionClose(); + + $backend = new Backend(); + $bckresult = trim($backend->configdRun('interface routes configure')); + if ($bckresult == 'OK') { + $status = 'ok'; + } else { + $status = "error reloading routes ($bckresult)"; + } + + return array('status' => $status); + } else { + return array('status' => 'failed'); + } } } diff --git a/src/opnsense/mvc/app/views/OPNsense/Routes/index.volt b/src/opnsense/mvc/app/views/OPNsense/Routes/index.volt index c75f37f57..a95c3c8b5 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Routes/index.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Routes/index.volt @@ -1,3 +1,56 @@ +{# + +Copyright (c) 2017 Fabian Franz +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, +INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY +AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, +OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. + +#} + + +
| - |
{{ lang._('Do not enter static routes for networks assigned on any interface of this firewall. Static routes are only used for networks reachable via a different router, and not reachable via your default gateway.')}}
+