diff options
-rw-r--r-- | etc/inc/functions.inc | 10 | ||||
-rw-r--r-- | etc/inc/gwlb.inc | 90 | ||||
-rw-r--r-- | etc/inc/interfaces.inc | 37 | ||||
-rw-r--r-- | etc/inc/pfsense-utils.inc | 45 | ||||
-rw-r--r-- | etc/inc/service-utils.inc | 5 | ||||
-rw-r--r-- | etc/inc/util.inc | 10 |
6 files changed, 96 insertions, 101 deletions
diff --git a/etc/inc/functions.inc b/etc/inc/functions.inc index 678f08c..72382da 100644 --- a/etc/inc/functions.inc +++ b/etc/inc/functions.inc @@ -74,18 +74,18 @@ require_once("auth.inc"); require_once("priv.inc"); require_once("certs.inc"); require_once("crypt.inc"); -require_once("captiveportal.inc"); -require_once("filter.inc"); +require_once("util.inc"); +require_once("gwlb.inc"); require_once("interfaces.inc"); require_once("services.inc"); require_once("system.inc"); -require_once("openvpn.inc"); require_once("pfsense-utils.inc"); -require_once("util.inc"); +require_once("captiveportal.inc"); +require_once("filter.inc"); +require_once("openvpn.inc"); require_once("ipsec.inc"); require_once("vpn.inc"); require_once("vslb.inc"); -require_once("gwlb.inc"); require_once("notices.inc"); require_once("cmd_chain.inc"); require_once("rrd.inc"); diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc index af040d4..e6fb8b1 100644 --- a/etc/inc/gwlb.inc +++ b/etc/inc/gwlb.inc @@ -27,12 +27,6 @@ */ -/* include all configuration functions */ -require_once("functions.inc"); -require_once("pkg-utils.inc"); -require_once("notices.inc"); -require_once("globals.inc"); - /* add static routes for monitor IP addresse * creates monitoring configuration file */ @@ -397,4 +391,86 @@ function dhclient_update_gateway_groups_defaultroute($interface = "wan") { write_config("Updating gateway group gateway for $interface - new gateway is $current_gw"); } -?>
\ No newline at end of file +function lookup_gateway_ip_by_name($name) { + global $config; + if(is_array($config['gateways'])) { + foreach($config['gateways']['gateway_item'] as $gateway) { + if($gateway['name'] == $name) { + $gatewayip = $gateway['gateway']; + //$interfacegw = $gateway['interface']; + return($gatewayip); + } + } + } else { + return(false); + } +} + +function lookup_gateway_monitor_ip_by_name($name) { + global $config; + $gateways_arr = return_gateways_array(); + + foreach($gateways_arr as $gateway) { + if($gateway['name'] == "$name") { + $monitorip = $gateway['monitor']; + if($monitorip == "") + $monitorip = $gateway['gateway']; + + return($monitorip); + } + } + return(false); +} + +function lookup_gateway_interface_by_name($name) { + global $config; + $gateways_arr = return_gateways_array(); + + foreach($gateways_arr as $gateway) { + if($gateway['name'] == "$name") { + $gatewayip = $gateway['gateway']; + $interfacegw = $gateway['interface']; + return($interfacegw); + } + } + return(false); +} + +function get_interface_gateway($interface) { + global $config, $g; + + $iflist = get_configured_interface_with_descr(); + /* + * XXX: BUG: This is silly at first, but we may be called with the interface + * descr for no apparent reason!!! + * Probably one of those silly strtoupper() legacy stuff! + */ + foreach ($iflist as $ifent => $ifdesc) { + if ($ifent == $interface || $ifdesc == $interface) { + $interface = $ifent; + break; + } + } + + $gw = NULL; + + $gwcfg = $config['interfaces'][$interface]; + if (is_ipaddr($gwcfg['gateway'])) + $gw = $gwcfg['gateway']; + else if (!empty($gwcfg['gateway'])) + $gw = lookup_gateway_ip_by_name($gwcfg['gateway']); + + // for dynamic interfaces we handle them through the $interface_router file. + if (!is_ipaddr($gw)) { + $realif = get_real_interface($interface); + if (file_exists("{$g['tmp_path']}/{$realif}_router")) { + $gw = file_get_contents("{$g['tmp_path']}/{$realif}_router"); + $gw = rtrim($gw); + } + } + + /* return gateway */ + return $gw; +} + +?> diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc index 80ab71d..17bef74 100644 --- a/etc/inc/interfaces.inc +++ b/etc/inc/interfaces.inc @@ -2300,43 +2300,6 @@ function get_interface_subnet($interface = "wan") { return null; } -function get_interface_gateway($interface) { - global $config, $g; - - $iflist = get_configured_interface_with_descr(); - /* - * XXX: BUG: This is silly at first, but we may be called with the interface - * descr for no apparent reason!!! - * Probably one of those silly strtoupper() legacy stuff! - */ - foreach ($iflist as $ifent => $ifdesc) { - if ($ifent == $interface || $ifdesc == $interface) { - $interface = $ifent; - break; - } - } - - $gw = NULL; - - $gwcfg = $config['interfaces'][$interface]; - if (is_ipaddr($gwcfg['gateway'])) - $gw = $gwcfg['gateway']; - else if (!empty($gwcfg['gateway'])) - $gw = lookup_gateway_ip_by_name($gwcfg['gateway']); - - // for dynamic interfaces we handle them through the $interface_router file. - if (!is_ipaddr($gw)) { - $realif = get_real_interface($interface); - if (file_exists("{$g['tmp_path']}/{$realif}_router")) { - $gw = file_get_contents("{$g['tmp_path']}/{$realif}_router"); - $gw = rtrim($gw); - } - } - - /* return gateway */ - return $gw; -} - /* return outside interfaces with a gateway */ function get_interfaces_with_gateway() { global $config; diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index c814dac..e74429d 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -2776,51 +2776,6 @@ function pfsense_default_state_size() { return $max_states; } -function lookup_gateway_ip_by_name($name) { - global $config; - if(is_array($config['gateways'])) { - foreach($config['gateways']['gateway_item'] as $gateway) { - if($gateway['name'] == $name) { - $gatewayip = $gateway['gateway']; - //$interfacegw = $gateway['interface']; - return($gatewayip); - } - } - } else { - return(false); - } -} - -function lookup_gateway_monitor_ip_by_name($name) { - global $config; - $gateways_arr = return_gateways_array(); - - foreach($gateways_arr as $gateway) { - if($gateway['name'] == "$name") { - $monitorip = $gateway['monitor']; - if($monitorip == "") - $monitorip = $gateway['gateway']; - - return($monitorip); - } - } - return(false); -} - -function lookup_gateway_interface_by_name($name) { - global $config; - $gateways_arr = return_gateways_array(); - - foreach($gateways_arr as $gateway) { - if($gateway['name'] == "$name") { - $gatewayip = $gateway['gateway']; - $interfacegw = $gateway['interface']; - return($interfacegw); - } - } - return(false); -} - /****f* pfsense-utils/safe_write_file * NAME * safe_write_file - Write a file out atomically diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 3b1cfa5..6c10017 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -137,11 +137,6 @@ function restart_service($name) { } } -function is_process_running($process) { - $running = (trim(shell_exec("ps axwu | grep '\b{$process}\b' | grep -v 'grep'")) != ''); - return $running; -} - function is_pid_running($pidfile) { $pid = trim(file_get_contents($pidfile)); $running = (trim(shell_exec("ps axwu | grep '\b{$pid}\b' | grep -v 'grep'")) != ''); diff --git a/etc/inc/util.inc b/etc/inc/util.inc index 7c31ca5..b1d875e 100644 --- a/etc/inc/util.inc +++ b/etc/inc/util.inc @@ -40,9 +40,15 @@ function isvalidpid($pid) { return false; } +function is_process_running($process) { + $running = (trim(shell_exec("ps axwu | grep '\b{$process}\b' | grep -v 'grep'")) != ''); + + return $running; +} + function isvalidproc($proc) { - $running = `ps awux | grep $proc | grep -v grep | wc -l`; - if(intval($running) >= 1) + $running = is_process_running($proc); + if (intval($running) >= 1) return true; else return false; |