1
|
<?php
|
2
|
/*
|
3
|
* status_gateways.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8
|
* Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
|
9
|
* Copyright (c) 2010 Seth Mos <seth.mos@dds.nl>
|
10
|
* All rights reserved.
|
11
|
*
|
12
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
13
|
* you may not use this file except in compliance with the License.
|
14
|
* You may obtain a copy of the License at
|
15
|
*
|
16
|
* http://www.apache.org/licenses/LICENSE-2.0
|
17
|
*
|
18
|
* Unless required by applicable law or agreed to in writing, software
|
19
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
20
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
21
|
* See the License for the specific language governing permissions and
|
22
|
* limitations under the License.
|
23
|
*/
|
24
|
|
25
|
##|+PRIV
|
26
|
##|*IDENT=page-status-gateways
|
27
|
##|*NAME=Status: Gateways
|
28
|
##|*DESCR=Allow access to the 'Status: Gateways' page.
|
29
|
##|*MATCH=status_gateways.php*
|
30
|
##|-PRIV
|
31
|
|
32
|
require_once("guiconfig.inc");
|
33
|
|
34
|
if ($_POST['act'] == 'killgw') {
|
35
|
if (!empty($_POST['gwname'])) {
|
36
|
mwexec("/sbin/pfctl -k label -k " . escapeshellarg("gw:{$_POST['gwname']}"));
|
37
|
} elseif (!empty($_POST['gwip']) && is_ipaddr($_POST['gwip'])) {
|
38
|
list($ipaddr, $scope) = explode('%', $_POST['gwip']);
|
39
|
mwexec("/sbin/pfctl -k gateway -k " . escapeshellarg($ipaddr));
|
40
|
} elseif (!empty($_POST['gwdef4'])) {
|
41
|
mwexec("/sbin/pfctl -k gateway -k '0.0.0.0'");
|
42
|
} elseif (!empty($_POST['gwdef6'])) {
|
43
|
mwexec("/sbin/pfctl -k gateway -k '::'");
|
44
|
}
|
45
|
|
46
|
header("Location: status_gateways.php");
|
47
|
exit;
|
48
|
}
|
49
|
|
50
|
$a_gateways = return_gateways_array();
|
51
|
$gateways_status = return_gateways_status(true);
|
52
|
|
53
|
$pgtitle = array(gettext("Status"), gettext("Gateways"));
|
54
|
$pglinks = array("", "@self");
|
55
|
$shortcut_section = "gateways";
|
56
|
include("head.inc");
|
57
|
|
58
|
/* active tabs */
|
59
|
$tab_array = array();
|
60
|
$tab_array[] = array(gettext("Gateways"), true, "status_gateways.php");
|
61
|
$tab_array[] = array(gettext("Gateway Groups"), false, "status_gateway_groups.php");
|
62
|
display_top_tabs($tab_array);
|
63
|
?>
|
64
|
<div class="panel panel-default">
|
65
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext('Gateways')?></h2></div>
|
66
|
<div class="panel-body">
|
67
|
|
68
|
<div class="table-responsive">
|
69
|
<table class="table table-striped table-hover table-condensed sortable-theme-bootstrap" data-sortable>
|
70
|
<thead>
|
71
|
<tr>
|
72
|
<th><?=gettext("Name"); ?></th>
|
73
|
<th><?=gettext("Gateway"); ?></th>
|
74
|
<th><?=gettext("Monitor"); ?></th>
|
75
|
<th><?=gettext("RTT"); ?></th>
|
76
|
<th><?=gettext("RTTsd"); ?></th>
|
77
|
<th><?=gettext("Loss"); ?></th>
|
78
|
<th><?=gettext("Status"); ?></th>
|
79
|
<th><?=gettext("Description"); ?></th>
|
80
|
<th><?=gettext("Action"); ?></th>
|
81
|
</tr>
|
82
|
</thead>
|
83
|
<tbody>
|
84
|
<?php foreach ($a_gateways as $i => $gateway) {
|
85
|
$gwip = lookup_gateway_ip_by_name($i);
|
86
|
?>
|
87
|
<tr>
|
88
|
<td>
|
89
|
<?=htmlspecialchars($gateway['name']);?>
|
90
|
<?php
|
91
|
if (isset($gateway['isdefaultgw'])) {
|
92
|
echo " <strong>(default)</strong>";
|
93
|
}
|
94
|
?>
|
95
|
</td>
|
96
|
<td>
|
97
|
<?=$gwip;?>
|
98
|
</td>
|
99
|
<td>
|
100
|
<?php
|
101
|
if ($gateways_status[$i]) {
|
102
|
if ($gateway['monitor_disable'] || ($gateway['monitorip'] == "none")) {
|
103
|
echo "(unmonitored)";
|
104
|
} else {
|
105
|
echo $gateways_status[$i]['monitorip'];
|
106
|
}
|
107
|
}
|
108
|
?>
|
109
|
</td>
|
110
|
<td>
|
111
|
<?php
|
112
|
if ($gateways_status[$i]) {
|
113
|
if (!isset($gateway['monitor_disable'])) {
|
114
|
echo $gateways_status[$i]['delay'];
|
115
|
}
|
116
|
} else {
|
117
|
echo gettext("Pending");
|
118
|
}
|
119
|
?>
|
120
|
</td>
|
121
|
<td>
|
122
|
<?php
|
123
|
if ($gateways_status[$i]) {
|
124
|
if (!isset($gateway['monitor_disable'])) {
|
125
|
echo $gateways_status[$i]['stddev'];
|
126
|
}
|
127
|
} else {
|
128
|
echo gettext("Pending");
|
129
|
}
|
130
|
?>
|
131
|
</td>
|
132
|
<td>
|
133
|
<?php
|
134
|
if ($gateways_status[$i]) {
|
135
|
if (!isset($gateway['monitor_disable'])) {
|
136
|
echo $gateways_status[$i]['loss'];
|
137
|
}
|
138
|
} else {
|
139
|
echo gettext("Pending");
|
140
|
}
|
141
|
?>
|
142
|
</td>
|
143
|
<?php
|
144
|
$status = $gateways_status[$i];
|
145
|
if (stristr($status['status'], "online")) {
|
146
|
switch ($status['substatus']) {
|
147
|
case "highloss":
|
148
|
$online = gettext("Danger, Packetloss") . ': ' . $status['loss'];
|
149
|
$bgcolor = "bg-danger";
|
150
|
break;
|
151
|
case "highdelay":
|
152
|
$online = gettext("Danger, Latency") . ': ' . $status['delay'];
|
153
|
$bgcolor = "bg-danger";
|
154
|
break;
|
155
|
case "loss":
|
156
|
$online = gettext("Warning, Packetloss") . ': ' . $status['loss'];
|
157
|
$bgcolor = "bg-warning";
|
158
|
break;
|
159
|
case "delay":
|
160
|
$online = gettext("Warning, Latency") . ': ' . $status['delay'];
|
161
|
$bgcolor = "bg-warning";
|
162
|
break;
|
163
|
default:
|
164
|
if ($status['monitor_disable'] || ($status['monitorip'] == "none")) {
|
165
|
$online = gettext("Online <br/>(unmonitored)");
|
166
|
} else {
|
167
|
$online = gettext("Online");
|
168
|
}
|
169
|
$bgcolor = "bg-success";
|
170
|
}
|
171
|
} elseif (stristr($status['status'], "down")) {
|
172
|
$bgcolor = "bg-danger";
|
173
|
switch ($status['substatus']) {
|
174
|
case "force_down":
|
175
|
$online = gettext("Offline (forced)");
|
176
|
break;
|
177
|
case "highloss":
|
178
|
$online = gettext("Offline, Packetloss") . ': ' . $status['loss'];
|
179
|
break;
|
180
|
case "highdelay":
|
181
|
$online = gettext("Offline, Latency") . ': ' . $status['delay'];
|
182
|
break;
|
183
|
default:
|
184
|
$online = gettext("Offline");
|
185
|
}
|
186
|
} else {
|
187
|
$online = gettext("Pending");
|
188
|
$bgcolor = "bg-info";
|
189
|
}
|
190
|
?>
|
191
|
<td class="<?=$bgcolor?>">
|
192
|
<strong><?=$online?></strong>
|
193
|
</td>
|
194
|
<td>
|
195
|
<?=htmlspecialchars($gateway['descr']); ?>
|
196
|
</td>
|
197
|
<td>
|
198
|
<a href="?act=killgw&gwname=<?=urlencode($gateway['name']);?>" class="fa-solid fa-times-circle do-confirm" title="<?=gettext('Kill all firewall states created by policy routing rules using this specific gateway by name.')?>" usepost></a>
|
199
|
<?php if (!empty($gwip) && is_ipaddr($gwip)): ?>
|
200
|
<a href="?act=killgw&gwip=<?=urlencode($gwip);?>" class="fa-regular fa-circle-xmark do-confirm" title="<?=gettext('Kill all firewall states using this gateway IP address via policy routing and reply-to.')?>" usepost></a>
|
201
|
<?php endif; ?>
|
202
|
<?php if (isset($gateway['isdefaultgw'])): ?>
|
203
|
<?php if ($gateway['ipprotocol'] != 'inet6'): ?>
|
204
|
<a href="?act=killgw&gwdef4=true" class="fa-solid fa-times do-confirm" title="<?=gettext('Kill all firewall states which use the default IPv4 gateway (0.0.0.0) and not policy routing or reply-to rules.')?>" usepost></a>
|
205
|
<?php else: ?>
|
206
|
<a href="?act=killgw&gwdef6=true" class="fa-solid fa-times do-confirm" title="<?=gettext('Kill all firewall states which use the default IPv6 gateway (::) and not policy routing or reply-to rules.')?>" usepost></a>
|
207
|
<?php endif; ?>
|
208
|
<?php endif; ?>
|
209
|
</td>
|
210
|
</tr>
|
211
|
<?php } ?> <!-- End-of-foreach -->
|
212
|
</tbody>
|
213
|
</table>
|
214
|
</div>
|
215
|
|
216
|
</div>
|
217
|
</div>
|
218
|
|
219
|
<?php include("foot.inc"); ?>
|