system: provided by legacy bindings are facilities...

... which are bound to MVC code.  Move remaining "pure" gateway
functions to the legacy_bindings and use plugins_run() stub to
get to the dpinger data...  The data could later be coalesced
or split up, but for now that seems reasonable enough (provided
it works ok and @adschellevis more or less likes this direction).
This commit is contained in:
Franco Fichtner 2019-04-21 19:27:45 +02:00
parent 0e8943c94a
commit 168be32071
4 changed files with 41 additions and 25 deletions

View File

@ -31,7 +31,6 @@
*/
require_once("interfaces.lib.inc");
require_once("plugins.inc.d/dpinger.inc"); /* XXX remove me */
/*
* converts a string like "a,b,c,d"

View File

@ -159,3 +159,36 @@ function get_alias_description($name)
{
return OPNsense\Firewall\Util::aliasDescription($name);
}
function return_gateways_status()
{
/* XXX quick and dirty compat layer */
$result = plugins_run('return_gateways_status');
if (!empty($result['dpinger'])) {
return $result['dpinger'];
}
return [];
}
function return_down_gateways()
{
$result = array();
foreach (return_gateways_status() as $gwname => $stat) {
if (strpos($stat['status'], 'down') !== false) {
$result[] = $gwname;
}
}
return $result ;
}
/*
* Return an array with all gateway groups with name as key
* All gateway groups will be processed before returning the array.
*/
function return_gateway_groups_array()
{
$gateways = new \OPNsense\Routing\Gateways(legacy_interfaces_details());
return $gateways->getGroups(return_gateways_status());
}

View File

@ -298,7 +298,14 @@ function dpinger_configure_do($verbose = false, $gwname = null)
}
}
function return_gateways_status()
function dpinger_run()
{
return array(
'return_gateways_status' => array('dpinger_status'),
);
}
function dpinger_status($verbose = false, $status)
{
$status = array();
@ -396,27 +403,6 @@ function return_gateways_status()
return $status;
}
function return_down_gateways()
{
$result = array();
foreach (return_gateways_status() as $gwname => $stat) {
if (strpos($stat['status'], 'down') !== false) {
$result[] = $gwname;
}
}
return $result ;
}
/*
* Return an array with all gateway groups with name as key
* All gateway groups will be processed before returning the array.
*/
function return_gateway_groups_array()
{
$gateways = new \OPNsense\Routing\Gateways(legacy_interfaces_details());
return $gateways->getGroups(return_gateways_status());
}
function dpinger_processes()
{
$result = array();

View File

@ -28,9 +28,7 @@
*/
require_once('config.inc');
require_once('interfaces.inc');
require_once('util.inc');
require_once('plugins.inc.d/dpinger.inc'); /* XXX remove me */
/**
* @param string $status