Project

General

Profile

Download (15.4 KB) Statistics
| Branch: | Tag: | Revision:
1 cf7d1057 Scott Ullrich
<?php
2
/*
3 1af5edbf Stephen Beaver
	status_ipsec.php
4 cf7d1057 Scott Ullrich
*/
5 fd9ebcd5 Stephen Beaver
/* ====================================================================
6 0da0d43e Phil Davis
 *  Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 90719498 Phil Davis
 *  portions Copyright (c) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
8 86b2861c Matt Smith
 *
9
 *  Parts of this code originally based on vpn_ipsec_sad.php from m0n0wall,
10 0dc2d195 Phil Davis
 *  Copyright (c) 2003-2004 Manuel Kasper (BSD 2 clause)
11 fd9ebcd5 Stephen Beaver
 *
12 0da0d43e Phil Davis
 *  Redistribution and use in source and binary forms, with or without modification,
13
 *  are permitted provided that the following conditions are met:
14 fd9ebcd5 Stephen Beaver
 *
15
 *  1. Redistributions of source code must retain the above copyright notice,
16
 *      this list of conditions and the following disclaimer.
17
 *
18
 *  2. Redistributions in binary form must reproduce the above copyright
19
 *      notice, this list of conditions and the following disclaimer in
20
 *      the documentation and/or other materials provided with the
21 0da0d43e Phil Davis
 *      distribution.
22 fd9ebcd5 Stephen Beaver
 *
23 0da0d43e Phil Davis
 *  3. All advertising materials mentioning features or use of this software
24 fd9ebcd5 Stephen Beaver
 *      must display the following acknowledgment:
25
 *      "This product includes software developed by the pfSense Project
26 0da0d43e Phil Davis
 *       for use in the pfSense software distribution. (http://www.pfsense.org/).
27 fd9ebcd5 Stephen Beaver
 *
28
 *  4. The names "pfSense" and "pfSense Project" must not be used to
29
 *       endorse or promote products derived from this software without
30
 *       prior written permission. For written permission, please contact
31
 *       coreteam@pfsense.org.
32
 *
33
 *  5. Products derived from this software may not be called "pfSense"
34
 *      nor may "pfSense" appear in their names without prior written
35
 *      permission of the Electric Sheep Fencing, LLC.
36
 *
37
 *  6. Redistributions of any form whatsoever must retain the following
38
 *      acknowledgment:
39
 *
40
 *  "This product includes software developed by the pfSense Project
41
 *  for use in the pfSense software distribution (http://www.pfsense.org/).
42 0da0d43e Phil Davis
 *
43 fd9ebcd5 Stephen Beaver
 *  THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
44
 *  EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45
 *  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46
 *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
47
 *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48
 *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49
 *  NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50
 *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51
 *  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52
 *  STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53
 *  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54
 *  OF THE POSSIBILITY OF SUCH DAMAGE.
55
 *
56
 *  ====================================================================
57
 *
58
 */
