Project

General

Profile

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