mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
(legacy) cleanup gwlb.inc
This commit is contained in:
parent
3f6f524a17
commit
64ee69be77
@ -912,20 +912,6 @@ function lookup_gateway_ip_by_name($name) {
|
||||
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) {
|
||||
|
||||
$gateways_arr = return_gateways_array(false, true);
|
||||
@ -1049,48 +1035,5 @@ function validate_address_family($ipaddr, $gwname) {
|
||||
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
|
||||
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() {
|
||||
global $config;
|
||||
$services = array();
|
||||
|
||||
@ -36,6 +36,31 @@ require_once("filter.inc");
|
||||
require_once("gwlb.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) {
|
||||
global $g, $config;
|
||||
|
||||
|
||||
@ -29,6 +29,21 @@
|
||||
|
||||
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'])) {
|
||||
$config['gateways'] = array();
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user