mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 00:24:40 +00:00
Squashed commit of the following:
commit 9da181580631e305cf194688479eb311d74dda9d
Author: Ad Schellevis <ad@opnsense.org>
Date: Tue Aug 31 13:22:39 2021 +0200
CARP: small cleanups after https://github.com/opnsense/core/pull/5184
commit 9875b53e98aeed173e1603182251b8e2165cabbb
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 22:28:03 2021 +0300
CARP: Fix fetching VIP status
Implement array safeguards after e44fd48
commit 9c6ff1717741ec7f21a1b88127c57ff3d849085d
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 22:23:25 2021 +0300
CARP: Fix fetching VIP status
Simplify code after e44fd48
commit 52ffd6ee3d471c09a69599a8fdd02f6e6ea6f2c6
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 22:19:26 2021 +0300
CARP: Fix fetching VIP status
Simplify code after e44fd48
commit d5ae42623e31138daa29debedc36088fa7ba4811
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 22:13:57 2021 +0300
CARP: Fix fetching VIP status
Simplify code after e44fd48
commit df99ba8106233a34732bb0cb39f6134d7697e4a4
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 16:39:57 2021 +0300
CARP: Fix fetching VIP status
Take into account translation issues
commit 45eddeb399b64e631e7d81be8ac29dc2cad97bf2
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 16:35:04 2021 +0300
CARP: Fix fetching VIP status
Take into account translation issues
commit a068f10cd0a4402e648a09027a6b48b90670e60a
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 15:08:51 2021 +0300
CARP: Fix fetching VIP status
Whitespace cleanup
commit aa958e1d04938b084a5582dd4080988aef240eaa
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 15:05:12 2021 +0300
CARP: Fix fetching VIP status
Remove unnecessary require_once call
Co-authored-by: Franco Fichtner <franco@lastsummer.de>
commit 5966d1c834fe5c69845a675f0f829ec6efcabc2f
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 15:04:47 2021 +0300
CARP: Fix fetching VIP status
Remove unnecessary require_once call
Co-authored-by: Franco Fichtner <franco@lastsummer.de>
commit 38d6d952084ed2db4ae2d81aa583850a38f2f7b2
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 15:03:57 2021 +0300
CARP: Fix fetching VIP status
Remove unnecessary require_once call
Co-authored-by: Franco Fichtner <franco@lastsummer.de>
commit 3ae8a2f960310b4f373fbae3e77e2eea2b7ced8a
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 14:49:46 2021 +0300
CARP: Fix fetching VIP status
Eliminate calling get_carp_interface_status() by openvpn.inc
commit bf195f3a66ad6a1ec5c62ecb589e32681eeb86dc
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 14:04:16 2021 +0300
CARP: Fix fetching VIP status
Refactor the widget to call ifconfig once
commit 26bfe2036a846824b9d163d9c3c8aafd2be3ac36
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 13:58:20 2021 +0300
CARP: Fix fetching VIP status
Refactor the status page to call ifconfig once
commit 7cdc8eca63acfb9db8da9cf621780c30454df132
Author: vnxme <46669194+vnxme@users.noreply.github.com>
Date: Sun Aug 29 10:22:05 2021 +0300
CARP: Fix fetching VIP status
Add a space after vhid to make grep more precise
This commit is contained in:
parent
e7fcd3e2bf
commit
53cd1c7183
@ -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)
|
||||
{
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -163,26 +163,35 @@ include("head.inc");
|
||||
</tr>
|
||||
<?php
|
||||
else:
|
||||
$intf_details = legacy_interfaces_details();
|
||||
foreach ($a_vip as $carp):
|
||||
if ($carp['mode'] != "carp") {
|
||||
continue;
|
||||
}
|
||||
$icon = '';
|
||||
$intf_status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");
|
||||
$intf = get_real_interface($carp['interface']);
|
||||
if (!empty($intf_details[$intf]) && !empty($intf_details[$intf]['carp'][$carp['vhid']])) {
|
||||
$intf_status = $intf_details[$intf]['carp'][$carp['vhid']]['status'];
|
||||
} else {
|
||||
$intf_status = null;
|
||||
}
|
||||
if (($carpcount > 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');
|
||||
}?>
|
||||
<tr>
|
||||
<td><?=convert_friendly_interface_to_friendly_descr($carp['interface']) . "@{$carp['vhid']}" ;?></td>
|
||||
<td><?=$carp['subnet'];?></td>
|
||||
<td><span class="<?=$icon;?>"></span> <?=$intf_status;?></td>
|
||||
<td><span class="<?=$icon;?>"></span> <?=$intf_status_i18n;?></td>
|
||||
</tr>
|
||||
<?php
|
||||
endforeach;
|
||||
|
||||
@ -35,11 +35,20 @@ config_read_array('virtualip', 'vip');
|
||||
?>
|
||||
<table class="table table-striped table-condensed">
|
||||
<?php
|
||||
$interfaces_details = legacy_interfaces_details();
|
||||
foreach ($config['virtualip']['vip'] as $carp):
|
||||
if ($carp['mode'] != "carp") {
|
||||
continue;
|
||||
}
|
||||
$status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");?>
|
||||
$intf = get_real_interface($carp['interface']);
|
||||
if (
|
||||
!empty($interfaces_details[$intf]) && !empty($interfaces_details[$intf]['carp'][$carp['vhid']])
|
||||
) {
|
||||
$status = $interfaces_details[$intf]['carp'][$carp['vhid']]['status'];
|
||||
} else {
|
||||
$status = null;
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<i class="fa fa-exchange fa-fw text-success"></i>
|
||||
@ -52,18 +61,21 @@ config_read_array('virtualip', 'vip');
|
||||
<td>
|
||||
<?php
|
||||
if (get_single_sysctl('net.inet.carp.allow') <= 0 ) {
|
||||
$status = gettext("DISABLED");
|
||||
echo "<span class=\"fa fa-remove fa-fw text-danger\" title=\"$status\" ></span>";
|
||||
} elseif ($status == gettext("MASTER")) {
|
||||
echo "<span class=\"fa fa-play fa-fw text-success\" title=\"$status\" ></span>";
|
||||
} elseif ($status == gettext("BACKUP")) {
|
||||
echo "<span class=\"fa fa-play fa-fw text-muted\" title=\"$status\" ></span>";
|
||||
} elseif ($status == gettext("INIT")) {
|
||||
echo "<span class=\"fa fa-info-circle fa-fw\" title=\"$status\" ></span>";
|
||||
$status_i18n = gettext("DISABLED");
|
||||
echo "<span class=\"fa fa-remove fa-fw text-danger\" title=\"$status_i18n\" ></span>";
|
||||
} elseif ($status == "MASTER") {
|
||||
$status_i18n = gettext("MASTER");
|
||||
echo "<span class=\"fa fa-play fa-fw text-success\" title=\"$status_i18n\" ></span>";
|
||||
} elseif ($status == "BACKUP") {
|
||||
$status_i18n = gettext("BACKUP");
|
||||
echo "<span class=\"fa fa-play fa-fw text-muted\" title=\"$status_i18n\" ></span>";
|
||||
} elseif ($status == "INIT") {
|
||||
$status_i18n = gettext("INIT");
|
||||
echo "<span class=\"fa fa-info-circle fa-fw\" title=\"$status_i18n\" ></span>";
|
||||
}
|
||||
if (!empty($carp['subnet'])):?>
|
||||
|
||||
<?=htmlspecialchars($status);?>
|
||||
<?=htmlspecialchars($status_i18n);?>
|
||||
<?=htmlspecialchars($carp['subnet']);?>
|
||||
<?php
|
||||
endif;?>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user