Projet

Général

Profil

Télécharger (9,68 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_ipsec.php @ ea0efb36

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

    
275
			unset($con_id);
276
		}
277
	}
278
?>
279
			<tr style="display:none;"><td></td></tr>
280
		</tbody>
281
		</table>
282
	</div>
283
	</td>
284
	</tr>
285
</table>
286

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