1 |
cf7d1057
|
Scott Ullrich
|
<?php
|
2 |
|
|
/*
|
3 |
c5d81585
|
Renato Botelho
|
* status_ipsec.php
|
4 |
86b2861c
|
Matt Smith
|
*
|
5 |
c5d81585
|
Renato Botelho
|
* part of pfSense (https://www.pfsense.org)
|
6 |
38809d47
|
Renato Botelho do Couto
|
* Copyright (c) 2004-2013 BSD Perimeter
|
7 |
|
|
* Copyright (c) 2013-2016 Electric Sheep Fencing
|
8 |
402c98a2
|
Reid Linnemann
|
* Copyright (c) 2014-2023 Rubicon Communications, LLC (Netgate)
|
9 |
c5d81585
|
Renato Botelho
|
* All rights reserved.
|
10 |
fd9ebcd5
|
Stephen Beaver
|
*
|
11 |
c5d81585
|
Renato Botelho
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
12 |
|
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13 |
|
|
* All rights reserved.
|
14 |
fd9ebcd5
|
Stephen Beaver
|
*
|
15 |
b12ea3fb
|
Renato Botelho
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
16 |
|
|
* you may not use this file except in compliance with the License.
|
17 |
|
|
* You may obtain a copy of the License at
|
18 |
fd9ebcd5
|
Stephen Beaver
|
*
|
19 |
b12ea3fb
|
Renato Botelho
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20 |
fd9ebcd5
|
Stephen Beaver
|
*
|
21 |
b12ea3fb
|
Renato Botelho
|
* Unless required by applicable law or agreed to in writing, software
|
22 |
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
23 |
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
24 |
|
|
* See the License for the specific language governing permissions and
|
25 |
|
|
* limitations under the License.
|
26 |
fd9ebcd5
|
Stephen Beaver
|
*/
|
27 |
cf7d1057
|
Scott Ullrich
|
|
28 |
6b07c15a
|
Matthew Grooms
|
##|+PRIV
|
29 |
|
|
##|*IDENT=page-status-ipsec
|
30 |
5230f468
|
jim-p
|
##|*NAME=Status: IPsec
|
31 |
6b07c15a
|
Matthew Grooms
|
##|*DESCR=Allow access to the 'Status: IPsec' page.
|
32 |
1af5edbf
|
Stephen Beaver
|
##|*MATCH=status_ipsec.php*
|
33 |
6b07c15a
|
Matthew Grooms
|
##|-PRIV
|
34 |
|
|
|
35 |
c81ef6e2
|
Phil Davis
|
require_once("guiconfig.inc");
|
36 |
4260c32a
|
Stephen Beaver
|
require_once("ipsec.inc");
|
37 |
bec6dcfb
|
jim-p
|
require_once("service-utils.inc");
|
38 |
|
|
|
39 |
|
|
if ($_POST['act'] == 'connect') {
|
40 |
|
|
/* Assume type is IKE */
|
41 |
|
|
$type = empty($_POST['type']) ? 'ike' : $_POST['type'];
|
42 |
|
|
ipsec_initiate_by_conid($type, $_POST['conid']);
|
43 |
|
|
} elseif ($_POST['act'] == 'disconnect') {
|
44 |
|
|
/* Assume type is IKE */
|
45 |
|
|
$type = empty($_POST['type']) ? 'ike' : $_POST['type'];
|
46 |
|
|
ipsec_terminate_by_conid($type, $_POST['conid'], $_POST['uniqueid']);
|
47 |
|
|
}
|
48 |
4b5f2ab3
|
Phil Davis
|
|
49 |
4260c32a
|
Stephen Beaver
|
// If this is just an AJAX call to update the table body, just generate the body and quit
|
50 |
|
|
if ($_REQUEST['ajax']) {
|
51 |
|
|
print_ipsec_body();
|
52 |
|
|
exit;
|
53 |
|
|
}
|
54 |
a93e56c5
|
Matthew Grooms
|
|
55 |
4260c32a
|
Stephen Beaver
|
// Table body is composed here so that it can be more easily updated via AJAX
|
56 |
|
|
function print_ipsec_body() {
|
57 |
|
|
global $config;
|
58 |
bec6dcfb
|
jim-p
|
|
59 |
|
|
if (!ipsec_enabled()) {
|
60 |
|
|
?>
|
61 |
|
|
<tr>
|
62 |
|
|
<td colspan="10">
|
63 |
|
|
<?php print_info_box(addslashes(gettext("IPsec is disabled.")), "warning", ""); ?>
|
64 |
|
|
</td>
|
65 |
|
|
</tr>
|
66 |
|
|
<?php
|
67 |
|
|
return;
|
68 |
|
|
}
|
69 |
|
|
if (!get_service_status(array('name' => 'ipsec'))) {
|
70 |
|
|
?>
|
71 |
|
|
<tr>
|
72 |
|
|
<td colspan="10">
|
73 |
|
|
<?php print_info_box(addslashes(gettext("IPsec daemon is stopped.")), "warning", ""); ?>
|
74 |
|
|
</td>
|
75 |
|
|
</tr>
|
76 |
|
|
<?php
|
77 |
|
|
return;
|
78 |
4e5857b6
|
jim-p
|
}
|
79 |
|
|
|
80 |
bec6dcfb
|
jim-p
|
$cmap = ipsec_map_config_by_id();
|
81 |
4260c32a
|
Stephen Beaver
|
$status = ipsec_list_sa();
|
82 |
3c5f4441
|
Stephen Jones
|
|
83 |
bec6dcfb
|
jim-p
|
$p1conids = array_column($status, 'con-id');
|
84 |
|
|
$p1uniqueids = array_column($status, 'uniqueid');
|
85 |
|
|
array_multisort($p1conids, SORT_NATURAL,
|
86 |
|
|
$p1uniqueids, SORT_NUMERIC,
|
87 |
|
|
$status);
|
88 |
0da0d43e
|
Phil Davis
|
|
89 |
bec6dcfb
|
jim-p
|
$p1connected = array();
|
90 |
|
|
$p2connected = array();
|
91 |
|
|
if (!is_array($status)) {
|
92 |
|
|
$status = array();
|
93 |
|
|
}
|
94 |
|
|
foreach ($status as $ikesa) {
|
95 |
|
|
list($ikeid, $reqid) = ipsec_id_by_conid($ikesa['con-id']);
|
96 |
|
|
if (!array_key_exists($ikeid, $cmap)) {
|
97 |
|
|
// Doesn't match known tunnel
|
98 |
|
|
$p1connected[$ikesa['con-id']] = $ikesa['con-id'];
|
99 |
|
|
} else {
|
100 |
|
|
$p1connected[$ikeid] = $ph1idx = $ikeid;
|
101 |
|
|
}
|
102 |
|
|
if (array_key_exists('child-sas', $ikesa) && is_array($ikesa['child-sas'])) {
|
103 |
|
|
$p2conids = array_column($ikesa['child-sas'], 'name');
|
104 |
|
|
$p2uniqueids = array_column($ikesa['child-sas'], 'uniqueid');
|
105 |
|
|
array_multisort($p2conids, SORT_NATURAL,
|
106 |
|
|
$p2uniqueids, SORT_NUMERIC,
|
107 |
|
|
$ikesa['child-sas']);
|
108 |
|
|
|
109 |
d35a18fc
|
Christian McDonald
|
foreach ($ikesa['child-sas'] as $childsa) {
|
110 |
bec6dcfb
|
jim-p
|
list($childikeid, $childreqid) = ipsec_id_by_conid($childsa['name']);
|
111 |
|
|
if ($childreqid != null) {
|
112 |
|
|
$p2connected[$childreqid] = $childsa['name'];
|
113 |
4260c32a
|
Stephen Beaver
|
} else {
|
114 |
bec6dcfb
|
jim-p
|
/* If this is IKEv2 w/o Split, mark all reqids for the P1 as connected */
|
115 |
f3554a3c
|
Viktor G
|
if (($cmap[$childikeid]['p1']['iketype'] == 'ikev2') &&
|
116 |
|
|
!isset($cmap[$childikeid]['p1']['splitconn']) &&
|
117 |
|
|
isset($cmap[$ikeid]['p2']) && is_array($cmap[$ikeid]['p2'])) {
|
118 |
bec6dcfb
|
jim-p
|
foreach ($cmap[$ikeid]['p2'] as $p2) {
|
119 |
|
|
$p2connected[$p2['reqid']] = $childsa['name'];
|
120 |
|
|
}
|
121 |
8af4e81e
|
jim-p
|
}
|
122 |
|
|
}
|
123 |
86b2861c
|
Matt Smith
|
}
|
124 |
bec6dcfb
|
jim-p
|
}
|
125 |
|
|
$p2disconnected = array();
|
126 |
|
|
if (!$cmap[$ikeid]['p1']['mobile'] &&
|
127 |
|
|
isset($cmap[$ikeid]) &&
|
128 |
|
|
is_array($cmap[$ikeid]) &&
|
129 |
|
|
is_array($cmap[$ikeid]['p2'])) {
|
130 |
|
|
foreach ($cmap[$ikeid]['p2'] as $p2) {
|
131 |
|
|
if (!array_key_exists($p2['reqid'], $p2connected)) {
|
132 |
|
|
/* This P2 is not connected */
|
133 |
|
|
$p2conid = ipsec_conid($cmap[$ikeid]['p1'], $p2);
|
134 |
|
|
$p2disconnected[$p2conid] = $p2;
|
135 |
8af4e81e
|
jim-p
|
}
|
136 |
4260c32a
|
Stephen Beaver
|
}
|
137 |
bec6dcfb
|
jim-p
|
}
|
138 |
|
|
?>
|
139 |
4260c32a
|
Stephen Beaver
|
|
140 |
bec6dcfb
|
jim-p
|
<tr>
|
141 |
|
|
<td>
|
142 |
|
|
<?= htmlspecialchars($ikesa['con-id']) ?>
|
143 |
|
|
#<?= htmlspecialchars($ikesa['uniqueid']) ?>
|
144 |
|
|
</td>
|
145 |
|
|
<td>
|
146 |
|
|
<?= htmlspecialchars($cmap[$ikeid]['p1']['descr']) ?>
|
147 |
|
|
<br/>
|
148 |
|
|
<a class="fa fa-pencil" href="vpn_ipsec_phase1.php?ikeid=<?= htmlspecialchars($ikeid) ?>"
|
149 |
|
|
title="<?= htmlspecialchars(gettext("Edit Phase 1 Entry")) ?>">
|
150 |
|
|
</a>
|
151 |
|
|
</td>
|
152 |
|
|
<td>
|
153 |
|
|
<b>ID:</b>
|
154 |
|
|
<?php
|
155 |
|
|
$localid = gettext("Unknown");
|
156 |
|
|
if (!empty($ikesa['local-id'])) {
|
157 |
|
|
if ($ikesa['local-id'] == '%any') {
|
158 |
|
|
$localid = gettext('Any identifier');
|
159 |
4260c32a
|
Stephen Beaver
|
} else {
|
160 |
bec6dcfb
|
jim-p
|
$localid = $ikesa['local-id'];
|
161 |
4260c32a
|
Stephen Beaver
|
}
|
162 |
bec6dcfb
|
jim-p
|
}
|
163 |
|
|
?>
|
164 |
|
|
<?= htmlspecialchars($localid) ?>
|
165 |
|
|
<br/>
|
166 |
|
|
<b><?= htmlspecialchars(gettext("Host:")); ?></b>
|
167 |
|
|
<?php
|
168 |
|
|
$lhost = gettext("Unknown");
|
169 |
|
|
if (!empty($ikesa['local-host'])) {
|
170 |
|
|
$lhost = $ikesa['local-host'];
|
171 |
|
|
if (!empty($ikesa['local-port'])) {
|
172 |
|
|
if (is_ipaddrv6($ikesa['local-host'])) {
|
173 |
|
|
$lhost = "[{$lhost}]";
|
174 |
9701089e
|
jim-p
|
}
|
175 |
bec6dcfb
|
jim-p
|
$lhost .= ":{$ikesa['local-port']}";
|
176 |
8af4e81e
|
jim-p
|
}
|
177 |
bec6dcfb
|
jim-p
|
}
|
178 |
|
|
?>
|
179 |
|
|
<?= htmlspecialchars($lhost) ?>
|
180 |
|
|
<br/>
|
181 |
|
|
<b>SPI:</b>
|
182 |
|
|
<?= htmlspecialchars( ($ikesa['initiator'] == 'yes') ? $ikesa['initiator-spi'] : $ikesa['responder-spi'] ) ?>
|
183 |
|
|
<?php if (isset($ikesa['nat-local'])): ?>
|
184 |
|
|
<?= htmlspecialchars(gettext("NAT-T")); ?>
|
185 |
|
|
<?php endif; ?>
|
186 |
|
|
</td>
|
187 |
|
|
<td>
|
188 |
|
|
<b>ID:</b>
|
189 |
|
|
<?php
|
190 |
|
|
$identity = "";
|
191 |
|
|
if (!empty($ikesa['remote-id'])) {
|
192 |
|
|
if ($ikesa['remote-id'] == '%any') {
|
193 |
|
|
$identity = gettext('Any identifier');
|
194 |
4260c32a
|
Stephen Beaver
|
} else {
|
195 |
bec6dcfb
|
jim-p
|
$identity = $ikesa['remote-id'];
|
196 |
4260c32a
|
Stephen Beaver
|
}
|
197 |
bec6dcfb
|
jim-p
|
}
|
198 |
|
|
$remoteid = "";
|
199 |
|
|
if (!empty($ikesa['remote-xauth-id'])) {
|
200 |
|
|
$remoteid = $ikesa['remote-xauth-id'];
|
201 |
|
|
} elseif (!empty($ikesa['remote-eap-id'])) {
|
202 |
|
|
$remoteid = $ikesa['remote-eap-id'];
|
203 |
|
|
} else {
|
204 |
|
|
if (empty($identity)) {
|
205 |
|
|
$identity = gettext("Unknown");
|
206 |
9e820b59
|
Phil Davis
|
}
|
207 |
bec6dcfb
|
jim-p
|
}
|
208 |
|
|
?>
|
209 |
|
|
<?php if (!empty($remoteid)): ?>
|
210 |
|
|
<?= htmlspecialchars($remoteid) ?><br/>
|
211 |
|
|
<?php endif; ?>
|
212 |
|
|
<?= htmlspecialchars($identity) ?>
|
213 |
|
|
<br/>
|
214 |
|
|
<b><?= htmlspecialchars(gettext("Host:")); ?></b>
|
215 |
|
|
<?php
|
216 |
|
|
$rhost = gettext("Unknown");
|
217 |
|
|
if (!empty($ikesa['remote-host'])) {
|
218 |
|
|
$rhost = $ikesa['remote-host'];
|
219 |
|
|
if (!empty($ikesa['remote-port'])) {
|
220 |
|
|
if (is_ipaddrv6($ikesa['remote-host'])) {
|
221 |
|
|
$rhost = "[{$rhost}]";
|
222 |
|
|
}
|
223 |
|
|
$rhost .= ":{$ikesa['remote-port']}";
|
224 |
4260c32a
|
Stephen Beaver
|
}
|
225 |
bec6dcfb
|
jim-p
|
}
|
226 |
|
|
?>
|
227 |
|
|
<?= htmlspecialchars($rhost) ?>
|
228 |
|
|
<?php if (isset($ikesa['nat-remote'])): ?>
|
229 |
|
|
<?= htmlspecialchars(gettext("NAT-T")); ?>
|
230 |
|
|
<?php endif; ?>
|
231 |
|
|
<br/>
|
232 |
|
|
<b>SPI:</b>
|
233 |
|
|
<?= htmlspecialchars( ($ikesa['initiator'] == 'yes') ? $ikesa['responder-spi'] : $ikesa['initiator-spi'] ) ?>
|
234 |
|
|
</td>
|
235 |
|
|
<td>
|
236 |
|
|
IKEv<?= htmlspecialchars($ikesa['version']) ?><br/>
|
237 |
|
|
<?php if ($ikesa['initiator'] == 'yes'): ?>
|
238 |
|
|
<?= htmlspecialchars(gettext("Initiator")); ?>
|
239 |
|
|
<?php else: ?>
|
240 |
|
|
<?= htmlspecialchars(gettext("Responder")); ?>
|
241 |
|
|
<?php endif; ?>
|
242 |
|
|
</td>
|
243 |
|
|
<td>
|
244 |
|
|
<?php if ($ikesa['version'] == 2): ?>
|
245 |
|
|
<b><?= htmlspecialchars(gettext("Rekey:")) ?></b>
|
246 |
|
|
<?php if (!empty($ikesa['rekey-time'])): ?>
|
247 |
|
|
<?= htmlspecialchars($ikesa['rekey-time']) ?>s
|
248 |
|
|
(<?= convert_seconds_to_dhms($ikesa['rekey-time']) ?>)
|
249 |
|
|
<?php else: ?>
|
250 |
|
|
<?= htmlspecialchars(gettext("Disabled")) ?>
|
251 |
|
|
<?php endif; ?>
|
252 |
|
|
<br/>
|
253 |
|
|
<?php endif; ?>
|
254 |
|
|
<b><?= htmlspecialchars(gettext("Reauth:")) ?></b>
|
255 |
|
|
<?php if (!empty($ikesa['reauth-time'])): ?>
|
256 |
|
|
<?= htmlspecialchars(htmlspecialchars($ikesa['reauth-time'])) ?>s
|
257 |
|
|
(<?= convert_seconds_to_dhms($ikesa['reauth-time']) ?>)
|
258 |
|
|
<?php else: ?>
|
259 |
|
|
<?= htmlspecialchars(gettext("Disabled")) ?>
|
260 |
|
|
<?php endif; ?>
|
261 |
|
|
</td>
|
262 |
|
|
<td>
|
263 |
|
|
<?= htmlspecialchars($ikesa['encr-alg']) ?>
|
264 |
|
|
<?php if (!empty($ikesa['encr-keysize'])): ?>
|
265 |
|
|
(<?= htmlspecialchars($ikesa['encr-keysize']) ?>)
|
266 |
|
|
<?php endif; ?>
|
267 |
|
|
<br/>
|
268 |
|
|
<?= htmlspecialchars($ikesa['integ-alg']) ?><br/>
|
269 |
|
|
<?= htmlspecialchars($ikesa['prf-alg']) ?><br/>
|
270 |
|
|
<?= htmlspecialchars($ikesa['dh-group']) ?><br/>
|
271 |
|
|
</td>
|
272 |
|
|
<td>
|
273 |
|
|
<span<?= ($ikesa['state'] == 'ESTABLISHED') ? ' class="text-success"' : '' ; ?>>
|
274 |
|
|
<?= htmlspecialchars(ucfirst(strtolower($ikesa['state']))) ?>
|
275 |
|
|
<?php if ($ikesa['state'] == 'ESTABLISHED'): ?>
|
276 |
|
|
<br/>
|
277 |
|
|
<? printf(gettext('%1$s seconds (%2$s) ago'), htmlspecialchars($ikesa['established']), convert_seconds_to_dhms($ikesa['established'])) ?>
|
278 |
|
|
<?php endif; ?>
|
279 |
|
|
</span>
|
280 |
|
|
<br/>
|
281 |
|
|
<br/>
|
282 |
cbd2aad1
|
jim-p
|
<?php if (!in_array($ikesa['state'], array('ESTABLISHED', 'CONNECTING'))): ?>
|
283 |
bec6dcfb
|
jim-p
|
<?= ipsec_status_button('ajax', 'connect', 'all', $ikesa['con-id'], null, true) ?>
|
284 |
|
|
<?php else: ?>
|
285 |
|
|
<?= ipsec_status_button('ajax', 'disconnect', 'ike', $ikesa['con-id'], $ikesa['uniqueid'], true) ?>
|
286 |
|
|
<?php endif; ?>
|
287 |
|
|
<br>
|
288 |
cbd2aad1
|
jim-p
|
<?php if (empty($ikesa['child-sas']) && ($ikesa['state'] != 'CONNECTING')): ?>
|
289 |
bec6dcfb
|
jim-p
|
<br/>
|
290 |
|
|
<?= ipsec_status_button('ajax', 'connect', 'all', $ikesa['con-id'], null, true) ?>
|
291 |
|
|
<?php endif; ?>
|
292 |
|
|
</td>
|
293 |
|
|
</tr>
|
294 |
|
|
<tr>
|
295 |
|
|
<td colspan="10">
|
296 |
|
|
<?php $child_key = "{$ikesa['con-id']}_{$ikesa['uniqueid']}_children"; ?>
|
297 |
|
|
<div>
|
298 |
|
|
<?php if ((count($ikesa['child-sas']) + count($p2disconnected)) > 0): ?>
|
299 |
|
|
<a type="button" id="btnchildsa-<?= htmlspecialchars($child_key) ?>" class="btn btn-sm btn-info">
|
300 |
|
|
<i class="fa fa-plus-circle icon-embed-btn"></i>
|
301 |
|
|
<?= htmlspecialchars(gettext('Show child SA entries')) ?>
|
302 |
|
|
<?php
|
303 |
|
|
$p2counts = count($ikesa['child-sas']) . " " . gettext("Connected");
|
304 |
|
|
if (count($p2disconnected) > 0) {
|
305 |
|
|
$p2counts .= ", " . count($p2disconnected) . " " . gettext("Disconnected");
|
306 |
c6220dcf
|
jim-p
|
}
|
307 |
bec6dcfb
|
jim-p
|
?>
|
308 |
|
|
(<?= htmlspecialchars($p2counts) ?>)
|
309 |
|
|
<?php endif; ?>
|
310 |
|
|
</a>
|
311 |
|
|
</div>
|
312 |
|
|
<table class="table table-hover table-condensed" id="childsa-<?= htmlspecialchars($child_key) ?>" style="display:none">
|
313 |
|
|
<thead>
|
314 |
|
|
<tr class="bg-info">
|
315 |
|
|
<th><?= htmlspecialchars(gettext("ID")) ?></th>
|
316 |
|
|
<th><?= htmlspecialchars(gettext("Description")) ?></th>
|
317 |
|
|
<th><?= htmlspecialchars(gettext("Local")) ?></th>
|
318 |
|
|
<th><?= htmlspecialchars(gettext("SPI(s)")) ?></th>
|
319 |
|
|
<th><?= htmlspecialchars(gettext("Remote")) ?></th>
|
320 |
|
|
<th><?= htmlspecialchars(gettext("Times")) ?></th>
|
321 |
|
|
<th><?= htmlspecialchars(gettext("Algo")) ?></th>
|
322 |
|
|
<th><?= htmlspecialchars(gettext("Stats")) ?></th>
|
323 |
|
|
<th><!-- Buttons --></th>
|
324 |
|
|
</tr>
|
325 |
|
|
</thead>
|
326 |
|
|
<tbody>
|
327 |
|
|
<?php if (is_array($ikesa['child-sas']) && (count($ikesa['child-sas']) > 0)) {
|
328 |
d35a18fc
|
Christian McDonald
|
foreach ($ikesa['child-sas'] as $childsa) {
|
329 |
bec6dcfb
|
jim-p
|
list($childikeid, $childreqid) = ipsec_id_by_conid($childsa['name']);
|
330 |
|
|
?>
|
331 |
|
|
<tr>
|
332 |
|
|
<td>
|
333 |
|
|
<?= htmlspecialchars($childsa['name']) ?>:<br />
|
334 |
|
|
#<?= htmlspecialchars($childsa['uniqueid']) ?>
|
335 |
|
|
</td>
|
336 |
|
|
<td>
|
337 |
|
|
<?php
|
338 |
|
|
$p2descr = "";
|
339 |
|
|
$p2uid = "";
|
340 |
|
|
if (!empty($childreqid)) {
|
341 |
|
|
/* IKEv1 or IKEv2+Split */
|
342 |
|
|
$p2descr = $cmap[$childikeid]['p2'][$childreqid]['descr'];
|
343 |
|
|
$p2uid = $cmap[$childikeid]['p2'][$childreqid]['uniqid'];
|
344 |
bfb06f9a
|
jim-p
|
} else {
|
345 |
bec6dcfb
|
jim-p
|
$childreqid = array_key_first($cmap[$childikeid]['p2']);
|
346 |
|
|
$p2uid = $cmap[$childikeid]['p2'][$childreqid]['uniqid'];
|
347 |
|
|
if (count($cmap[$childikeid]['p2']) > 1) {
|
348 |
|
|
$p2descr = gettext("Multiple");
|
349 |
4260c32a
|
Stephen Beaver
|
} else {
|
350 |
bec6dcfb
|
jim-p
|
$p2descr = $cmap[$childikeid]['p2'][$childreqid]['descr'];
|
351 |
4260c32a
|
Stephen Beaver
|
}
|
352 |
bec6dcfb
|
jim-p
|
}
|
353 |
|
|
?>
|
354 |
|
|
<?= htmlspecialchars($p2descr) ?>
|
355 |
|
|
<?php if (!empty($p2uid) && ($p2descr != gettext("Multiple"))): ?>
|
356 |
|
|
<br/>
|
357 |
|
|
<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?uniqid=<?= htmlspecialchars($p2uid) ?>"
|
358 |
|
|
title="<?= gettext("Edit Phase 2 Entry") ?>">
|
359 |
|
|
</a>
|
360 |
|
|
<?php endif ?>
|
361 |
|
|
</td>
|
362 |
|
|
<td>
|
363 |
|
|
<?php
|
364 |
|
|
$lnetlist = array();
|
365 |
|
|
if (is_array($childsa['local-ts'])) {
|
366 |
|
|
foreach ($childsa['local-ts'] as $lnets) {
|
367 |
|
|
$lnetlist[] = htmlspecialchars(ipsec_fixup_network($lnets));
|
368 |
4260c32a
|
Stephen Beaver
|
}
|
369 |
bec6dcfb
|
jim-p
|
} else {
|
370 |
|
|
$lnetlist[] = htmlspecialchars(gettext("Unknown"));
|
371 |
|
|
}
|
372 |
|
|
?>
|
373 |
b751eaa9
|
jim-p
|
<?= implode('<br/>', $lnetlist) ?>
|
374 |
bec6dcfb
|
jim-p
|
</td>
|
375 |
|
|
<td>
|
376 |
|
|
<?php
|
377 |
|
|
if (isset($childsa['spi-in'])) {
|
378 |
|
|
?>
|
379 |
|
|
<b><?= htmlspecialchars(gettext("Local:")) ?></b>
|
380 |
|
|
<?= htmlspecialchars($childsa['spi-in']) ?>
|
381 |
|
|
<?php
|
382 |
|
|
}
|
383 |
|
|
if (isset($childsa['spi-out'])) {
|
384 |
|
|
?>
|
385 |
|
|
<br/>
|
386 |
|
|
<b><?= htmlspecialchars(gettext("Remote:")) ?></b>
|
387 |
|
|
<?= htmlspecialchars($childsa['spi-out']) ?>
|
388 |
|
|
<?php
|
389 |
|
|
}
|
390 |
|
|
?>
|
391 |
|
|
</td>
|
392 |
|
|
<td>
|
393 |
|
|
<?php
|
394 |
|
|
$rnetlist = array();
|
395 |
|
|
if (is_array($childsa['remote-ts'])) {
|
396 |
|
|
foreach ($childsa['remote-ts'] as $rnets) {
|
397 |
|
|
$rnetlist[] = htmlspecialchars(ipsec_fixup_network($rnets));
|
398 |
4260c32a
|
Stephen Beaver
|
}
|
399 |
bec6dcfb
|
jim-p
|
} else {
|
400 |
|
|
$rnetlist[] = htmlspecialchars(gettext("Unknown"));
|
401 |
4260c32a
|
Stephen Beaver
|
}
|
402 |
bec6dcfb
|
jim-p
|
?>
|
403 |
b751eaa9
|
jim-p
|
<?= implode('<br/>', $rnetlist) ?>
|
404 |
bec6dcfb
|
jim-p
|
</td>
|
405 |
|
|
<td>
|
406 |
|
|
<b><?= htmlspecialchars(gettext("Rekey:")) ?></b>
|
407 |
|
|
<?= htmlspecialchars($childsa['rekey-time']) ?>s
|
408 |
|
|
(<?= convert_seconds_to_dhms($childsa['rekey-time']) ?>)
|
409 |
|
|
<br/>
|
410 |
|
|
|
411 |
|
|
<b><?= htmlspecialchars(gettext("Life:")) ?></b>
|
412 |
|
|
<?= htmlspecialchars($childsa['life-time']) ?>s
|
413 |
|
|
(<?= convert_seconds_to_dhms($childsa['life-time']) ?>)
|
414 |
|
|
<br/>
|
415 |
|
|
|
416 |
|
|
<b><?= htmlspecialchars(gettext("Install:")) ?></b>
|
417 |
|
|
<?= htmlspecialchars($childsa['install-time']) ?>s
|
418 |
|
|
(<?= convert_seconds_to_dhms($childsa['install-time']) ?>)
|
419 |
|
|
</td>
|
420 |
|
|
<td>
|
421 |
|
|
<?= htmlspecialchars($childsa['encr-alg']) ?>
|
422 |
|
|
<?php if (!empty($childsa['encr-keysize'])): ?>
|
423 |
|
|
(<?= htmlspecialchars($childsa['encr-keysize']) ?>)
|
424 |
|
|
<?php endif; ?>
|
425 |
|
|
<br/>
|
426 |
|
|
<?= htmlspecialchars($childsa['integ-alg']) ?>
|
427 |
|
|
<br/>
|
428 |
|
|
<?php if (!empty($childsa['prf-alg'])): ?>
|
429 |
|
|
<?= htmlspecialchars($childsa['prf-alg']) ?>
|
430 |
|
|
<br/>
|
431 |
|
|
<?php endif; ?>
|
432 |
|
|
<?php if (!empty($childsa['dh-group'])): ?>
|
433 |
|
|
<?= htmlspecialchars($childsa['dh-group']) ?>
|
434 |
|
|
<br/>
|
435 |
|
|
<?php endif; ?>
|
436 |
|
|
<?php if (!empty($childsa['esn'])): ?>
|
437 |
|
|
<?= htmlspecialchars($childsa['esn']) ?>
|
438 |
|
|
<br/>
|
439 |
|
|
<?php endif;
|
440 |
|
|
$ipcomp = gettext('None');
|
441 |
|
|
if (!empty($childsa['cpi-in']) || !empty($childsa['cpi-out'])) {
|
442 |
|
|
$ipcomp = "{$childsa['cpi-in']} {$childsa['cpi-out']}";
|
443 |
|
|
}
|
444 |
|
|
?>
|
445 |
|
|
<?= htmlspecialchars(gettext("IPComp: ")) ?> <?= htmlspecialchars($ipcomp) ?>
|
446 |
|
|
</td>
|
447 |
|
|
<td>
|
448 |
|
|
<b><?= htmlspecialchars(gettext("Bytes-In:")) ?></b>
|
449 |
|
|
<?= htmlspecialchars(number_format($childsa['bytes-in'])) ?>
|
450 |
|
|
(<?= htmlspecialchars(format_bytes($childsa['bytes-in'])) ?>)
|
451 |
|
|
<br/>
|
452 |
|
|
<b><?= htmlspecialchars(gettext("Packets-In:")) ?></b>
|
453 |
|
|
<?= htmlspecialchars(number_format($childsa['packets-in'])) ?>
|
454 |
|
|
<br/>
|
455 |
|
|
<b><?= htmlspecialchars(gettext("Bytes-Out:")) ?></b>
|
456 |
|
|
<?= htmlspecialchars(number_format($childsa['bytes-out'])) ?>
|
457 |
|
|
(<?= htmlspecialchars(format_bytes($childsa['bytes-out'])) ?>)
|
458 |
|
|
<br/>
|
459 |
|
|
<b><?= htmlspecialchars(gettext("Packets-Out:")) ?></b>
|
460 |
|
|
<?= htmlspecialchars(number_format($childsa['packets-out'])) ?>
|
461 |
|
|
<br/>
|
462 |
|
|
</td>
|
463 |
|
|
<td>
|
464 |
|
|
|
465 |
|
|
<?= htmlspecialchars(ucfirst(strtolower($childsa['state']))) ?><br/>
|
466 |
|
|
<?= ipsec_status_button('ajax', 'disconnect', 'child', $childsa['name'], $childsa['uniqueid'], true) ?>
|
467 |
|
|
</td>
|
468 |
|
|
<?php
|
469 |
3795cc0a
|
sbeaver
|
}
|
470 |
bec6dcfb
|
jim-p
|
?>
|
471 |
|
|
</tr>
|
472 |
|
|
<?php
|
473 |
86b2861c
|
Matt Smith
|
}
|
474 |
bec6dcfb
|
jim-p
|
foreach ($p2disconnected as $p2conid => $p2) {
|
475 |
|
|
?>
|
476 |
|
|
<tr>
|
477 |
|
|
<td><?= htmlspecialchars($p2conid) ?></td>
|
478 |
|
|
<td>
|
479 |
|
|
<?= htmlspecialchars($p2['descr']) ?>
|
480 |
|
|
<br/>
|
481 |
|
|
<a class="fa fa-pencil" href="vpn_ipsec_phase2.php?uniqid=<?= htmlspecialchars($p2['uniqid']) ?>"
|
482 |
|
|
title="<?= htmlspecialchars(gettext("Edit Phase 2 Entry")) ?>">
|
483 |
|
|
</a>
|
484 |
|
|
</td>
|
485 |
|
|
<td>
|
486 |
|
|
<?= htmlspecialchars(ipsec_idinfo_to_cidr($p2['localid'], false, $p2['mode'])) ?>
|
487 |
|
|
</td>
|
488 |
|
|
<td><!-- SPI n/a --></td>
|
489 |
|
|
<td>
|
490 |
|
|
<?= htmlspecialchars(ipsec_idinfo_to_cidr($p2['remoteid'], false, $p2['mode'])) ?>
|
491 |
|
|
</td>
|
492 |
|
|
<td><!-- Times n/a --></td>
|
493 |
|
|
<td><!-- Algo is too much here --></td>
|
494 |
|
|
<td><!-- Stats n/a --></td>
|
495 |
|
|
<td>
|
496 |
|
|
<?= htmlspecialchars(gettext("Disconnected")) ?><br/>
|
497 |
|
|
<?= ipsec_status_button('ajax', 'connect', 'child', $p2conid, null, true) ?>
|
498 |
|
|
</td>
|
499 |
|
|
</tr>
|
500 |
|
|
<?php
|
501 |
|
|
}
|
502 |
|
|
?>
|
503 |
|
|
</tbody>
|
504 |
|
|
</table>
|
505 |
|
|
</td>
|
506 |
|
|
</tr>
|
507 |
|
|
<?php
|
508 |
4260c32a
|
Stephen Beaver
|
}
|
509 |
|
|
|
510 |
|
|
$rgmap = array();
|
511 |
bec6dcfb
|
jim-p
|
$gateways_status = return_gateways_status(true);
|
512 |
8af4e81e
|
jim-p
|
|
513 |
bec6dcfb
|
jim-p
|
foreach ($cmap as $p1) {
|
514 |
|
|
if (!array_key_exists('p1', $p1) ||
|
515 |
|
|
isset($p1['p1']['disabled'])) {
|
516 |
|
|
continue;
|
517 |
|
|
}
|
518 |
|
|
$ph1ent = &$p1['p1'];
|
519 |
|
|
$rgmap[$ph1ent['remote-gateway']] = $ph1ent['remote-gateway'];
|
520 |
|
|
if ($p1connected[$ph1ent['ikeid']]) {
|
521 |
|
|
continue;
|
522 |
|
|
}
|
523 |
|
|
?>
|
524 |
|
|
<tr>
|
525 |
|
|
<td>
|
526 |
|
|
<?= htmlspecialchars(ipsec_conid($ph1ent)) ?>
|
527 |
|
|
</td>
|
528 |
|
|
<td>
|
529 |
|
|
<?= htmlspecialchars($ph1ent['descr']) ?>
|
530 |
|
|
</td>
|
531 |
|
|
<td>
|
532 |
|
|
<b><?= htmlspecialchars(gettext("ID:")) ?></b>
|
533 |
|
|
<?php
|
534 |
|
|
list ($myid_type, $myid_data) = ipsec_find_id($ph1ent, "local", array(), $gateways_status);
|
535 |
|
|
if (empty($myid_data)) {
|
536 |
|
|
$myid_data = gettext("Unknown");
|
537 |
4260c32a
|
Stephen Beaver
|
}
|
538 |
bec6dcfb
|
jim-p
|
?>
|
539 |
|
|
<?= htmlspecialchars($myid_data) ?>
|
540 |
|
|
<br/>
|
541 |
|
|
<b><?= htmlspecialchars(gettext("Host:")) ?></b>
|
542 |
|
|
<?php
|
543 |
|
|
$ph1src = ipsec_get_phase1_src($ph1ent, $gateways_status);
|
544 |
|
|
if (empty($ph1src)) {
|
545 |
|
|
$ph1src = gettext("Unknown");
|
546 |
|
|
} else {
|
547 |
|
|
$ph1src = str_replace(',', ', ', $ph1src);
|
548 |
|
|
}
|
549 |
|
|
?>
|
550 |
|
|
<?= htmlspecialchars($ph1src) ?>
|
551 |
|
|
</td>
|
552 |
|
|
<td>
|
553 |
|
|
<?php if (!isset($ph1ent['mobile'])): ?>
|
554 |
|
|
<b><?= htmlspecialchars(gettext("ID:")) ?></b>
|
555 |
|
|
<?php
|
556 |
|
|
list ($peerid_type, $peerid_data) = ipsec_find_id($ph1ent, "peer", $rgmap, $gateways_status);
|
557 |
|
|
if (empty($peerid_data)) {
|
558 |
|
|
$peerid_data = gettext("Unknown");
|
559 |
|
|
}
|
560 |
|
|
?>
|
561 |
|
|
<?= htmlspecialchars($peerid_data) ?>
|
562 |
|
|
<br/>
|
563 |
|
|
<b><?= htmlspecialchars(gettext("Host:")) ?></b>
|
564 |
|
|
<?php
|
565 |
|
|
$ph1dst = ipsec_get_phase1_dst($ph1ent);
|
566 |
|
|
if (empty($ph1dst)) {
|
567 |
|
|
$ph1dst = print(gettext("Unknown"));
|
568 |
|
|
}
|
569 |
|
|
?>
|
570 |
|
|
<?= htmlspecialchars($ph1dst) ?>
|
571 |
|
|
<?php else: ?>
|
572 |
|
|
<?= htmlspecialchars(gettext("Mobile Clients")) ?>
|
573 |
|
|
<?php endif; ?>
|
574 |
|
|
</td>
|
575 |
|
|
<td></td>
|
576 |
|
|
<td></td>
|
577 |
|
|
<td></td>
|
578 |
|
|
<td>
|
579 |
|
|
<?php if (isset($ph1ent['mobile'])): ?>
|
580 |
|
|
<?= htmlspecialchars(gettext("Awaiting connections")) ?>
|
581 |
|
|
<?php else: ?>
|
582 |
|
|
<?= htmlspecialchars(gettext("Disconnected")) ?>
|
583 |
|
|
<br/>
|
584 |
|
|
<?= ipsec_status_button('ajax', 'connect', 'all', ipsec_conid($ph1ent), null, true) ?>
|
585 |
|
|
<br/><br/>
|
586 |
|
|
<?= ipsec_status_button('ajax', 'connect', 'ike', ipsec_conid($ph1ent), null, true) ?>
|
587 |
|
|
|
588 |
|
|
<?php endif; ?>
|
589 |
|
|
</td>
|
590 |
|
|
</tr>
|
591 |
|
|
<?php
|
592 |
97242546
|
Matt Smith
|
}
|
593 |
bec6dcfb
|
jim-p
|
unset($p1connected, $p2connected, $p2disconnected, $rgmap);
|
594 |
86b2861c
|
Matt Smith
|
}
|
595 |
3795cc0a
|
sbeaver
|
|
596 |
4260c32a
|
Stephen Beaver
|
$pgtitle = array(gettext("Status"), gettext("IPsec"), gettext("Overview"));
|
597 |
edcd7535
|
Phil Davis
|
$pglinks = array("", "@self", "@self");
|
598 |
4260c32a
|
Stephen Beaver
|
$shortcut_section = "ipsec";
|
599 |
0da0d43e
|
Phil Davis
|
|
600 |
4260c32a
|
Stephen Beaver
|
include("head.inc");
|
601 |
0da0d43e
|
Phil Davis
|
|
602 |
4260c32a
|
Stephen Beaver
|
$tab_array = array();
|
603 |
|
|
$tab_array[] = array(gettext("Overview"), true, "status_ipsec.php");
|
604 |
|
|
$tab_array[] = array(gettext("Leases"), false, "status_ipsec_leases.php");
|
605 |
|
|
$tab_array[] = array(gettext("SADs"), false, "status_ipsec_sad.php");
|
606 |
|
|
$tab_array[] = array(gettext("SPDs"), false, "status_ipsec_spd.php");
|
607 |
|
|
display_top_tabs($tab_array);
|
608 |
3795cc0a
|
sbeaver
|
?>
|
609 |
0da0d43e
|
Phil Davis
|
|
610 |
4260c32a
|
Stephen Beaver
|
<div class="panel panel-default">
|
611 |
bec6dcfb
|
jim-p
|
<div class="panel-heading"><h2 class="panel-title"><?= htmlspecialchars(gettext("IPsec Status")); ?></h2></div>
|
612 |
4260c32a
|
Stephen Beaver
|
<div class="panel-body table-responsive">
|
613 |
|
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap" data-sortable>
|
614 |
|
|
<thead>
|
615 |
|
|
<tr>
|
616 |
bec6dcfb
|
jim-p
|
<th><?= htmlspecialchars(gettext("ID")) ?></th>
|
617 |
|
|
<th><?= htmlspecialchars(gettext("Description") )?></th>
|
618 |
|
|
<th><?= htmlspecialchars(gettext("Local")) ?></th>
|
619 |
|
|
<th><?= htmlspecialchars(gettext("Remote")) ?></th>
|
620 |
|
|
<th><?= htmlspecialchars(gettext("Role")) ?></th>
|
621 |
|
|
<th><?= htmlspecialchars(gettext("Timers")) ?></th>
|
622 |
|
|
<th><?= htmlspecialchars(gettext("Algo")) ?></th>
|
623 |
|
|
<th><?= htmlspecialchars(gettext("Status")) ?></th>
|
624 |
4260c32a
|
Stephen Beaver
|
</tr>
|
625 |
|
|
</thead>
|
626 |
|
|
<tbody id="ipsec-body">
|
627 |
|
|
<tr>
|
628 |
fc48da17
|
NOYB
|
<td colspan="10">
|
629 |
bec6dcfb
|
jim-p
|
<?= print_info_box('<i class="fa fa-gear fa-spin"></i> ' .
|
630 |
|
|
gettext("Collecting IPsec status information."), "warning", "") ?>
|
631 |
3795cc0a
|
sbeaver
|
</td>
|
632 |
|
|
</tr>
|
633 |
|
|
</tbody>
|
634 |
c7fbdd6c
|
Ermal
|
</table>
|
635 |
|
|
</div>
|
636 |
3795cc0a
|
sbeaver
|
</div>
|
637 |
|
|
|
638 |
|
|
<?php
|
639 |
|
|
unset($status);
|
640 |
4260c32a
|
Stephen Beaver
|
|
641 |
d2c1089f
|
Phil Davis
|
if (ipsec_enabled()) {
|
642 |
4260c32a
|
Stephen Beaver
|
print('<div class="infoblock">');
|
643 |
d2c1089f
|
Phil Davis
|
} else {
|
644 |
4260c32a
|
Stephen Beaver
|
print('<div class="infoblock blockopen">');
|
645 |
d2c1089f
|
Phil Davis
|
}
|
646 |
4260c32a
|
Stephen Beaver
|
|
647 |
a1ca121f
|
Christopher
|
print_info_box(sprintf(gettext('%1$sConfigure IPsec%2$s.'), '<a href="vpn_ipsec.php">', '</a>'), 'info', false);
|
648 |
d2c1089f
|
Phil Davis
|
?>
|
649 |
|
|
</div>
|
650 |
4260c32a
|
Stephen Beaver
|
|
651 |
|
|
<script type="text/javascript">
|
652 |
|
|
//<![CDATA[
|
653 |
|
|
|
654 |
|
|
events.push(function() {
|
655 |
067551a4
|
Stephen Beaver
|
ajax_lock = false; // Mutex so we don't make a call until the previous call is finished
|
656 |
|
|
sa_open = new Array(); // Array in which to keep the child SA show/hide state
|
657 |
29c1ecb8
|
Stephen Jones
|
tryCount = 3;
|
658 |
4260c32a
|
Stephen Beaver
|
// Fetch the tbody contents from the server
|
659 |
|
|
function update_table() {
|
660 |
|
|
if (ajax_lock) {
|
661 |
|
|
return;
|
662 |
|
|
}
|
663 |
|
|
|
664 |
|
|
ajax_lock = true;
|
665 |
|
|
|
666 |
|
|
ajaxRequest = $.ajax(
|
667 |
|
|
{
|
668 |
|
|
url: "/status_ipsec.php",
|
669 |
|
|
type: "post",
|
670 |
|
|
data: {
|
671 |
|
|
ajax: "ajax"
|
672 |
1144e24c
|
Steve Beaver
|
},
|
673 |
|
|
error: function(xhr, textStatus, errorThrown){
|
674 |
|
|
//alert("error.... retrying");
|
675 |
29c1ecb8
|
Stephen Jones
|
if (tryCount > 0){
|
676 |
|
|
tryCount --;
|
677 |
1144e24c
|
Steve Beaver
|
ajax_lock = false;
|
678 |
|
|
update_table();
|
679 |
|
|
}
|
680 |
|
|
return;
|
681 |
4260c32a
|
Stephen Beaver
|
}
|
682 |
|
|
}
|
683 |
|
|
);
|
684 |
|
|
|
685 |
|
|
// Deal with the results of the above ajax call
|
686 |
|
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
687 |
29c1ecb8
|
Stephen Jones
|
if(textStatus === "success"){
|
688 |
|
|
tryCount =3;
|
689 |
|
|
}
|
690 |
fc48da17
|
NOYB
|
if (!response) {
|
691 |
2807660f
|
Stephen Jones
|
response = '<tr><td colspan="10"><?=print_info_box(addslashes(gettext("No IPsec status information available.")), "warning", "")?></td></tr>';
|
692 |
fc48da17
|
NOYB
|
}
|
693 |
|
|
|
694 |
4260c32a
|
Stephen Beaver
|
$('#ipsec-body').html(response);
|
695 |
|
|
ajax_lock = false;
|
696 |
|
|
|
697 |
067551a4
|
Stephen Beaver
|
// Update "Show child SA" handlers
|
698 |
|
|
$('[id^=btnchildsa-]').click(function () {
|
699 |
3c5f4441
|
Stephen Jones
|
show_childsa($(this).prop("id").replace( 'btnchildsa-', ''));
|
700 |
067551a4
|
Stephen Beaver
|
});
|
701 |
|
|
|
702 |
|
|
// Check the sa_open array for child SAs that have been opened
|
703 |
3c5f4441
|
Stephen Jones
|
$('[id^=childsa-]').each(function(idx) {
|
704 |
|
|
sa_idx = $(this).prop("id").replace( 'childsa-', '');
|
705 |
4260c32a
|
Stephen Beaver
|
|
706 |
|
|
if (sa_open[sa_idx]) {
|
707 |
067551a4
|
Stephen Beaver
|
show_childsa(sa_idx);
|
708 |
4260c32a
|
Stephen Beaver
|
}
|
709 |
|
|
});
|
710 |
|
|
|
711 |
64d53c69
|
Steve Beaver
|
// re-attached the GET to POST handler
|
712 |
|
|
interceptGET();
|
713 |
|
|
|
714 |
4260c32a
|
Stephen Beaver
|
// and do it again
|
715 |
|
|
setTimeout(update_table, 5000);
|
716 |
|
|
});
|
717 |
|
|
}
|
718 |
|
|
|
719 |
067551a4
|
Stephen Beaver
|
function show_childsa(said) {
|
720 |
|
|
sa_open[said] = true;
|
721 |
3c5f4441
|
Stephen Jones
|
$('#childsa-' + said).show();
|
722 |
c6220dcf
|
jim-p
|
$('#btnchildsa-' + said).hide();
|
723 |
067551a4
|
Stephen Beaver
|
}
|
724 |
|
|
|
725 |
4260c32a
|
Stephen Beaver
|
// Populate the tbody on page load
|
726 |
|
|
update_table();
|
727 |
|
|
});
|
728 |
|
|
//]]>
|
729 |
|
|
</script>
|
730 |
|
|
|
731 |
d2c1089f
|
Phil Davis
|
<?php
|
732 |
3795cc0a
|
sbeaver
|
include("foot.inc"); ?>
|