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