59 cf7d1057 Scott Ullrich
60 6b07c15a Matthew Grooms
##|+PRIV
61
##|*IDENT=page-status-ipsec
62 5230f468 jim-p
##|*NAME=Status: IPsec
63 6b07c15a Matthew Grooms
##|*DESCR=Allow access to the 'Status: IPsec' page.
64 1af5edbf Stephen Beaver
##|*MATCH=status_ipsec.php*
65 6b07c15a Matthew Grooms
##|-PRIV
66
67
68 a93e56c5 Matthew Grooms
global $g;
69
70 2eff0148 Phil Davis
$pgtitle = array(gettext("Status"), gettext("IPsec"), gettext("Overview"));
71 b32dd0a6 jim-p
$shortcut_section = "ipsec";
72 cf7d1057 Scott Ullrich
73
require("guiconfig.inc");
74
include("head.inc");
75 3b5918ba Chris Buechler
require_once("ipsec.inc");
76 a93e56c5 Matthew Grooms
77 17402c63 Ermal
if ($_GET['act'] == 'connect') {
78
	if (ctype_digit($_GET['ikeid'])) {
79 483c3b5b Ermal LUÇI
		$ph1ent = ipsec_get_phase1($_GET['ikeid']);
80
		if (!empty($ph1ent)) {
81 9d51fcde Chris Buechler
			if (empty($ph1ent['iketype']) || $ph1ent['iketype'] == 'ikev1' || isset($ph1ent['splitconn'])) {
82 483c3b5b Ermal LUÇI
				$ph2entries = ipsec_get_number_of_phase2($_GET['ikeid']);
83
				for ($i = 0; $i < $ph2entries; $i++) {
84
					$connid = escapeshellarg("con{$_GET['ikeid']}00{$i}");
85 c5d8cbe0 Chris Buechler
					mwexec_bg("/usr/local/sbin/ipsec down {$connid}");
86 b866103e Chris Buechler
					mwexec_bg("/usr/local/sbin/ipsec up {$connid}");
87 483c3b5b Ermal LUÇI
				}
88
			} else {
89 c5d8cbe0 Chris Buechler
				mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
90 b866103e Chris Buechler
				mwexec_bg("/usr/local/sbin/ipsec up con" . escapeshellarg($_GET['ikeid']));
91 483c3b5b Ermal LUÇI
			}
92
		}
93 6e8b0ec3 jim-p
	}
94 17402c63 Ermal
} else if ($_GET['act'] == 'ikedisconnect') {
95
	if (ctype_digit($_GET['ikeid'])) {
96 5f601060 Phil Davis
		if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) {
97 c5d8cbe0 Chris Buechler
			mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "[" . escapeshellarg($_GET['ikesaid']) . "]");
98 5f601060 Phil Davis
		} else {
99 c5d8cbe0 Chris Buechler
			mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
100 5f601060 Phil Davis
		}
101 614be051 bcyrill
	}
