diff --git a/src/etc/inc/interfaces.inc b/src/etc/inc/interfaces.inc index 34551e77d..d92d8c9f6 100644 --- a/src/etc/inc/interfaces.inc +++ b/src/etc/inc/interfaces.inc @@ -4482,28 +4482,6 @@ function is_ipaddr_configured($ipaddr, $ignore_if = '') } } -/* - * get_carp_interface_status($carpinterface): returns the status of a carp ip - */ -function get_carp_interface_status($carpinterface) -{ - $carp_query = []; - - /* XXX: Need to find a better way for this! */ - list ($interface, $vhid) = explode("_vip", $carpinterface); - $interface = get_real_interface($interface); - exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/grep 'vhid {$vhid}'", $carp_query); - foreach ($carp_query as $int) { - if (stristr($int, "MASTER")) { - return gettext("MASTER"); - } elseif (stristr($int, "BACKUP")) { - return gettext("BACKUP"); - } elseif (stristr($int, "INIT")) { - return gettext("INIT"); - } - } - return gettext('DISABLED'); -} function make_ipv6_64_address($prefix, $suffix) { diff --git a/src/etc/inc/plugins.inc.d/openvpn.inc b/src/etc/inc/plugins.inc.d/openvpn.inc index 88a870e78..726d612cb 100644 --- a/src/etc/inc/plugins.inc.d/openvpn.inc +++ b/src/etc/inc/plugins.inc.d/openvpn.inc @@ -898,11 +898,17 @@ function openvpn_restart($mode, $settings, $carp_event = false) } if ( - strstr($settings['interface'], '_vip') && $mode == 'client' && - get_carp_interface_status($settings['interface']) == gettext('BACKUP') + strstr($settings['interface'], '_vip') && $mode == 'client' ) { - /* do not restart a client if we are a CARP backup instance */ - return; + list ($interface, $vhid) = explode("_vip", $settings['interface']); + $interface_details = legacy_interface_details(get_real_interface($interface)); + if ( + !empty($interface_details) && !empty($interface_details['carp'][$vhid]) && + $interface_details['carp'][$vhid]['status'] == 'BACKUP' + ) { + /* do not restart a client if we are a CARP backup instance */ + return; + } } @unlink("/var/etc/openvpn/{$mode_id}.sock"); diff --git a/src/www/carp_status.php b/src/www/carp_status.php index cb4b50a4c..f51cfb99b 100644 --- a/src/www/carp_status.php +++ b/src/www/carp_status.php @@ -163,26 +163,35 @@ include("head.inc"); 0 && !$status)) { $icon = "fa fa-remove fa-fw text-danger"; - $intf_status = gettext('DISABLED'); - } elseif ($intf_status == gettext('MASTER')) { + $intf_status_i18n = gettext('DISABLED'); + } elseif ($intf_status == 'MASTER') { $icon = "fa fa-play fa-fw text-success"; - } elseif ($intf_status == gettext('BACKUP')) { + $intf_status_i18n = gettext('MASTER'); + } elseif ($intf_status == 'BACKUP') { $icon = "fa fa-play fa-fw text-muted"; - } elseif ($intf_status == gettext('INIT')) { + $intf_status_i18n = gettext('BACKUP'); + } elseif ($intf_status == 'INIT') { $icon = "fa fa-info-circle fa-fw"; + $intf_status_i18n = gettext('INIT'); }?>
| @@ -52,18 +61,21 @@ config_read_array('virtualip', 'vip'); | "; - } elseif ($status == gettext("MASTER")) { - echo ""; - } elseif ($status == gettext("BACKUP")) { - echo ""; - } elseif ($status == gettext("INIT")) { - echo ""; + $status_i18n = gettext("DISABLED"); + echo ""; + } elseif ($status == "MASTER") { + $status_i18n = gettext("MASTER"); + echo ""; + } elseif ($status == "BACKUP") { + $status_i18n = gettext("BACKUP"); + echo ""; + } elseif ($status == "INIT") { + $status_i18n = gettext("INIT"); + echo ""; } if (!empty($carp['subnet'])):?> - =htmlspecialchars($status);?> + =htmlspecialchars($status_i18n);?> =htmlspecialchars($carp['subnet']);?> |