Commit 64ee69be authored by Ad Schellevis's avatar Ad Schellevis

(legacy) cleanup gwlb.inc

parent 3f6f524a
...@@ -912,20 +912,6 @@ function lookup_gateway_ip_by_name($name) { ...@@ -912,20 +912,6 @@ function lookup_gateway_ip_by_name($name) {
return false; return false;
} }
function lookup_gateway_monitor_ip_by_name($name) {
$gateways_arr = return_gateways_array(false, true);
if (!empty($gateways_arr[$name])) {
$gateway = $gateways_arr[$name];
if(!is_ipaddr($gateway['monitor']))
return $gateway['gateway'];
return $gateway['monitor'];
}
return (false);
}
function lookup_gateway_interface_by_name($name) { function lookup_gateway_interface_by_name($name) {
$gateways_arr = return_gateways_array(false, true); $gateways_arr = return_gateways_array(false, true);
...@@ -1049,48 +1035,5 @@ function validate_address_family($ipaddr, $gwname) { ...@@ -1049,48 +1035,5 @@ function validate_address_family($ipaddr, $gwname) {
return false; return false;
} }
function gateway_is_gwgroup_member($name) {
global $config;
if (is_array($config['gateways']['gateway_group']))
$groups = $config['gateways']['gateway_group'];
else
return false;
$members = array();
foreach($groups as $group) {
if (is_array($group['item'])) {
foreach($group['item'] as $item) {
$elements = explode("|", $item);
$gwname = $elements[0];
if ($name == $elements[0])
$members[] = $group['name'];
}
}
}
return $members;
}
/**
* check if apinger service is enabled
*/
function is_apinger_enabled() {
global $config;
$gwcount=0;
if (isset($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gwkey => $gateway) {
if (!isset($gateway['monitor_disable']) || $gateway['monitor_disable'] == "0") {
$gwcount += 1;
}
}
}
if ($gwcount == 0) {
return false;
} else {
return true;
}
}
?> ?>
...@@ -2408,6 +2408,28 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont ...@@ -2408,6 +2408,28 @@ function install_cron_job($command, $active=false, $minute="0", $hour="*", $mont
configure_cron(); configure_cron();
} }
/**
* check if apinger service is enabled
*/
function is_apinger_enabled() {
global $config;
$gwcount=0;
if (isset($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gwkey => $gateway) {
if (!isset($gateway['monitor_disable']) || $gateway['monitor_disable'] == "0") {
$gwcount += 1;
}
}
}
if ($gwcount == 0) {
return false;
} else {
return true;
}
}
function get_services() { function get_services() {
global $config; global $config;
$services = array(); $services = array();
......
...@@ -36,6 +36,31 @@ require_once("filter.inc"); ...@@ -36,6 +36,31 @@ require_once("filter.inc");
require_once("gwlb.inc"); require_once("gwlb.inc");
require_once("openvpn.inc"); require_once("openvpn.inc");
function gateway_is_gwgroup_member($name) {
global $config;
if (is_array($config['gateways']['gateway_group']))
$groups = $config['gateways']['gateway_group'];
else
return false;
$members = array();
foreach($groups as $group) {
if (is_array($group['item'])) {
foreach($group['item'] as $item) {
$elements = explode("|", $item);
$gwname = $elements[0];
if ($name == $elements[0])
$members[] = $group['name'];
}
}
}
return $members;
}
function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) { function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
global $g, $config; global $g, $config;
......
...@@ -29,6 +29,21 @@ ...@@ -29,6 +29,21 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
function lookup_gateway_monitor_ip_by_name($name) {
$gateways_arr = return_gateways_array(false, true);
if (!empty($gateways_arr[$name])) {
$gateway = $gateways_arr[$name];
if(!is_ipaddr($gateway['monitor']))
return $gateway['gateway'];
return $gateway['monitor'];
}
return (false);
}
if (!is_array($config['gateways'])) { if (!is_array($config['gateways'])) {
$config['gateways'] = array(); $config['gateways'] = array();
} }
......
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