1 |
a26686cb
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
1af5edbf
|
Stephen Beaver
|
status_carp.php
|
4 |
a26686cb
|
Scott Ullrich
|
*/
|
5 |
fd9ebcd5
|
Stephen Beaver
|
/* ====================================================================
|
6 |
0da0d43e
|
Phil Davis
|
* Copyright (c) 2004-2015 Electric Sheep Fencing, LLC. All rights reserved.
|
7 |
fd9ebcd5
|
Stephen Beaver
|
*
|
8 |
0da0d43e
|
Phil Davis
|
* Redistribution and use in source and binary forms, with or without modification,
|
9 |
|
|
* are permitted provided that the following conditions are met:
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
|
|
* 1. Redistributions of source code must retain the above copyright notice,
|
12 |
|
|
* this list of conditions and the following disclaimer.
|
13 |
|
|
*
|
14 |
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
15 |
|
|
* notice, this list of conditions and the following disclaimer in
|
16 |
|
|
* the documentation and/or other materials provided with the
|
17 |
0da0d43e
|
Phil Davis
|
* distribution.
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
0da0d43e
|
Phil Davis
|
* 3. All advertising materials mentioning features or use of this software
|
20 |
fd9ebcd5
|
Stephen Beaver
|
* must display the following acknowledgment:
|
21 |
|
|
* "This product includes software developed by the pfSense Project
|
22 |
0da0d43e
|
Phil Davis
|
* for use in the pfSense software distribution. (http://www.pfsense.org/).
|
23 |
fd9ebcd5
|
Stephen Beaver
|
*
|
24 |
|
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
25 |
|
|
* endorse or promote products derived from this software without
|
26 |
|
|
* prior written permission. For written permission, please contact
|
27 |
|
|
* coreteam@pfsense.org.
|
28 |
|
|
*
|
29 |
|
|
* 5. Products derived from this software may not be called "pfSense"
|
30 |
|
|
* nor may "pfSense" appear in their names without prior written
|
31 |
|
|
* permission of the Electric Sheep Fencing, LLC.
|
32 |
|
|
*
|
33 |
|
|
* 6. Redistributions of any form whatsoever must retain the following
|
34 |
|
|
* acknowledgment:
|
35 |
|
|
*
|
36 |
|
|
* "This product includes software developed by the pfSense Project
|
37 |
|
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
38 |
0da0d43e
|
Phil Davis
|
*
|
39 |
fd9ebcd5
|
Stephen Beaver
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
40 |
|
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
41 |
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
42 |
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
43 |
|
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
44 |
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
45 |
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
46 |
|
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
47 |
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
48 |
|
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
49 |
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
50 |
|
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
51 |
|
|
*
|
52 |
|
|
* ====================================================================
|
53 |
|
|
*
|
54 |
|
|
*/
|
55 |
a26686cb
|
Scott Ullrich
|
|
56 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
57 |
|
|
##|*IDENT=page-status-carp
|
58 |
5230f468
|
jim-p
|
##|*NAME=Status: CARP
|
59 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: CARP' page.
|
60 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=status_carp.php*
|
61 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
62 |
|
|
|
63 |
670fafe5
|
Scott Ullrich
|
require_once("guiconfig.inc");
|
64 |
783f1ee2
|
PiBa-NL
|
require_once("globals.inc");
|
65 |
a26686cb
|
Scott Ullrich
|
|
66 |
a1e58090
|
Scott Ullrich
|
unset($interface_arr_cache);
|
67 |
07e5afeb
|
Scott Ullrich
|
unset($interface_ip_arr_cache);
|
68 |
a1e58090
|
Scott Ullrich
|
|
69 |
2a5960b0
|
Luiz Otavio O Souza
|
|
70 |
|
|
function find_ipalias($carpif) {
|
71 |
|
|
global $config;
|
72 |
|
|
|
73 |
|
|
$ips = array();
|
74 |
|
|
foreach ($config['virtualip']['vip'] as $vip) {
|
75 |
d9901ff4
|
Chris Buechler
|
if ($vip['mode'] != "ipalias") {
|
76 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
77 |
d9901ff4
|
Chris Buechler
|
}
|
78 |
|
|
if ($vip['interface'] != $carpif) {
|
79 |
2a5960b0
|
Luiz Otavio O Souza
|
continue;
|
80 |
d9901ff4
|
Chris Buechler
|
}
|
81 |
2a5960b0
|
Luiz Otavio O Souza
|
$ips[] = "{$vip['subnet']}/{$vip['subnet_bits']}";
|
82 |
|
|
}
|
83 |
|
|
|
84 |
|
|
return ($ips);
|
85 |
|
|
}
|
86 |
|
|
|
87 |
a26686cb
|
Scott Ullrich
|
$status = get_carp_status();
|
88 |
9e4bb200
|
Stephen Beaver
|
|
89 |
d3a01571
|
Stephen Beaver
|
if ($_POST['carp_maintenancemode'] != "") {
|
90 |
783f1ee2
|
PiBa-NL
|
interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"]));
|
91 |
|
|
}
|
92 |
d3a01571
|
Stephen Beaver
|
|
93 |
|
|
if ($_POST['disablecarp'] != "") {
|
94 |
b191b7b1
|
Stephen Beaver
|
if ($status > 0) {
|
95 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '0');
|
96 |
b191b7b1
|
Stephen Beaver
|
if (is_array($config['virtualip']['vip'])) {
|
97 |
8e2986f8
|
Ermal
|
$viparr = &$config['virtualip']['vip'];
|
98 |
aae16684
|
Renato Botelho
|
foreach ($viparr as $vip) {
|
99 |
2a5960b0
|
Luiz Otavio O Souza
|
if ($vip['mode'] != "carp" && $vip['mode'] != "ipalias")
|
100 |
|
|
continue;
|
101 |
|
|
if ($vip['mode'] == "ipalias" && substr($vip['interface'], 0, 4) != "_vip")
|
102 |
|
|
continue;
|
103 |
|
|
|
104 |
|
|
interface_vip_bring_down($vip);
|
105 |
|
|
|
106 |
|
|
/*
|
107 |
|
|
* Reconfigure radvd when necessary
|
108 |
|
|
* XXX: Is it the best way to do it?
|
109 |
|
|
*/
|
110 |
|
|
if (isset($config['dhcpdv6']) && is_array($config['dhcpdv6'])) {
|
111 |
|
|
foreach ($config['dhcpdv6'] as $dhcpv6if => $dhcpv6ifconf) {
|
112 |
|
|
if ($dhcpv6if !== $vip['interface'] ||
|
113 |
|
|
$dhcpv6ifconf['ramode'] === "disabled") {
|
114 |
|
|
continue;
|
115 |
9b527a79
|
Renato Botelho
|
}
|
116 |
|
|
|
117 |
2a5960b0
|
Luiz Otavio O Souza
|
services_radvd_configure();
|
118 |
b191b7b1
|
Stephen Beaver
|
break;
|
119 |
2a5960b0
|
Luiz Otavio O Souza
|
}
|
120 |
aae16684
|
Renato Botelho
|
}
|
121 |
|
|
}
|
122 |
|
|
}
|
123 |
cccee755
|
Chris Buechler
|
$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot and some configuration changes will re-enable."), $carp_counter);
|
124 |
9c296826
|
Ermal
|
$status = 0;
|
125 |
a26686cb
|
Scott Ullrich
|
} else {
|
126 |
2df8214a
|
Carlos Eduardo Ramos
|
$savemsg = gettext("CARP has been enabled.");
|
127 |
b191b7b1
|
Stephen Beaver
|
if (is_array($config['virtualip']['vip'])) {
|
128 |
aae16684
|
Renato Botelho
|
$viparr = &$config['virtualip']['vip'];
|
129 |
|
|
foreach ($viparr as $vip) {
|
130 |
a133bb38
|
Ermal
|
switch ($vip['mode']) {
|
131 |
b191b7b1
|
Stephen Beaver
|
case "carp":
|
132 |
|
|
interface_carp_configure($vip);
|
133 |
|
|
break;
|
134 |
|
|
case 'ipalias':
|
135 |
d9901ff4
|
Chris Buechler
|
if (substr($vip['interface'], 0, 4) == "_vip") {
|
136 |
b191b7b1
|
Stephen Beaver
|
interface_ipalias_configure($vip);
|
137 |
d9901ff4
|
Chris Buechler
|
}
|
138 |
b191b7b1
|
Stephen Beaver
|
break;
|
139 |
e120d5ce
|
Chris Buechler
|
}
|
140 |
aae16684
|
Renato Botelho
|
}
|
141 |
|
|
}
|
142 |
8ff85c39
|
Ermal
|
interfaces_sync_setup();
|
143 |
971de1f9
|
Renato Botelho
|
set_single_sysctl('net.inet.carp.allow', '1');
|
144 |
9c296826
|
Ermal
|
$status = 1;
|
145 |
a26686cb
|
Scott Ullrich
|
}
|
146 |
|
|
}
|
147 |
|
|
|
148 |
0a4fbd99
|
jim-p
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
149 |
|
|
|
150 |
|
|
if (!empty($_POST['resetdemotion'])) {
|
151 |
|
|
set_single_sysctl("net.inet.carp.demotion", "-{$carp_detected_problems}");
|
152 |
|
|
sleep(1);
|
153 |
|
|
$carp_detected_problems = get_single_sysctl("net.inet.carp.demotion");
|
154 |
|
|
}
|
155 |
8a84b3ab
|
jim-p
|
|
156 |
b191b7b1
|
Stephen Beaver
|
$pgtitle = array(gettext("Status"), gettext("CARP"));
|
157 |
b32dd0a6
|
jim-p
|
$shortcut_section = "carp";
|
158 |
d3a01571
|
Stephen Beaver
|
|
159 |
b63695db
|
Scott Ullrich
|
include("head.inc");
|
160 |
abe98adb
|
Phil Davis
|
if ($savemsg) {
|
161 |
d3a01571
|
Stephen Beaver
|
print_info_box($savemsg, 'success');
|
162 |
abe98adb
|
Phil Davis
|
}
|
163 |
8a84b3ab
|
jim-p
|
|
164 |
7d5b007c
|
Sjon Hortensius
|
$carpcount = 0;
|
165 |
288a2a0f
|
Phil Davis
|
if (is_array($config['virtualip']['vip'])) {
|
166 |
|
|
foreach ($config['virtualip']['vip'] as $carp) {
|
167 |
7d5b007c
|
Sjon Hortensius
|
if ($carp['mode'] == "carp") {
|
168 |
|
|
$carpcount++;
|
169 |
|
|
break;
|
170 |
|
|
}
|
171 |
|
|
}
|
172 |
|
|
}
|
173 |
d3a01571
|
Stephen Beaver
|
|
174 |
|
|
// If $carpcount > 0 display buttons then display table
|
175 |
|
|
// otherwise display error box and quit
|
176 |
|
|
|
177 |
|
|
if ($carpcount == 0) {
|
178 |
|
|
print_info_box(gettext('No CARP interfaces have been defined.') . '<br />' .
|
179 |
0da0d43e
|
Phil Davis
|
'<a href="system_hasync.php" class="alert-link">' .
|
180 |
8545adde
|
k-paulius
|
gettext("You can configure high availability sync settings here.") .
|
181 |
d3a01571
|
Stephen Beaver
|
'</a>');
|
182 |
abe98adb
|
Phil Davis
|
} else {
|
183 |
d3a01571
|
Stephen Beaver
|
?>
|
184 |
1af5edbf
|
Stephen Beaver
|
<form action="status_carp.php" method="post">
|
185 |
9e4bb200
|
Stephen Beaver
|
<?php
|
186 |
abe98adb
|
Phil Davis
|
if ($status > 0) {
|
187 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = true;
|
188 |
abe98adb
|
Phil Davis
|
} else {
|
189 |
9e4bb200
|
Stephen Beaver
|
$carp_enabled = false;
|
190 |
abe98adb
|
Phil Davis
|
}
|
191 |
0da0d43e
|
Phil Davis
|
|
192 |
|
|
// Sadly this needs to be here so that it is inside the form
|
193 |
61f75117
|
Stephen Beaver
|
if ($carp_detected_problems > 0) {
|
194 |
|
|
print_info_box(
|
195 |
98128ad6
|
Phil Davis
|
gettext("CARP has detected a problem and this unit has been demoted to BACKUP status.") .
|
196 |
|
|
"<br/>" .
|
197 |
|
|
gettext("Check the link status on all interfaces with configured CARP VIPs.") .
|
198 |
|
|
"<br/>" .
|
199 |
|
|
sprintf(gettext('Search the %1$sSystem Log%2$s for CARP demotion-related events.'), "<a href=\"/status_logs.php?filtertext=carp%3A+demoted+by\">", "</a>") .
|
200 |
|
|
"<br/><br/>" .
|
201 |
61f75117
|
Stephen Beaver
|
'<input type="submit" class="btn btn-warning" name="resetdemotion" id="resetdemotion" value="' .
|
202 |
8545adde
|
k-paulius
|
gettext("Reset CARP Demotion Status.") .
|
203 |
98128ad6
|
Phil Davis
|
'" />',
|
204 |
|
|
'danger'
|
205 |
61f75117
|
Stephen Beaver
|
);
|
206 |
|
|
}
|
207 |
|
|
|
208 |
9e4bb200
|
Stephen Beaver
|
?>
|
209 |
d3a01571
|
Stephen Beaver
|
<input type="submit" class="btn btn-warning" name="disablecarp" value="<?=($carp_enabled ? gettext("Temporarily Disable CARP") : gettext("Enable CARP"))?>" />
|
210 |
61f75117
|
Stephen Beaver
|
<input type="submit" class="btn btn-info" name="carp_maintenancemode" id="carp_maintenancemode" value="<?=(isset($config["virtualip_carp_maintenancemode"]) ? gettext("Leave Persistent CARP Maintenance Mode") : gettext("Enter Persistent CARP Maintenance Mode"))?>" />
|
211 |
0da0d43e
|
Phil Davis
|
|
212 |
d3a01571
|
Stephen Beaver
|
<br /><br />
|
213 |
0da0d43e
|
Phil Davis
|
|
214 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
215 |
6f3a6c31
|
Stephen Beaver
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('CARP Interfaces')?></h2></div>
|
216 |
d3a01571
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
217 |
10fe1eb5
|
Stephen Beaver
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap " data-sortable>
|
218 |
d3a01571
|
Stephen Beaver
|
<thead>
|
219 |
|
|
<tr>
|
220 |
|
|
<th><?=gettext("CARP Interface")?></th>
|
221 |
|
|
<th><?=gettext("Virtual IP")?></th>
|
222 |
|
|
<th><?=gettext("Status")?></th>
|
223 |
|
|
</tr>
|
224 |
|
|
</thead>
|
225 |
|
|
<tbody>
|
226 |
a26686cb
|
Scott Ullrich
|
<?php
|
227 |
288a2a0f
|
Phil Davis
|
foreach ($config['virtualip']['vip'] as $carp) {
|
228 |
|
|
if ($carp['mode'] != "carp") {
|
229 |
7d5b007c
|
Sjon Hortensius
|
continue;
|
230 |
288a2a0f
|
Phil Davis
|
}
|
231 |
0da0d43e
|
Phil Davis
|
|
232 |
7d5b007c
|
Sjon Hortensius
|
$vhid = $carp['vhid'];
|
233 |
f92ea2e2
|
Luiz Otavio O Souza
|
$status = get_carp_interface_status("_vip{$carp['uniqid']}");
|
234 |
2a5960b0
|
Luiz Otavio O Souza
|
$aliases = find_ipalias("_vip{$carp['uniqid']}");
|
235 |
0da0d43e
|
Phil Davis
|
|
236 |
abe98adb
|
Phil Davis
|
if ($carp_enabled == false) {
|
237 |
1b7379f9
|
Jared Dillard
|
$icon = 'times-circle';
|
238 |
7d5b007c
|
Sjon Hortensius
|
$status = "DISABLED";
|
239 |
|
|
} else {
|
240 |
288a2a0f
|
Phil Davis
|
if ($status == "MASTER") {
|
241 |
1b7379f9
|
Jared Dillard
|
$icon = 'check-circle';
|
242 |
288a2a0f
|
Phil Davis
|
} else if ($status == "BACKUP") {
|
243 |
1b7379f9
|
Jared Dillard
|
$icon = 'check-circle-o';
|
244 |
288a2a0f
|
Phil Davis
|
} else if ($status == "INIT") {
|
245 |
1b7379f9
|
Jared Dillard
|
$icon = 'question-circle';
|
246 |
7d5b007c
|
Sjon Hortensius
|
}
|
247 |
|
|
}
|
248 |
a26686cb
|
Scott Ullrich
|
?>
|
249 |
d3a01571
|
Stephen Beaver
|
<tr>
|
250 |
|
|
<td><?=convert_friendly_interface_to_friendly_descr($carp['interface'])?>@<?=$vhid?></td>
|
251 |
2a5960b0
|
Luiz Otavio O Souza
|
<td>
|
252 |
|
|
<?php
|
253 |
|
|
printf("{$carp['subnet']}/{$carp['subnet_bits']}");
|
254 |
d9901ff4
|
Chris Buechler
|
for ($i = 0; $i < count($aliases); $i++) {
|
255 |
2a5960b0
|
Luiz Otavio O Souza
|
printf("<br>{$aliases[$i]}");
|
256 |
d9901ff4
|
Chris Buechler
|
}
|
257 |
2a5960b0
|
Luiz Otavio O Souza
|
?>
|
258 |
|
|
</td>
|
259 |
1b7379f9
|
Jared Dillard
|
<td><i class="fa fa-<?=$icon?>"></i> <?=$status?></td>
|
260 |
d3a01571
|
Stephen Beaver
|
</tr>
|
261 |
7d5b007c
|
Sjon Hortensius
|
<?php }?>
|
262 |
d3a01571
|
Stephen Beaver
|
</tbody>
|
263 |
|
|
</table>
|
264 |
61f75117
|
Stephen Beaver
|
</div>
|
265 |
d3a01571
|
Stephen Beaver
|
</div>
|
266 |
0f4317d3
|
Colin Fleming
|
</form>
|
267 |
a26686cb
|
Scott Ullrich
|
|
268 |
d3a01571
|
Stephen Beaver
|
<div class="panel panel-default">
|
269 |
3d7a8696
|
k-paulius
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('pfSync Nodes')?></h2></div>
|
270 |
d3a01571
|
Stephen Beaver
|
<div class="panel-body">
|
271 |
|
|
<ul>
|
272 |
1f919154
|
Scott Ullrich
|
<?php
|
273 |
2a5960b0
|
Luiz Otavio O Souza
|
|
274 |
|
|
$nodes = array();
|
275 |
|
|
$states = pfSense_get_pf_states();
|
276 |
|
|
for ($i = 0; $states != NULL && $i < count($states); $i++) {
|
277 |
|
|
$nodes[$states[$i]['creatorid']] = 1;
|
278 |
|
|
}
|
279 |
|
|
foreach ($nodes as $node => $nenabled) {
|
280 |
|
|
echo "<li>$node</li>";
|
281 |
288a2a0f
|
Phil Davis
|
}
|
282 |
1f919154
|
Scott Ullrich
|
?>
|
283 |
d3a01571
|
Stephen Beaver
|
</ul>
|
284 |
|
|
</div>
|
285 |
|
|
</div>
|
286 |
|
|
|
287 |
|
|
<?php
|
288 |
|
|
}
|
289 |
1f919154
|
Scott Ullrich
|
|
290 |
d3a01571
|
Stephen Beaver
|
include("foot.inc");
|