1
|
<?php
|
2
|
/*
|
3
|
* status_ipsec.php
|
4
|
*
|
5
|
* part of pfSense (https://www.pfsense.org)
|
6
|
* Copyright (c) 2004-2016 Electric Sheep Fencing, LLC
|
7
|
* All rights reserved.
|
8
|
*
|
9
|
* originally based on m0n0wall (http://m0n0.ch/wall)
|
10
|
* Copyright (c) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
11
|
* All rights reserved.
|
12
|
*
|
13
|
* Redistribution and use in source and binary forms, with or without
|
14
|
* modification, are permitted provided that the following conditions are met:
|
15
|
*
|
16
|
* 1. Redistributions of source code must retain the above copyright notice,
|
17
|
* this list of conditions and the following disclaimer.
|
18
|
*
|
19
|
* 2. Redistributions in binary form must reproduce the above copyright
|
20
|
* notice, this list of conditions and the following disclaimer in
|
21
|
* the documentation and/or other materials provided with the
|
22
|
* distribution.
|
23
|
*
|
24
|
* 3. All advertising materials mentioning features or use of this software
|
25
|
* must display the following acknowledgment:
|
26
|
* "This product includes software developed by the pfSense Project
|
27
|
* for use in the pfSense® software distribution. (http://www.pfsense.org/).
|
28
|
*
|
29
|
* 4. The names "pfSense" and "pfSense Project" must not be used to
|
30
|
* endorse or promote products derived from this software without
|
31
|
* prior written permission. For written permission, please contact
|
32
|
* coreteam@pfsense.org.
|
33
|
*
|
34
|
* 5. Products derived from this software may not be called "pfSense"
|
35
|
* nor may "pfSense" appear in their names without prior written
|
36
|
* permission of the Electric Sheep Fencing, LLC.
|
37
|
*
|
38
|
* 6. Redistributions of any form whatsoever must retain the following
|
39
|
* acknowledgment:
|
40
|
*
|
41
|
* "This product includes software developed by the pfSense Project
|
42
|
* for use in the pfSense software distribution (http://www.pfsense.org/).
|
43
|
*
|
44
|
* THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
|
45
|
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
46
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
47
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
|
48
|
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
49
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
50
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
51
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
52
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
53
|
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
54
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
55
|
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
56
|
*/
|
57
|
|
58
|
##|+PRIV
|
59
|
##|*IDENT=page-status-ipsec
|
60
|
##|*NAME=Status: IPsec
|
61
|
##|*DESCR=Allow access to the 'Status: IPsec' page.
|
62
|
##|*MATCH=status_ipsec.php*
|
63
|
##|-PRIV
|
64
|
|
65
|
require_once("guiconfig.inc");
|
66
|
require_once("ipsec.inc");
|
67
|
|
68
|
global $g;
|
69
|
|
70
|
if (!is_array($config['ipsec']['phase1'])) {
|
71
|
$config['ipsec']['phase1'] = array();
|
72
|
}
|
73
|
|
74
|
// If this is just an AJAX call to update the table body, just generate the body and quit
|
75
|
if ($_REQUEST['ajax']) {
|
76
|
print_ipsec_body();
|
77
|
exit;
|
78
|
}
|
79
|
|
80
|
if ($_GET['act'] == 'connect') {
|
81
|
if (ctype_digit($_GET['ikeid'])) {
|
82
|
$ph1ent = ipsec_get_phase1($_GET['ikeid']);
|
83
|
if (!empty($ph1ent)) {
|
84
|
if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == 'ikev1' || isset($ph1ent['splitconn'])) {
|
85
|
$ph2entries = ipsec_get_number_of_phase2($_GET['ikeid']);
|
86
|
for ($i = 0; $i < $ph2entries; $i++) {
|
87
|
$connid = escapeshellarg("con{$_GET['ikeid']}00{$i}");
|
88
|
mwexec_bg("/usr/local/sbin/ipsec down {$connid}");
|
89
|
mwexec_bg("/usr/local/sbin/ipsec up {$connid}");
|
90
|
}
|
91
|
} else {
|
92
|
mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
|
93
|
mwexec_bg("/usr/local/sbin/ipsec up con" . escapeshellarg($_GET['ikeid']));
|
94
|
}
|
95
|
}
|
96
|
}
|
97
|
} else if ($_GET['act'] == 'ikedisconnect') {
|
98
|
if (ctype_digit($_GET['ikeid'])) {
|
99
|
if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) {
|
100
|
mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "[" . escapeshellarg($_GET['ikesaid']) . "]");
|
101
|
} else {
|
102
|
mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
|
103
|
}
|
104
|
}
|
105
|
} else if ($_GET['act'] == 'childdisconnect') {
|
106
|
if (ctype_digit($_GET['ikeid'])) {
|
107
|
if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) {
|
108
|
mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "{" . escapeshellarg($_GET['ikesaid']) . "}");
|
109
|
}
|
110
|
}
|
111
|
}
|
112
|
|
113
|
// Table body is composed here so that it can be more easily updated via AJAX
|
114
|
function print_ipsec_body() {
|
115
|
global $config;
|
116
|
|
117
|
$a_phase1 = &$config['ipsec']['phase1'];
|
118
|
$status = ipsec_list_sa();
|
119
|
$ipsecconnected = array();
|
120
|
|
121
|
if (is_array($status)) {
|
122
|
foreach ($status as $ikeid => $ikesa) {
|
123
|
$con_id = substr($ikeid, 3);
|
124
|
|
125
|
if ($ikesa['version'] == 1) {
|
126
|
$ph1idx = substr($con_id, 0, strrpos(substr($con_id, 0, -1), '00'));
|
127
|
$ipsecconnected[$ph1idx] = $ph1idx;
|
128
|
} else {
|
129
|
$ipsecconnected[$con_id] = $ph1idx = $con_id;
|
130
|
}
|
131
|
|
132
|
print("<tr>\n");
|
133
|
print("<td>\n");
|
134
|
print(htmlspecialchars(ipsec_get_descr($ph1idx)));
|
135
|
print("</td>\n");
|
136
|
print("<td>\n");
|
137
|
|
138
|
if (!empty($ikesa['local-id'])) {
|
139
|
if ($ikesa['local-id'] == '%any') {
|
140
|
print(gettext('Any identifier'));
|
141
|
} else {
|
142
|
print(htmlspecialchars($ikesa['local-id']));
|
143
|
}
|
144
|
} else {
|
145
|
print(gettext("Unknown"));
|
146
|
}
|
147
|
|
148
|
print("</td>\n");
|
149
|
print("<td>\n");
|
150
|
|
151
|
if (!empty($ikesa['local-host'])) {
|
152
|
print(htmlspecialchars($ikesa['local-host']));
|
153
|
} else {
|
154
|
print(gettext("Unknown"));
|
155
|
}
|
156
|
|
157
|
/*
|
158
|
* XXX: local-nat-t was defined by pfSense
|
159
|
* When strongswan team accepted the change, they changed it to
|
160
|
* nat-local. Keep both for a while and remove local-nat-t in
|
161
|
* the future
|
162
|
*/
|
163
|
if (isset($ikesa['local-nat-t']) || isset($ikesa['nat-local'])) {
|
164
|
print(" NAT-T");
|
165
|
}
|
166
|
|
167
|
print("</td>\n");
|
168
|
print("<td>\n");
|
169
|
|
170
|
$identity = "";
|
171
|
if (!empty($ikesa['remote-id'])) {
|
172
|
if ($ikesa['remote-id'] == '%any') {
|
173
|
$identity = htmlspecialchars(gettext('Any identifier'));
|
174
|
} else {
|
175
|
$identity = htmlspecialchars($ikesa['remote-id']);
|
176
|
}
|
177
|
}
|
178
|
|
179
|
if (!empty($ikesa['remote-xauth-id'])) {
|
180
|
echo htmlspecialchars($ikesa['remote-xauth-id']);
|
181
|
echo "<br/>{$identity}";
|
182
|
} elseif (!empty($ikesa['remote-eap-id'])) {
|
183
|
echo htmlspecialchars($ikesa['remote-eap-id']);
|
184
|
echo "<br/>{$identity}";
|
185
|
} else {
|
186
|
if (empty($identity)) {
|
187
|
print(gettext("Unknown"));
|
188
|
} else {
|
189
|
print($identity);
|
190
|
}
|
191
|
}
|
192
|
|
193
|
print("</td>\n");
|
194
|
print("<td>\n");
|
195
|
|
196
|
if (!empty($ikesa['remote-host'])) {
|
197
|
print(htmlspecialchars($ikesa['remote-host']));
|
198
|
} else {
|
199
|
print(gettext("Unknown"));
|
200
|
}
|
201
|
/*
|
202
|
* XXX: remote-nat-t was defined by pfSense
|
203
|
* When strongswan team accepted the change, they changed it to
|
204
|
* nat-remote. Keep both for a while and remove remote-nat-t in
|
205
|
* the future
|
206
|
*/
|
207
|
if (isset($ikesa['remote-nat-t']) || isset($ikesa['nat-remote'])) {
|
208
|
print(" NAT-T");
|
209
|
}
|
210
|
|
211
|
print("</td>\n");
|
212
|
print("<td>\n");
|
213
|
print("IKEv" . htmlspecialchars($ikesa['version']));
|
214
|
print("<br/>\n");
|
215
|
|
216
|
if ($ikesa['initiator'] == 'yes') {
|
217
|
print("initiator");
|
218
|
} else {
|
219
|
print("responder");
|
220
|
}
|
221
|
|
222
|
print("</td>\n");
|
223
|
print("<td>\n");
|
224
|
print(htmlspecialchars($ikesa['reauth-time']) . gettext(" seconds (") . convert_seconds_to_dhms($ikesa['reauth-time']) . ")");
|
225
|
print("</td>\n");
|
226
|
print("<td>\n");
|
227
|
print(htmlspecialchars($ikesa['encr-alg']));
|
228
|
print("<br/>");
|
229
|
print(htmlspecialchars($ikesa['integ-alg']));
|
230
|
print("<br/>");
|
231
|
print(htmlspecialchars($ikesa['prf-alg']));
|
232
|
print("<br/>\n");
|
233
|
print(htmlspecialchars($ikesa['dh-group']));
|
234
|
print("</td>\n");
|
235
|
print("<td>\n");
|
236
|
|
237
|
if ($ikesa['state'] == 'ESTABLISHED') {
|
238
|
print('<span class="text-success">');
|
239
|
} else {
|
240
|
print('<span>');
|
241
|
}
|
242
|
|
243
|
print(ucfirst(htmlspecialchars($ikesa['state'])));
|
244
|
|
245
|
if ($ikesa['state'] == 'ESTABLISHED') {
|
246
|
print("<br/>" . htmlspecialchars($ikesa['established']) . gettext(" seconds (") . convert_seconds_to_dhms($ikesa['established']) . gettext(") ago"));
|
247
|
}
|
248
|
|
249
|
print("</span>");
|
250
|
print("</td>\n");
|
251
|
print("<td>\n");
|
252
|
|
253
|
if ($ikesa['state'] != 'ESTABLISHED') {
|
254
|
|
255
|
print('<a href="status_ipsec.php?act=connect&ikeid=' . $con_id . '" class="btn btn-xs btn-success" data-toggle="tooltip" title="' . gettext("Connect VPN"). '" >');
|
256
|
print('<i class="fa fa-sign-in icon-embed-btn"></i>');
|
257
|
print(gettext("Connect VPN"));
|
258
|
print("</a>\n");
|
259
|
|
260
|
} else {
|
261
|
|
262
|
print('<a href="status_ipsec.php?act=ikedisconnect&ikeid=' . $con_id . '" class="btn btn-xs btn-danger" data-toggle="tooltip" title="' . gettext("Disconnect VPN") . '">');
|
263
|
print('<i class="fa fa-trash icon-embed-btn"></i>');
|
264
|
print(gettext("Disconnect"));
|
265
|
print("</a><br />\n");
|
266
|
|
267
|
}
|
268
|
|
269
|
print("</td>\n");
|
270
|
print("</tr>\n");
|
271
|
print("<tr>\n");
|
272
|
print("<td colspan = 10>\n");
|
273
|
|
274
|
if (is_array($ikesa['child-sas']) && (count($ikesa['child-sas']) > 0)) {
|
275
|
|
276
|
print('<div>');
|
277
|
print('<a type="button" id="btnchildsa-' . $ikeid . '" class="btn btn-sm btn-info">');
|
278
|
print('<i class="fa fa-plus-circle icon-embed-btn"></i>');
|
279
|
print(gettext('Show child SA entries'));
|
280
|
print("</a>\n");
|
281
|
print(" </div>\n");
|
282
|
|
283
|
print('<table class="table table-hover table-condensed" id="childsa-' . $ikeid . '" style="display:none">');
|
284
|
print("<thead>\n");
|
285
|
print('<tr class="bg-info">');
|
286
|
print('<th><?=gettext("Local subnets")?></th>');
|
287
|
print('<th><?=gettext("Local SPI(s)")?></th>');
|
288
|
print('<th><?=gettext("Remote subnets")?></th>');
|
289
|
print('<th><?=gettext("Times")?></th>');
|
290
|
print('<th><?=gettext("Algo")?></th>');
|
291
|
print('<th><?=gettext("Stats")?></th>');
|
292
|
print('<th><!-- Buttons --></th>');
|
293
|
print("</tr\n");
|
294
|
print("</thead>\n");
|
295
|
print("<tbody>\n");
|
296
|
|
297
|
foreach ($ikesa['child-sas'] as $childid => $childsa) {
|
298
|
print("<tr>");
|
299
|
print("<td>\n");
|
300
|
|
301
|
if (is_array($childsa['local-ts'])) {
|
302
|
foreach ($childsa['local-ts'] as $lnets) {
|
303
|
print(htmlspecialchars(ipsec_fixup_network($lnets)) . "<br />");
|
304
|
}
|
305
|
} else {
|
306
|
print(gettext("Unknown"));
|
307
|
}
|
308
|
|
309
|
print("</td>\n");
|
310
|
print("<td>\n");
|
311
|
|
312
|
if (isset($childsa['spi-in'])) {
|
313
|
print(gettext("Local: ") . htmlspecialchars($childsa['spi-in']));
|
314
|
}
|
315
|
|
316
|
if (isset($childsa['spi-out'])) {
|
317
|
print('<br/>' . gettext('Remote: ') . htmlspecialchars($childsa['spi-out']));
|
318
|
}
|
319
|
|
320
|
print("</td>\n");
|
321
|
print("<td>\n");
|
322
|
|
323
|
if (is_array($childsa['remote-ts'])) {
|
324
|
foreach ($childsa['remote-ts'] as $rnets) {
|
325
|
print(htmlspecialchars(ipsec_fixup_network($rnets)) . '<br />');
|
326
|
}
|
327
|
} else {
|
328
|
print(gettext("Unknown"));
|
329
|
}
|
330
|
|
331
|
print("</td>\n");
|
332
|
print("<td>\n");
|
333
|
|
334
|
print(gettext("Rekey: ") . htmlspecialchars($childsa['rekey-time']) . gettext(" seconds (") . convert_seconds_to_dhms($childsa['rekey-time']) . ")");
|
335
|
print('<br/>' . gettext('Life: ') . htmlspecialchars($childsa['life-time']) . gettext(" seconds (") . convert_seconds_to_dhms($childsa['life-time']) . ")");
|
336
|
print('<br/>' . gettext('Install: ') .htmlspecialchars($childsa['install-time']) . gettext(" seconds (") . convert_seconds_to_dhms($childsa['install-time']) . ")");
|
337
|
|
338
|
|
339
|
print("</td>\n");
|
340
|
print("<td>\n");
|
341
|
|
342
|
print(htmlspecialchars($childsa['encr-alg']) . '<br/>');
|
343
|
print(htmlspecialchars($childsa['integ-alg']) . '<br/>');
|
344
|
|
345
|
if (!empty($childsa['prf-alg'])) {
|
346
|
print(htmlspecialchars($childsa['prf-alg']) . '<br/>');
|
347
|
}
|
348
|
|
349
|
if (!empty($childsa['dh-group'])) {
|
350
|
print(htmlspecialchars($childsa['dh-group']) . '<br/>');
|
351
|
}
|
352
|
|
353
|
if (!empty($childsa['esn'])) {
|
354
|
print(htmlspecialchars($childsa['esn']) . '<br/>');
|
355
|
}
|
356
|
|
357
|
print(gettext("IPComp: "));
|
358
|
if (!empty($childsa['cpi-in']) || !empty($childsa['cpi-out'])) {
|
359
|
print(htmlspecialchars($childsa['cpi-in']) . " " . htmlspecialchars($childsa['cpi-out']));
|
360
|
} else {
|
361
|
print(gettext('none'));
|
362
|
}
|
363
|
|
364
|
print("</td>\n");
|
365
|
print("<td>\n");
|
366
|
|
367
|
print(gettext("Bytes-In: ") . htmlspecialchars(number_format($childsa['bytes-in'])) . ' (' . htmlspecialchars(format_bytes($childsa['bytes-in'])) . ')<br/>');
|
368
|
print(gettext("Packets-In: ") . htmlspecialchars(number_format($childsa['packets-in'])) . '<br/>');
|
369
|
print(gettext("Bytes-Out: ") . htmlspecialchars(number_format($childsa['bytes-out'])) . ' (' . htmlspecialchars(format_bytes($childsa['bytes-out'])) . ')<br/>');
|
370
|
print(gettext("Packets-Out: ") . htmlspecialchars(number_format($childsa['packets-out'])) . '<br/>');
|
371
|
|
372
|
print("</td>\n");
|
373
|
print("<td>\n");
|
374
|
print('<a href="status_ipsec.php?act=childdisconnect&ikeid=' . $con_id . '&ikesaid=' . $childsa['uniqueid'] . '" class="btn btn-xs btn-warning" data-toggle="tooltip" title="' . gettext('Disconnect Child SA') . '">');
|
375
|
print('<i class="fa fa-trash icon-embed-btn"></i>');
|
376
|
print(gettext("Disconnect"));
|
377
|
print("</a>\n");
|
378
|
print("</td>\n");
|
379
|
print("</tr>\n");
|
380
|
|
381
|
}
|
382
|
|
383
|
print("</tbody>\n");
|
384
|
print(" </table>\n");
|
385
|
print("</td>\n");
|
386
|
print("</tr>\n");
|
387
|
|
388
|
}
|
389
|
|
390
|
unset($con_id);
|
391
|
}
|
392
|
|
393
|
}
|
394
|
|
395
|
$rgmap = array();
|
396
|
if (is_array($a_phase1)) {
|
397
|
foreach ($a_phase1 as $ph1ent) {
|
398
|
if (isset($ph1ent['disabled'])) {
|
399
|
continue;
|
400
|
}
|
401
|
|
402
|
$rgmap[$ph1ent['remote-gateway']] = $ph1ent['remote-gateway'];
|
403
|
|
404
|
if ($ipsecconnected[$ph1ent['ikeid']]) {
|
405
|
continue;
|
406
|
}
|
407
|
|
408
|
print("<tr>\n");
|
409
|
print("<td>\n");
|
410
|
|
411
|
print(htmlspecialchars($ph1ent['descr']));
|
412
|
print("</td>\n");
|
413
|
print("<td>\n");
|
414
|
list ($myid_type, $myid_data) = ipsec_find_id($ph1ent, "local");
|
415
|
|
416
|
if (empty($myid_data)) {
|
417
|
print(gettext("Unknown"));
|
418
|
} else {
|
419
|
print(htmlspecialchars($myid_data));
|
420
|
}
|
421
|
|
422
|
print("</td>\n");
|
423
|
print("<td>\n");
|
424
|
$ph1src = ipsec_get_phase1_src($ph1ent);
|
425
|
|
426
|
if (empty($ph1src)) {
|
427
|
print(gettext("Unknown"));
|
428
|
} else {
|
429
|
print(htmlspecialchars($ph1src));
|
430
|
}
|
431
|
|
432
|
print("</td>\n");
|
433
|
print("<td>\n");
|
434
|
|
435
|
list ($peerid_type, $peerid_data) = ipsec_find_id($ph1ent, "peer", $rgmap);
|
436
|
|
437
|
if (empty($peerid_data)) {
|
438
|
print(gettext("Unknown"));
|
439
|
} else {
|
440
|
print(htmlspecialchars($peerid_data));
|
441
|
}
|
442
|
print(" </td>\n");
|
443
|
print(" <td>\n");
|
444
|
$ph1src = ipsec_get_phase1_dst($ph1ent);
|
445
|
|
446
|
if (empty($ph1src)) {
|
447
|
print(gettext("Unknown"));
|
448
|
} else {
|
449
|
print(htmlspecialchars($ph1src));
|
450
|
}
|
451
|
|
452
|
print("</td>\n");
|
453
|
print("<td>\n");
|
454
|
print("</td>\n");
|
455
|
print("<td>\n");
|
456
|
print("</td>\n");
|
457
|
print("<td>\n");
|
458
|
print("</td>\n");
|
459
|
|
460
|
if (isset($ph1ent['mobile'])) {
|
461
|
|
462
|
print("<td>\n");
|
463
|
print(gettext("Awaiting connections"));
|
464
|
print("</td>\n");
|
465
|
print("<td>\n");
|
466
|
print("</td>\n");
|
467
|
print("</td>\n");
|
468
|
} else {
|
469
|
|
470
|
print("<td>\n");
|
471
|
print(gettext("Disconnected"));
|
472
|
print("</td>\n");
|
473
|
print("<td>\n");
|
474
|
print('<a href="status_ipsec.php?act=connect&ikeid=' . $ph1ent['ikeid'] . '" class="btn btn-xs btn-success">');
|
475
|
print('<i class="fa fa-sign-in icon-embed-btn"></i>');
|
476
|
print(gettext("Connect VPN"));
|
477
|
print("</a>\n");
|
478
|
print("</td>\n");
|
479
|
|
480
|
}
|
481
|
print("</tr>\n");
|
482
|
}
|
483
|
}
|
484
|
|
485
|
unset($ipsecconnected, $phase1, $rgmap);
|
486
|
}
|
487
|
|
488
|
$pgtitle = array(gettext("Status"), gettext("IPsec"), gettext("Overview"));
|
489
|
$shortcut_section = "ipsec";
|
490
|
|
491
|
include("head.inc");
|
492
|
|
493
|
$tab_array = array();
|
494
|
$tab_array[] = array(gettext("Overview"), true, "status_ipsec.php");
|
495
|
$tab_array[] = array(gettext("Leases"), false, "status_ipsec_leases.php");
|
496
|
$tab_array[] = array(gettext("SADs"), false, "status_ipsec_sad.php");
|
497
|
$tab_array[] = array(gettext("SPDs"), false, "status_ipsec_spd.php");
|
498
|
display_top_tabs($tab_array);
|
499
|
?>
|
500
|
|
501
|
<div class="panel panel-default">
|
502
|
<div class="panel-heading"><h2 class="panel-title"><?=gettext("IPsec Status");?></h2></div>
|
503
|
<div class="panel-body table-responsive">
|
504
|
<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap" data-sortable>
|
505
|
<thead>
|
506
|
<tr>
|
507
|
<th><?=gettext("Description")?></th>
|
508
|
<th><?=gettext("Local ID")?></th>
|
509
|
<th><?=gettext("Local IP")?></th>
|
510
|
<th><?=gettext("Remote ID")?></th>
|
511
|
<th><?=gettext("Remote IP")?></th>
|
512
|
<th><?=gettext("Role")?></th>
|
513
|
<th><?=gettext("Reauth")?></th>
|
514
|
<th><?=gettext("Algo")?></th>
|
515
|
<th><?=gettext("Status")?></th>
|
516
|
<th></th>
|
517
|
</tr>
|
518
|
</thead>
|
519
|
<tbody id="ipsec-body">
|
520
|
<tr>
|
521
|
<td colspan="10">
|
522
|
<?=print_info_box(gettext("Collecting IPsec status information."), warning, "")?>
|
523
|
</td>
|
524
|
</tr>
|
525
|
</tbody>
|
526
|
</table>
|
527
|
</div>
|
528
|
</div>
|
529
|
|
530
|
<?php
|
531
|
unset($status);
|
532
|
|
533
|
if (ipsec_enabled()) {
|
534
|
print('<div class="infoblock">');
|
535
|
} else {
|
536
|
print('<div class="infoblock blockopen">');
|
537
|
}
|
538
|
|
539
|
print_info_box(sprintf(gettext('IPsec can be configured %1$shere%2$s.'), '<a href="vpn_ipsec.php">', '</a>'), 'info', false);
|
540
|
?>
|
541
|
</div>
|
542
|
|
543
|
<script type="text/javascript">
|
544
|
//<![CDATA[
|
545
|
|
546
|
events.push(function() {
|
547
|
ajax_lock = false; // Mutex so we don't make a call until the previous call is finished
|
548
|
sa_open = new Array(); // Array in which to keep the child SA show/hide state
|
549
|
|
550
|
// Fetch the tbody contents from the server
|
551
|
function update_table() {
|
552
|
if (ajax_lock) {
|
553
|
return;
|
554
|
}
|
555
|
|
556
|
ajax_lock = true;
|
557
|
|
558
|
ajaxRequest = $.ajax(
|
559
|
{
|
560
|
url: "/status_ipsec.php",
|
561
|
type: "post",
|
562
|
data: {
|
563
|
ajax: "ajax"
|
564
|
}
|
565
|
}
|
566
|
);
|
567
|
|
568
|
// Deal with the results of the above ajax call
|
569
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
570
|
|
571
|
if (!response) {
|
572
|
response = '<tr><td colspan="10"><?=print_info_box(gettext("No IPsec status information available."), warning, "")?></td></tr>';
|
573
|
}
|
574
|
|
575
|
$('#ipsec-body').html(response);
|
576
|
ajax_lock = false;
|
577
|
|
578
|
// Update "Show child SA" handlers
|
579
|
$('[id^=btnchildsa-]').click(function () {
|
580
|
show_childsa($(this).prop("id").replace( /^\D+/g, ''));
|
581
|
});
|
582
|
|
583
|
// Check the sa_open array for child SAs that have been opened
|
584
|
$('[id^=childsa-con]').each(function(idx) {
|
585
|
sa_idx = $(this).prop("id").replace( /^\D+/g, '');
|
586
|
|
587
|
if (sa_open[sa_idx]) {
|
588
|
show_childsa(sa_idx);
|
589
|
}
|
590
|
});
|
591
|
|
592
|
// and do it again
|
593
|
setTimeout(update_table, 5000);
|
594
|
});
|
595
|
}
|
596
|
|
597
|
function show_childsa(said) {
|
598
|
sa_open[said] = true;
|
599
|
$('#childsa-con' + said).show();
|
600
|
$('#btnchildsa-con' + said).hide();
|
601
|
}
|
602
|
|
603
|
// Populate the tbody on page load
|
604
|
update_table();
|
605
|
});
|
606
|
//]]>
|
607
|
</script>
|
608
|
|
609
|
<?php
|
610
|
include("foot.inc"); ?>
|