1
|
<?php
|
2
|
/*
|
3
|
* status_ipsec.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
|
* All rights reserved.
|
10
|
*
|
11
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
12
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
13
|
* All rights reserved.
|
14
|
*
|
15
|
* 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
|
*
|
19
|
* http://www.apache.org/licenses/LICENSE-2.0
|
20
|
*
|
21
|
* 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
|
*/
|
27
|
|
28
|
##|+PRIV
|
29
|
##|*IDENT=page-status-ipsec
|
30
|
##|*NAME=Status: IPsec
|
31
|
##|*DESCR=Allow access to the 'Status: IPsec' page.
|
32
|
##|*MATCH=status_ipsec.php*
|
33
|
##|-PRIV
|
34
|
|
35
|
require_once("guiconfig.inc");
|
36
|
require_once("ipsec.inc");
|
37
|
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
|
|
49
|
// 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
|
|
55
|
// Table body is composed here so that it can be more easily updated via AJAX
|
56
|
function print_ipsec_body() {
|
57
|
global $config;
|
58
|
|
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
|
}
|
79
|
|
80
|
$cmap = ipsec_map_config_by_id();
|
81
|
$status = ipsec_list_sa();
|
82
|
|
83
|
$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
|
|
89
|
$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
|
foreach ($ikesa['child-sas'] as $childsa) {
|
110
|
list($childikeid, $childreqid) = ipsec_id_by_conid($childsa['name']);
|
111
|
if ($childreqid != null) {
|
112
|
$p2connected[$childreqid] = $childsa['name'];
|
113
|
} else {
|
114
|
/* If this is IKEv2 w/o Split, mark all reqids for the P1 as connected */
|
115
|
if (($cmap[$childikeid]['p1']['iketype'] == 'ikev2') &&
|
116
|
!isset($cmap[$childikeid]['p1']['splitconn']) &&
|
117
|
isset($cmap[$ikeid]['p2']) && is_array($cmap[$ikeid]['p2'])) {
|
118
|
foreach ($cmap[$ikeid]['p2'] as $p2) {
|
119
|
$p2connected[$p2['reqid']] = $childsa['name'];
|
120
|
}
|
121
|
}
|
122
|
}
|
123
|
}
|
124
|
}
|
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
|
}
|
136
|
}
|
137
|
}
|
138
|
?>
|
139
|
|
140
|
<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
|
} else {
|
160
|
$localid = $ikesa['local-id'];
|
161
|
}
|
162
|
}
|
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
|
}
|
175
|
$lhost .= ":{$ikesa['local-port']}";
|
176
|
}
|
177
|
}
|
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
|
} else {
|
195
|
$identity = $ikesa['remote-id'];
|
196
|
}
|
197
|
}
|
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
|
}
|
207
|
}
|
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
|
}
|
225
|
}
|
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
|
<?php if (!in_array($ikesa['state'], array('ESTABLISHED', 'CONNECTING'))): ?>
|
283
|
<?= 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
|
<?php if (empty($ikesa['child-sas']) && ($ikesa['state'] != 'CONNECTING')): ?>
|
289
|
<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
|
}
|
307
|
?>
|
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
|
foreach ($ikesa['child-sas'] as $childsa) {
|
329
|
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
|
} else {
|
345
|
$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
|
} else {
|
350
|
$p2descr = $cmap[$childikeid]['p2'][$childreqid]['descr'];
|
351
|
}
|
352
|
}
|
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
|
}
|
369
|
} else {
|
370
|
$lnetlist[] = htmlspecialchars(gettext("Unknown"));
|
371
|
}
|
372
|
?>
|
373
|
<?= implode('<br/>', $lnetlist) ?>
|
374
|
</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
|
}
|
399
|
} else {
|
400
|
$rnetlist[] = htmlspecialchars(gettext("Unknown"));
|
401
|
}
|
402
|
?>
|
403
|
<?= implode('<br/>', $rnetlist) ?>
|
404
|
</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
|
}
|
470
|
?>
|
471
|
</tr>
|
472
|
<?php
|
473
|
}
|
474
|
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
|
}
|
509
|
|
510
|
$rgmap = array();
|
511
|
$gateways_status = return_gateways_status(true);
|
512
|
|
513
|
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
|
}
|
538
|
?>
|
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
|
}
|
593
|
unset($p1connected, $p2connected, $p2disconnected, $rgmap);
|
594
|
}
|
595
|
|
596
|
$pgtitle = array(gettext("Status"), gettext("IPsec"), gettext("Overview"));
|
597
|
$pglinks = array("", "@self", "@self");
|
598
|
$shortcut_section = "ipsec";
|
599
|
|
600
|
include("head.inc");
|
601
|
|
602
|
$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
|
?>
|
609
|
|
610
|
<div class="panel panel-default">
|
611
|
<div class="panel-heading"><h2 class="panel-title"><?= htmlspecialchars(gettext("IPsec Status")); ?></h2></div>
|
612
|
<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
|
<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
|
</tr>
|
625
|
</thead>
|
626
|
<tbody id="ipsec-body">
|
627
|
<tr>
|
628
|
<td colspan="10">
|
629
|
<?= print_info_box('<i class="fa fa-gear fa-spin"></i> ' .
|
630
|
gettext("Collecting IPsec status information."), "warning", "") ?>
|
631
|
</td>
|
632
|
</tr>
|
633
|
</tbody>
|
634
|
</table>
|
635
|
</div>
|
636
|
</div>
|
637
|
|
638
|
<?php
|
639
|
unset($status);
|
640
|
|
641
|
if (ipsec_enabled()) {
|
642
|
print('<div class="infoblock">');
|
643
|
} else {
|
644
|
print('<div class="infoblock blockopen">');
|
645
|
}
|
646
|
|
647
|
print_info_box(sprintf(gettext('%1$sConfigure IPsec%2$s.'), '<a href="vpn_ipsec.php">', '</a>'), 'info', false);
|
648
|
?>
|
649
|
</div>
|
650
|
|
651
|
<script type="text/javascript">
|
652
|
//<![CDATA[
|
653
|
|
654
|
events.push(function() {
|
655
|
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
|
tryCount = 3;
|
658
|
// 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
|
},
|
673
|
error: function(xhr, textStatus, errorThrown){
|
674
|
//alert("error.... retrying");
|
675
|
if (tryCount > 0){
|
676
|
tryCount --;
|
677
|
ajax_lock = false;
|
678
|
update_table();
|
679
|
}
|
680
|
return;
|
681
|
}
|
682
|
}
|
683
|
);
|
684
|
|
685
|
// Deal with the results of the above ajax call
|
686
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
687
|
if(textStatus === "success"){
|
688
|
tryCount =3;
|
689
|
}
|
690
|
if (!response) {
|
691
|
response = '<tr><td colspan="10"><?=print_info_box(addslashes(gettext("No IPsec status information available.")), "warning", "")?></td></tr>';
|
692
|
}
|
693
|
|
694
|
$('#ipsec-body').html(response);
|
695
|
ajax_lock = false;
|
696
|
|
697
|
// Update "Show child SA" handlers
|
698
|
$('[id^=btnchildsa-]').click(function () {
|
699
|
show_childsa($(this).prop("id").replace( 'btnchildsa-', ''));
|
700
|
});
|
701
|
|
702
|
// Check the sa_open array for child SAs that have been opened
|
703
|
$('[id^=childsa-]').each(function(idx) {
|
704
|
sa_idx = $(this).prop("id").replace( 'childsa-', '');
|
705
|
|
706
|
if (sa_open[sa_idx]) {
|
707
|
show_childsa(sa_idx);
|
708
|
}
|
709
|
});
|
710
|
|
711
|
// re-attached the GET to POST handler
|
712
|
interceptGET();
|
713
|
|
714
|
// and do it again
|
715
|
setTimeout(update_table, 5000);
|
716
|
});
|
717
|
}
|
718
|
|
719
|
function show_childsa(said) {
|
720
|
sa_open[said] = true;
|
721
|
$('#childsa-' + said).show();
|
722
|
$('#btnchildsa-' + said).hide();
|
723
|
}
|
724
|
|
725
|
// Populate the tbody on page load
|
726
|
update_table();
|
727
|
});
|
728
|
//]]>
|
729
|
</script>
|
730
|
|
731
|
<?php
|
732
|
include("foot.inc"); ?>
|