Project

General

Profile

Download (9.44 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	diag_ipsec.php
5
	Copyright (C) 2004-2009 Scott Ullrich
6
	Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
7
	All rights reserved.
8

    
9
	Parts of this code was originally based on vpn_ipsec_sad.php
10
	Copyright (C) 2003-2004 Manuel Kasper
11

    
12
	Redistribution and use in source and binary forms, with or without
13
	modification, are permitted provided that the following conditions are met:
14

    
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 the
20
	   documentation and/or other materials provided with the distribution.
21

    
22
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
23
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
24
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
26
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31
	POSSIBILITY OF SUCH DAMAGE.
32
*/
33

    
34
/*
35
	pfSense_MODULE:	ipsec
36
*/
37

    
38
##|+PRIV
39
##|*IDENT=page-status-ipsec
40
##|*NAME=Status: IPsec page
41
##|*DESCR=Allow access to the 'Status: IPsec' page.
42
##|*MATCH=diag_ipsec.php*
43
##|-PRIV
44

    
45

    
46
global $g;
47

    
48
$pgtitle = array(gettext("Status"),gettext("IPsec"));
49
$shortcut_section = "ipsec";
50

    
51
require("guiconfig.inc");
52
include("head.inc");
53
require("ipsec.inc");
54

    
55
if ($_GET['act'] == 'connect') {
56
	if (ctype_digit($_GET['ikeid'])) {
57
		mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
58
		mwexec("/usr/local/sbin/ipsec up con" . escapeshellarg($_GET['ikeid']));
59
	}
60
} else if ($_GET['act'] == 'ikedisconnect') {
61
	if (ctype_digit($_GET['ikeid'])) {
62
		mwexec("/usr/local/sbin/ipsec down con" . escapeshellarg($_GET['ikeid']));
63
	}
64
} else if ($_GET['act'] == 'disconnect') {
65
	if (!empty($_GET['user'])) {
66
		ipsec_disconnect_mobile($_GET['user']);
67
		sleep(1);
68
		$savemsg = gettext("Disconnected user") . " " . $_GET['user'];
69
	}
70
}
71

    
72
if (!is_array($config['ipsec']['phase2']))
73
    $config['ipsec']['phase2'] = array();
74

    
75
$a_phase2 = &$config['ipsec']['phase2'];
76

    
77
$status = ipsec_smp_dump_status();
78

    
79
?>
80

    
81
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?php echo $jsevents["body"]["onload"]; ?>">
82
<?php include("fbegin.inc"); ?>
83
<div id="inputerrors"></div>
84
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="status ipsec">
85
	<tr>
86
		<td>
87
			<?php
88
				$tab_array = array();
89
				$tab_array[0] = array(gettext("Overview"), true, "diag_ipsec.php");
90
				$tab_array[1] = array(gettext("SAD"), false, "diag_ipsec_sad.php");
91
				$tab_array[2] = array(gettext("SPD"), false, "diag_ipsec_spd.php");
92
				$tab_array[3] = array(gettext("Logs"), false, "diag_logs_ipsec.php");
93
				display_top_tabs($tab_array);
94
			?>
95
		</td>
96
	</tr>
97
	<tr>
98
	<td>
99
	<div id="mainarea">
100
		<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable" summary="status">
101
		<thead>
102
			<tr>
103
				<th class="listhdrr nowrap"><?php echo gettext("Description");?></th>
104
				<th class="listhdrr nowrap"><?php echo gettext("Local ID");?></th>
105
				<th class="listhdrr nowrap"><?php echo gettext("Local IP");?></th>
106
				<th class="listhdrr nowrap"><?php echo gettext("Remote ID");?></th>
107
				<th class="listhdrr nowrap"><?php echo gettext("Remote IP");?></th>
108
				<th class="listhdrr nowrap"><?php echo gettext("Role");?></th>
109
				<th class="listhdrr nowrap"><?php echo gettext("Status");?></th>
110
				<td class="list nowrap"></td>
111
		</tr>
112
		</thead>
113
		<tbody>
114
<?php
115
	if (is_array($status['query']) && is_array($status['query']['ikesalist']) && is_array($status['query']['ikesalist']['ikesa'])) {
116
		foreach ($status['query']['ikesalist']['ikesa'] as $ikeid => $ikesa) {
117
			$con_id = substr($ikesa['peerconfig'], 3);
118

    
119
			if (ipsec_phase1_status($status['query']['ikesalist']['ikesa'], $ikesa['id'])) {
120
				$icon = "pass";
121
			} elseif(!isset($config['ipsec']['enable'])) {
122
				$icon = "block";
123
			} else {
124
				$icon = "reject";
125
			}
126
?>
127
			<tr>
128
				<td class="listlr">
129
					<?php echo htmlspecialchars(ipsec_get_descr($con_id));?>
130
				</td>
131
				<td class="listr">
132
			<?php   if (!is_array($ikesa['local']))
133
					echo "Unknown";
134
				else {
135
					if (!empty($ikesa['local']['identification']))
136
						echo htmlspecialchars($ikesa['local']['identification']);
137
					else
138
						echo 'Unknown';
139
				}
140
			?>
141
				</td>
142
				<td class="listr">
143
			<?php   if (!is_array($ikesa['local']))
144
					echo "Unknown";
145
				else {
146
					if (!empty($ikesa['local']['address']))
147
						echo htmlspecialchars($ikesa['local']['address']) . ':' . htmlspecialchars($ikesa['local']['port']);
148
					else
149
						echo 'Unknown';
150
					if ($ikesa['local']['nat'] != 'false')
151
						echo " NAT-T";
152
				}
153
			?>
154
				</td>
155
				<td class="listr">
156
			<?php   if (!is_array($ikesa['remote']))
157
					echo "Unknown";
158
				else {
159
					if (!empty($ikesa['remote']['identification']))
160
						echo htmlspecialchars($ikesa['remote']['identification']);
161
					else
162
						echo 'Unknown';
163
				}
164
			?>
165
				</td>
166
				<td class="listr">
167
			<?php   if (!is_array($ikesa['remote']))
168
					echo "Unknown";
169
				else {
170
					if (!empty($ikesa['remote']['address']))
171
						echo htmlspecialchars($ikesa['remote']['address']) . ':' . htmlspecialchars($ikesa['remote']['port']);
172
					else
173
						echo 'Unknown';
174
					if ($ikesa['remote']['nat'] != 'false')
175
						echo " NAT-T";
176
				}
177
			?>
178
				</td>
179
				<td class="listr">
180
					<?php echo htmlspecialchars($ikesa['role']);?>
181
				</td>
182
				<td class="listr">
183
					<center>
184
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_<?php echo $icon; ?>.gif" title="<?php echo $ikesa['status']; ?>" alt=""/>
185
						<br/><?php echo htmlspecialchars($ikesa['status']);?>
186
					</center>
187
				</td>
188
				<td >
189
				<?php if ($icon != "pass"): ?>
190
					<center>
191
						<a href="diag_ipsec.php?act=connect&amp;ikeid=<?php echo $con_id; ?>">
192
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0"/>
193
						</a>
194
					</center>
195
				<?php else: ?>
196
					<center>
197
						<a href="diag_ipsec.php?act=ikedisconnect&amp;ikeid=<?php echo $con_id; ?>">
198
						<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_stop.gif" alt="Disconnect VPN" title="Disconnect VPN" border="0"/>
199
						</a>
200
					</center>
201
				<?php endif; ?>
202
				</td>
203
				<td valign="middle" class="list nowrap">
204
					<table border="0" cellspacing="0" cellpadding="1" summary="">
205
					</table>
206
				</td>
207
			</tr>
208
			<?php if (is_array($ikesa['childsalist'])): ?>
209
			<tr>
210
				<td class="listrborder" colspan="7">
211
				<div id="btnchildsa-<?=$ikeid;?>">
212
					<input  type="button" onclick="show_childsa('childsa-<?=$ikeid;?>','btnchildsa-<?=$ikeid;?>');" value="+" /> - Show child SA entries
213
				</div>
214
				<table class="tabcont" width="100%" height="100%" border="0" cellspacing="0" cellpadding="0" id="childsa-<?=$ikeid;?>" style="display:none" summary="">
215
				<thead>
216
					<tr>
217
						<th class="listhdrr nowrap"><?php echo gettext("Local subnets");?></th>
218
						<th class="listhdrr nowrap"><?php echo gettext("Local SPI");?></th>
219
						<th class="listhdrr nowrap"><?php echo gettext("Remote SPI");?></th>
220
						<th class="listhdrr nowrap"><?php echo gettext("Remote subnets");?></th>
221
					</tr>
222
				</thead>
223
				<tbody>
224
				<?php
225
					if (is_array($ikesa['childsalist']['childsa'])) {
226
						foreach ($ikesa['childsalist']['childsa'] as $childsa) {
227
				?>
228
					<tr valign="top">
229
						<td class="listlr nowrap">
230
				<?php	if (is_array($childsa['local']) && is_array($childsa['local']['networks']) && is_array($childsa['local']['networks']['network'])) {
231
						foreach ($childsa['local']['networks']['network'] as $lnets) {
232
							echo htmlspecialchars($lnets) . "<br />";	
233
						}
234
					} else
235
						echo "Unknown";
236
				?>
237
						</td>
238
						<td class="listr nowrap">
239
				<?php	if (is_array($childsa['local']))
240
						echo htmlspecialchars($childsa['local']['spi']);
241
				?>
242
						</td>
243
						<td class="listr nowrap">
244
				<?php	if (is_array($childsa['remote']))
245
						echo htmlspecialchars($childsa['remote']['spi']);
246
				?>
247
						</td>
248
						<td class="listr nowrap">
249
				<?php	if (is_array($childsa['remote']) && is_array($childsa['remote']['networks']) && is_array($childsa['remote']['networks']['network'])) {
250
						foreach ($childsa['remote']['networks']['network'] as $rnets) {
251
							echo htmlspecialchars($rnets) . "<br />";	
252
						}
253
					} else
254
						echo "Unknown";
255
				?>
256
						</td>
257
						<td class="list nowrap">
258
							&nbsp;
259
						</td>
260
					</tr>
261
				<?php } } ?>
262
					<tr style="display:none;"><td></td></tr>
263
				</tbody>
264
				</table>
265
				</td>
266
			</tr>
267
			<?php endif; 
268

    
269
			unset($con_id);
270
		}
271
	}
272
?>
273
			<tr style="display:none;"><td></td></tr>
274
		</tbody>
275
		</table>
276
	</div>
277
	</td>
278
	</tr>
279
</table>
280

    
281
<p class="vexpl">
282
	<span class="red">
283
		<strong><?php echo gettext("Note:");?><br /></strong>
284
	</span>
285
	<?php echo gettext("You can configure IPsec");?>
286
	<a href="vpn_ipsec.php">here</a>.
287
</p>
288
<?php unset($status); include("fend.inc"); ?>
289
<script type="text/javascript">
290
//<![CDATA[
291
function show_childsa(id, buttonid) {
292
	document.getElementById(buttonid).innerHTML='';
293
	aodiv = document.getElementById(id);
294
	aodiv.style.display = "block";
295
}
296
//]]>
297
</script>
298
</body>
299
</html>
(14-14/255)