102 e952906e Ermal
} else if ($_GET['act'] == 'childdisconnect') {
103
	if (ctype_digit($_GET['ikeid'])) {
104 5f601060 Phil Davis
		if (!empty($_GET['ikesaid']) && ctype_digit($_GET['ikesaid'])) {
105 c5d8cbe0 Chris Buechler
			mwexec_bg("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']) . "{" . escapeshellarg($_GET['ikesaid']) . "}");
106 5f601060 Phil Davis
		}
107 6e0b68bf jim-p
	}
108
}
109
110 5f601060 Phil Davis
if (!is_array($config['ipsec']['phase1'])) {
111 3795cc0a sbeaver
	$config['ipsec']['phase1'] = array();
112 5f601060 Phil Davis
}
113 a93e56c5 Matthew Grooms
114 fd875a8d Ermal
$a_phase1 = &$config['ipsec']['phase1'];
115 a93e56c5 Matthew Grooms
116 1dade399 Renato Botelho
$status = ipsec_list_sa();
117 a93e56c5 Matthew Grooms
118 3795cc0a sbeaver
$tab_array = array();
119 1af5edbf Stephen Beaver
$tab_array[] = array(gettext("Overview"), true, "status_ipsec.php");
120
$tab_array[] = array(gettext("Leases"), false, "status_ipsec_leases.php");
121 f4741421 k-paulius
$tab_array[] = array(gettext("SADs"), false, "status_ipsec_sad.php");
122
$tab_array[] = array(gettext("SPDs"), false, "status_ipsec_spd.php");
123 3795cc0a sbeaver
display_top_tabs($tab_array);
124 c7fbdd6c Ermal
?>
125 3795cc0a sbeaver
126
<div class="panel panel-default">
127 3d7a8696 k-paulius
	<div class="panel-heading"><h2 class="panel-title"><?=gettext("IPsec Status");?></h2></div>
128 d495fca5 Jared Dillard
	<div class="panel-body table-responsive">
129 10fe1eb5 Stephen Beaver
		<table class="table table-striped table-condensed table-hover sortable-theme-bootstrap" data-sortable>
130 3795cc0a sbeaver
			<thead>
131
				<tr>
132
					<th><?=gettext("Description")?></th>
133
					<th><?=gettext("Local ID")?></th>
134
					<th><?=gettext("Local IP")?></th>
135
					<th><?=gettext("Remote ID")?></th>
136
					<th><?=gettext("Remote IP")?></th>
137
					<th><?=gettext("Role")?></th>
138
					<th><?=gettext("Reauth")?></th>
139
					<th><?=gettext("Algo")?></th>
140
					<th><?=gettext("Status")?></th>
141
					<th></th>
142
				</tr>
143
			</thead>
144
			<tbody>
145
<?php
146
$ipsecconnected = array();
147
148 86b2861c Matt Smith
if (is_array($status)) {
149
	foreach ($status as $ikeid => $ikesa) {
150 7d31c585 Chris Buechler
		$con_id = substr($ikeid, 3);
151 0da0d43e Phil Davis
152 3795cc0a sbeaver
		if ($ikesa['version'] == 1) {
153
			$ph1idx = substr($con_id, 0, strrpos(substr($con_id, 0, -1), '00'));
154
			$ipsecconnected[$ph1idx] = $ph1idx;
155
		} else {
156
			$ipsecconnected[$con_id] = $ph1idx = $con_id;
157
		}
158
?>
159
				<tr>
160
					<td>
161
						<?=htmlspecialchars(ipsec_get_descr($ph1idx))?>
162
					</td>
163
					<td>
164
<?php
165 86b2861c Matt Smith
		if (!empty($ikesa['local-id'])) {
166
			if ($ikesa['local-id'] == '%any') {
167
				print(gettext('Any identifier'));
168 5f601060 Phil Davis
			} else {
169 86b2861c Matt Smith
				print(htmlspecialchars($ikesa['local-id']));
170 5f601060 Phil Davis
			}
171 86b2861c Matt Smith
		} else {
172
			print(gettext("Unknown"));
173
		}
174
175 6795e0da Renato Botelho
?>
176 3795cc0a sbeaver
					</td>
177
					<td>
178 6795e0da Renato Botelho
<?php
179 86b2861c Matt Smith
		if (!empty($ikesa['local-host'])) {
180
			print(htmlspecialchars($ikesa['local-host']));
181
		} else {
182
			print(gettext("Unknown"));
183
		}
184 936bfb38 Renato Botelho
		/*
185
		 * XXX: local-nat-t was defined by pfSense
186
		 * When strongswan team accepted the change, they changed it to
187
		 * nat-local. Keep both for a while and remove local-nat-t in
188
		 * the future
189
		 */
190 2f95dc5a Renato Botelho
		if (isset($ikesa['local-nat-t']) || isset($ikesa['nat-local'])) {
191 86b2861c Matt Smith
			print(" NAT-T");
192
		}
193 6795e0da Renato Botelho
?>
194 0da0d43e Phil Davis
					</td>
195 3795cc0a sbeaver
					<td>
196 6795e0da Renato Botelho
<?php
197 86b2861c Matt Smith
		$identity = "";
198
		if (!empty($ikesa['remote-id'])) {
199
			if ($ikesa['remote-id'] == '%any') {
200 3bd74348 bruno
				$identity = htmlspecialchars(gettext('Any identifier'));
201 86b2861c Matt Smith
			} else {
202 dc9d5657 jim-p
				$identity = htmlspecialchars($ikesa['remote-id']);
203 86b2861c Matt Smith
			}
204
		}
205
		if (!empty($ikesa['remote-xauth-id'])) {
206
			echo htmlspecialchars($ikesa['remote-xauth-id']);
207
			echo "<br/>{$identity}";
208
		} elseif (!empty($ikesa['remote-eap-id'])) {
209
			echo htmlspecialchars($ikesa['remote-eap-id']);
210
			echo "<br/>{$identity}";
211
		} else {
212
			if (empty($identity)) {
213 3795cc0a sbeaver
				print(gettext("Unknown"));
214 86b2861c Matt Smith
			} else {
215
				print($identity);
216 3795cc0a sbeaver
			}
217 86b2861c Matt Smith
		}
218 6795e0da Renato Botelho
?>
219 3795cc0a sbeaver
					</td>
220
					<td>
221 6795e0da Renato Botelho
<?php
222 86b2861c Matt Smith
		if (!empty($ikesa['remote-host'])) {
223
			print(htmlspecialchars($ikesa['remote-host']));
224
		} else {
225
			print(gettext("Unknown"));
226
		}
227 936bfb38 Renato Botelho
		/*
228
		 * XXX: remote-nat-t was defined by pfSense
229
		 * When strongswan team accepted the change, they changed it to
230
		 * nat-remote. Keep both for a while and remove remote-nat-t in
231
		 * the future
232
		 */
233
		if (isset($ikesa['remote-nat-t']) || isset($ikesa['nat-remote'])) {
234 86b2861c Matt Smith
			print(" NAT-T");
235
		}
236 6795e0da Renato Botelho
?>
237 4a098495 Sjon Hortensius
					</td>
238 3795cc0a sbeaver
					<td>
239
						IKEv<?=htmlspecialchars($ikesa['version'])?>
240
						<br/>
241 86b2861c Matt Smith
<?php
242
		if ($ikesa['initiator'] == 'yes') {
243
			print("initiator");
244
		} else {
245
			print("responder");
246
		}
247
?>
248 3795cc0a sbeaver
					</td>
249
					<td>
250 00ae4060 Matt Smith
						<?=htmlspecialchars($ikesa['reauth-time']) . gettext(" seconds (") . convert_seconds_to_hms($ikesa['reauth-time']) . ")";?>
251 3795cc0a sbeaver
					</td>
252
					<td>
253 86b2861c Matt Smith
						<?=htmlspecialchars($ikesa['encr-alg'])?>
254 3795cc0a sbeaver
						<br/>
255 86b2861c Matt Smith
						<?=htmlspecialchars($ikesa['integ-alg'])?>
256 3795cc0a sbeaver
						<br/>
257 86b2861c Matt Smith
						<?=htmlspecialchars($ikesa['prf-alg'])?>
258 3795cc0a sbeaver
						<br/>
259 86b2861c Matt Smith
						<?=htmlspecialchars($ikesa['dh-group'])?>
260 3795cc0a sbeaver
					</td>
261
					<td>
262
<?php
263 86b2861c Matt Smith
		if ($ikesa['state'] == 'ESTABLISHED') {
264 fbe6a2ce Jared Dillard
			print('<span class="text-success">');
265 86b2861c Matt Smith
		} else {
266
			print('<span>');
267
		}
268 6795e0da Renato Botelho
?>
269 86b2861c Matt Smith
						<?=ucfirst(htmlspecialchars($ikesa['state']))?>
270 00ae4060 Matt Smith
						<br/><?=htmlspecialchars($ikesa['established']) . gettext(" seconds (" . convert_seconds_to_hms($ikesa['established']) . ") ago")?>
271 3795cc0a sbeaver
						</span>
272
					</td>
273
					<td >
274 6795e0da Renato Botelho
<?php
275 2804a932 Luiz Otavio O Souza
		if ($ikesa['state'] != 'ESTABLISHED') {
276 6795e0da Renato Botelho
?>
277 37676f4e jim-p
						<a href="status_ipsec.php?act=connect&amp;ikeid=<?=$con_id; ?>" class="btn btn-xs btn-success" data-toggle="tooltip" title="<?=gettext("Connect VPN");?>" >
278
							<i class="fa fa-sign-in icon-embed-btn"></i>
279 3795cc0a sbeaver
							<?=gettext("Connect VPN")?>
280 17402c63 Ermal
						</a>
281 6795e0da Renato Botelho
<?php
282 86b2861c Matt Smith
		} else {
283 6795e0da Renato Botelho
?>
284 3bd74348 bruno
						<a href="status_ipsec.php?act=ikedisconnect&amp;ikeid=<?=$con_id; ?>" class="btn btn-xs btn-danger" data-toggle="tooltip" title="<?=gettext("Disconnect VPN");?>">
285 37676f4e jim-p
							<i class="fa fa-trash icon-embed-btn"></i>
286 3795cc0a sbeaver
							<?=gettext("Disconnect")?>
287
						</a><br />
288 6795e0da Renato Botelho
<?php
289 86b2861c Matt Smith
		}
290 6795e0da Renato Botelho
?>
291 3795cc0a sbeaver
					</td>
292
				</tr>
293
				<tr>
294
					<td colspan = 10>
295 6795e0da Renato Botelho
<?php
296 97242546 Matt Smith
		if (is_array($ikesa['child-sas']) && (count($ikesa['child-sas']) > 0)) {
297 6795e0da Renato Botelho
?>
298 3795cc0a sbeaver
						<div id="btnchildsa-<?=$ikeid?>">
299 37676f4e jim-p
							<a type="button" onclick="show_childsa('childsa-<?=$ikeid?>','btnchildsa-<?=$ikeid?>');" class="btn btn-sm btn-info" />
300
								<i class="fa fa-plus-circle icon-embed-btn"></i>
301 3795cc0a sbeaver
								<?=gettext('Show child SA entries')?>
302
							</a>
303
						</div>
304 fd875a8d Ermal
305 3795cc0a sbeaver
						<table class="table table-hover table-condensed" id="childsa-<?=$ikeid?>" style="display:none">
306
							<thead>
307 fbe6a2ce Jared Dillard
								<tr class="bg-info">
308 3795cc0a sbeaver
									<th><?=gettext("Local subnets")?></th>
309
									<th><?=gettext("Local SPI(s)")?></th>
310
									<th><?=gettext("Remote subnets")?></th>
311
									<th><?=gettext("Times")?></th>
312
									<th><?=gettext("Algo")?></th>
313
									<th><?=gettext("Stats")?></th>
314
									<th><!-- Buttons --></th>
315
								</tr>
316
							</thead>
317
							<tbody>
318
<?php
319 86b2861c Matt Smith
			foreach ($ikesa['child-sas'] as $childid => $childsa) {
320 3795cc0a sbeaver
?>
321
								<tr>
322
									<td>
323
<?php
324 86b2861c Matt Smith
				if (is_array($childsa['local-ts'])) {
325
					foreach ($childsa['local-ts'] as $lnets) {
326 3795cc0a sbeaver
						print(htmlspecialchars(ipsec_fixup_network($lnets)) . "<br />");
327 86b2861c Matt Smith
					}
328
				} else {
329 3795cc0a sbeaver
					print(gettext("Unknown"));
330 86b2861c Matt Smith
				}
331 6795e0da Renato Botelho
?>
332 3795cc0a sbeaver
									</td>
333
									<td>
334 6795e0da Renato Botelho
<?php
335 86b2861c Matt Smith
				if (isset($childsa['spi-in'])) {
336
					print(gettext("Local: ") . htmlspecialchars($childsa['spi-in']));
337
				}
338 0da0d43e Phil Davis
339 86b2861c Matt Smith
				if (isset($childsa['spi-out'])) {
340
					print('<br/>' . gettext('Remote: ') . htmlspecialchars($childsa['spi-out']));
341
				}
342 6795e0da Renato Botelho
?>
343 3795cc0a sbeaver
									</td>
344
									<td>
345 6795e0da Renato Botelho
<?php
346 86b2861c Matt Smith
				if (is_array($childsa['remote-ts'])) {
347
					foreach ($childsa['remote-ts'] as $rnets) {
348 3795cc0a sbeaver
						print(htmlspecialchars(ipsec_fixup_network($rnets)) . '<br />');
349 86b2861c Matt Smith
					}
350
				} else {
351 3795cc0a sbeaver
					print(gettext("Unknown"));
352 86b2861c Matt Smith
				}
353 6795e0da Renato Botelho
?>
354 3795cc0a sbeaver
									</td>
355
									<td>
356 6795e0da Renato Botelho
<?php
357 00ae4060 Matt Smith
				print(gettext("Rekey: ") . htmlspecialchars($childsa['rekey-time']) . gettext(" seconds (") . convert_seconds_to_hms($childsa['rekey-time']) . ")");
358 abe98adb Phil Davis
				print('<br/>' . gettext('Life: ') . htmlspecialchars($childsa['life-time']) . gettext(" seconds (") . convert_seconds_to_hms($childsa['life-time']) . ")");
359
				print('<br/>' . gettext('Install: ') .htmlspecialchars($childsa['install-time']) . gettext(" seconds (") . convert_seconds_to_hms($childsa['install-time']) . ")");
360 3795cc0a sbeaver
361 6795e0da Renato Botelho
?>
362 3795cc0a sbeaver
									</td>
363
									<td>
364
<?php
365 86b2861c Matt Smith
				print(htmlspecialchars($childsa['encr-alg']) . '<br/>');
366
				print(htmlspecialchars($childsa['integ-alg']) . '<br/>');
367 0da0d43e Phil Davis
368 86b2861c Matt Smith
				if (!empty($childsa['prf-alg'])) {
369
					print(htmlspecialchars($childsa['prf-alg']) . '<br/>');
370
				}
371
				if (!empty($childsa['dh-group'])) {
372
					print(htmlspecialchars($childsa['dh-group']) . '<br/>');
373
				}
374
				if (!empty($childsa['esn'])) {
375 6de4dd1d Phil Davis
					print(htmlspecialchars($childsa['esn']) . '<br/>');
376 86b2861c Matt Smith
				}
377 0da0d43e Phil Davis
378 86b2861c Matt Smith
				print(gettext("IPComp: "));
379
				if (!empty($childsa['cpi-in']) || !empty($childsa['cpi-out'])) {
380
					print(htmlspecialchars($childsa['cpi-in']) . " " . htmlspecialchars($childsa['cpi-out']));
381
				} else {
382
					print(gettext('none'));
383
				}
384 3795cc0a sbeaver
?>
385
									</td>
386
									<td>
387
<?php
388 d0499e38 jim-p
				print(gettext("Bytes-In: ") . htmlspecialchars(number_format($childsa['bytes-in'])) . ' (' . htmlspecialchars(format_bytes($childsa['bytes-in'])) . ')<br/>');
389
				print(gettext("Packets-In: ") . htmlspecialchars(number_format($childsa['packets-in'])) . '<br/>');
390
				print(gettext("Bytes-Out: ") . htmlspecialchars(number_format($childsa['bytes-out'])) . ' (' . htmlspecialchars(format_bytes($childsa['bytes-out'])) . ')<br/>');
391
				print(gettext("Packets-Out: ") . htmlspecialchars(number_format($childsa['packets-out'])) . '<br/>');
392 3795cc0a sbeaver
?>
393
									</td>
394
									<td>
395 1af5edbf Stephen Beaver
										<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')?>">
396 37676f4e jim-p
											<i class="fa fa-trash icon-embed-btn"></i>
397 3795cc0a sbeaver
											<?=gettext("Disconnect")?>
398
										</a>
399
									</td>
400
								</tr>
401
<?php
402 86b2861c Matt Smith
			}
403 b907136c Renato Botelho
?>
404 3795cc0a sbeaver
405
							</tbody>
406
						</table>
407
					</td>
408
				</tr>
409 b907136c Renato Botelho
<?php
410 97242546 Matt Smith
		}
411 3795cc0a sbeaver
412
		unset($con_id);
413 97242546 Matt Smith
	}
414
415 86b2861c Matt Smith
}
416 3795cc0a sbeaver
417
$rgmap = array();
418 86b2861c Matt Smith
foreach ($a_phase1 as $ph1ent) {
419
	if (isset($ph1ent['disabled'])) {
420 3795cc0a sbeaver
		continue;
421 86b2861c Matt Smith
	}
422 0da0d43e Phil Davis
423 3795cc0a sbeaver
	$rgmap[$ph1ent['remote-gateway']] = $ph1ent['remote-gateway'];
424 0da0d43e Phil Davis
425 86b2861c Matt Smith
	if ($ipsecconnected[$ph1ent['ikeid']]) {
426 3795cc0a sbeaver
		continue;
427 86b2861c Matt Smith
	}
428 3795cc0a sbeaver
?>
429
				<tr>
430
					<td>
431
<?php
432
	print(htmlspecialchars($ph1ent['descr']));
433
?>
434
					</td>
435
					<td>
436
<?php
437
	list ($myid_type, $myid_data) = ipsec_find_id($ph1ent, "local");
438 abe98adb Phil Davis
	if (empty($myid_data)) {
439 3795cc0a sbeaver
		print(gettext("Unknown"));
440 abe98adb Phil Davis
	} else {
441 3795cc0a sbeaver
		print(htmlspecialchars($myid_data));
442 abe98adb Phil Davis
	}
443 3795cc0a sbeaver
?>
444
					</td>
445
					<td>
446
<?php
447
	$ph1src = ipsec_get_phase1_src($ph1ent);
448 0da0d43e Phil Davis
449 abe98adb Phil Davis
	if (empty($ph1src)) {
450 3795cc0a sbeaver
		print(gettext("Unknown"));
451 abe98adb Phil Davis
	} else {
452 3795cc0a sbeaver
		print(htmlspecialchars($ph1src));
453 abe98adb Phil Davis
	}
454 3795cc0a sbeaver
?>
455
					</td>
456
					<td>
457
<?php
458
	list ($peerid_type, $peerid_data) = ipsec_find_id($ph1ent, "peer", $rgmap);
459 abe98adb Phil Davis
	if (empty($peerid_data)) {
460 3795cc0a sbeaver
		print(gettext("Unknown"));
461 abe98adb Phil Davis
	} else {
462 3795cc0a sbeaver
		print(htmlspecialchars($peerid_data));
463 abe98adb Phil Davis
	}
464 3795cc0a sbeaver
?>
465
					</td>
466
					<td>
467
<?php
468
	$ph1src = ipsec_get_phase1_dst($ph1ent);
469 abe98adb Phil Davis
	if (empty($ph1src)) {
470 3795cc0a sbeaver
		print(gettext("Unknown"));
471 abe98adb Phil Davis
	} else {
472 3795cc0a sbeaver
		print(htmlspecialchars($ph1src));
473 abe98adb Phil Davis
	}
474 3795cc0a sbeaver
?>
475
					</td>
476
					<td>
477
					</td>
478
					<td>
479
					</td>
480
					<td>
481
					</td>
482
<?php
483 86b2861c Matt Smith
	if (isset($ph1ent['mobile'])) {
484 3795cc0a sbeaver
?>
485
					<td>
486
						<?=gettext("Awaiting connections")?>
487
					</td>
488
					<td>
489
					</td>
490
<?php
491 86b2861c Matt Smith
	} else {
492 3795cc0a sbeaver
?>
493
					<td>
494
						<?=gettext("Disconnected")?>
495
					</td>
496
					<td >
497 1af5edbf Stephen Beaver
						<a href="status_ipsec.php?act=connect&amp;ikeid=<?=$ph1ent['ikeid']; ?>" class="btn btn-xs btn-success">
498 37676f4e jim-p
							<i class="fa fa-sign-in icon-embed-btn"></i>
499 3795cc0a sbeaver
							<?=gettext("Connect VPN")?>
500 6795e0da Renato Botelho
						</a>
501 3795cc0a sbeaver
					</td>
502 b907136c Renato Botelho
<?php
503 86b2861c Matt Smith
	}
504 b907136c Renato Botelho
?>
505 3795cc0a sbeaver
				</tr>
506 fd875a8d Ermal
<?php
507 86b2861c Matt Smith
}
508 3795cc0a sbeaver
unset($ipsecconnected, $phase1, $rgmap);
509 c7fbdd6c Ermal
?>
510 3795cc0a sbeaver
			</tbody>
511 c7fbdd6c Ermal
		</table>
512
	</div>
513 3795cc0a sbeaver
</div>
514
515 c7fbdd6c Ermal
<script type="text/javascript">
516 a8590dd6 Colin Fleming
//<![CDATA[
517 c7fbdd6c Ermal
function show_childsa(id, buttonid) {
518
	document.getElementById(buttonid).innerHTML='';
519
	aodiv = document.getElementById(id);
520 fbe6a2ce Jared Dillard
	aodiv.style.display = "table";
521 c7fbdd6c Ermal
}
522 a8590dd6 Colin Fleming
//]]>
523 c7fbdd6c Ermal
</script>
524 3795cc0a sbeaver
525
<?php
526
unset($status);
527 d2c1089f Phil Davis
if (ipsec_enabled()) {
528
?>
529
<div class="infoblock">
530
<?php
531
} else {
532
?>
533
<div class="infoblock blockopen">
534
<?php
535
}
536 8545adde k-paulius
print_info_box(sprintf(gettext('You can configure IPsec %1$shere%2$s.'), '<a href="vpn_ipsec.php">', '</a>'), 'info', false);
537 d2c1089f Phil Davis
?>
538
</div>
539
<?php
540 3795cc0a sbeaver
include("foot.inc"); ?>