net/relayd: more tweaks

* Apply should reconfigure, it takes care of start stop reload
  according to the mutable service settings.
* ; exit 0 on stop was caused by spurious apply.  Fixed by doing
  reconfigure (see above).
* Add service control to status and log page.
* Spacing for spinner icons in buttons.
* Apply spins until reconfigured.

From my side this is ready for release in 18.1.7 when the legacy
model migration works fine.  There is one change for this in core
that is not in 18.1.6 that prevents earlier merge.

CC: @fbrendel
This commit is contained in:
Franco Fichtner
2018-04-05 16:25:10 +00:00
parent d2bae5b76e
commit f6aa805ca1
8 changed files with 57 additions and 56 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
PLUGIN_NAME= relayd
PLUGIN_VERSION= 2.0.d
PLUGIN_REVISION= 5
PLUGIN_REVISION= 6
PLUGIN_DEPENDS= relayd
PLUGIN_COMMENT= Relayd Load Balancer
PLUGIN_MAINTAINER= frank.brendel@eurolog.com
+25 -24
View File
@@ -1,32 +1,30 @@
<?php
/**
* Copyright (C) 2018 EURO-LOG AG
* Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
/*
* Copyright (C) 2018 EURO-LOG AG
* Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
* All rights reserved.
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 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.
*
* 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.
* 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.
*/
function relayd_enabled()
@@ -34,7 +32,7 @@ function relayd_enabled()
global $config;
return isset($config['OPNsense']['relayd']['general']['enabled']) &&
$config['OPNsense']['relayd']['general']['enabled'] == 1;
$config['OPNsense']['relayd']['general']['enabled'] == 1;
}
function relayd_firewall($fw)
@@ -48,7 +46,9 @@ function relayd_firewall($fw)
function relayd_services()
{
global $config;
$services = array();
if (relayd_enabled()) {
$services[] = array(
'description' => gettext('Relayd'),
@@ -60,6 +60,7 @@ function relayd_services()
'name' => 'relayd',
);
}
return $services;
}
@@ -1,31 +1,29 @@
<?php
/**
* Copyright (C) 2018 EURO-LOG AG
/*
* Copyright (C) 2018 EURO-LOG AG
* All rights reserved.
*
* All rights reserved.
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 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.
*
* 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.
* 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.
*/
namespace OPNsense\Relayd\Api;
@@ -195,11 +195,9 @@ class SettingsController extends ApiControllerBase
$result['result'] = 'ok';
$this->mdlRelayd->serializeToConfig();
Config::getInstance()->save();
if ($nodeType == 'general' &&
isset($relaydInfo[$nodeType]['enabled']) &&
$relaydInfo[$nodeType]['enabled'] == '0') {
if ($nodeType == 'general') {
$svcRelayd = new ServiceController();
$result = $svcRelayd->stopAction();
$result = $svcRelayd->reconfigureAction();
}
}
}
@@ -43,6 +43,7 @@ POSSIBILITY OF SUCH DAMAGE.
$('#btnReload').unbind('click').click(function(){
$('#btnReloadProgress').addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/relayd/service/reconfigure", sendData={}, callback=function(data,status) {
updateServiceControlUI('relayd');
$('#btnReloadProgress').removeClass("fa fa-spinner fa-pulse");
$('#btnReload').blur();
$("#responseMsg").removeClass("hidden");
@@ -62,10 +63,10 @@ POSSIBILITY OF SUCH DAMAGE.
$("#frm_GeneralSettings_progress").addClass("fa fa-spinner fa-pulse");
var frm_id = 'frm_GeneralSettings';
saveFormToEndpoint(url = "/api/relayd/settings/set/general/",formid=frm_id,callback_ok=function(){
$("#"+frm_id+"_progress").removeClass("fa fa-spinner fa-pulse");
$("#btn_ApplyGeneralSettings").blur();
updateServiceControlUI('relayd');
});
$("#"+frm_id+"_progress").removeClass("fa fa-spinner fa-pulse");
$("#btn_ApplyGeneralSettings").blur();
});
$("#grid-host").UIBootgrid({
@@ -332,8 +333,8 @@ POSSIBILITY OF SUCH DAMAGE.
</div>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="btnConfigTest" type="button"><b>{{ lang._('Test Configuration') }}</b><i id="btnConfigTestProgress" class=""></i></button>
<button class="btn btn-primary" id="btnReload" type="button"><b>{{ lang._('Reload Configuration') }}</b><i id="btnReloadProgress" class=""></i></button>
<button class="btn btn-primary" id="btnConfigTest" type="button"><b>{{ lang._('Test Configuration') }}</b> <i id="btnConfigTestProgress"></i></button>
<button class="btn btn-primary" id="btnReload" type="button"><b>{{ lang._('Reload Configuration') }}</b> <i id="btnReloadProgress"></i></button>
<br/>
<br/>
</div>
@@ -28,6 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
<script type="text/javascript">
$( document ).ready(function() {
updateServiceControlUI('relayd');
// get status and build the table body
$('#btnRefresh').unbind('click').click(function() {
ajaxCall(url = "/api/relayd/status/sum", sendData={}, callback = function(result, status) {
@@ -4,7 +4,7 @@ type:script
message:starting relayd
[stop]
command:/usr/local/etc/rc.d/relayd stop; exit 0
command:/usr/local/etc/rc.d/relayd stop
type:script
message:stopping relayd
+2
View File
@@ -3,4 +3,6 @@
$logfile = '/var/log/relayd.log';
$logclog = true;
$service_hook = 'relayd';
require_once 'diag_logs_template.inc';