Project

General

Profile

Download (7.72 KB) Statistics
| Branch: | Tag: | Revision:
1 cf7d1057 Scott Ullrich
<?php
2
/* $Id$ */
3
/*
4
	diag_ipsec.php
5 13d193c2 Scott Ullrich
	Copyright (C) 2004-2009 Scott Ullrich
6 a93e56c5 Matthew Grooms
	Copyright (C) 2008 Shrew Soft Inc <mgrooms@shrew.net>.
7 cf7d1057 Scott Ullrich
	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 13d193c2 Scott Ullrich
/*
35
	pfSense_MODULE:	ipsec
36
*/
37
38 6b07c15a Matthew Grooms
##|+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 a93e56c5 Matthew Grooms
global $g;
47
48 f8ec8de4 Renato Botelho
$pgtitle = array(gettext("Status"),gettext("IPsec"));
49 cf7d1057 Scott Ullrich
50
require("guiconfig.inc");
51
include("head.inc");
52 483e6de8 Scott Ullrich
require("ipsec.inc");
53 a93e56c5 Matthew Grooms
54 6e8b0ec3 jim-p
if ($_GET['act'] == "connect") {
55
	if (is_ipaddr($_GET['remoteid']) && is_ipaddr($_GET['source'])) {
56
		exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
57
	}
58
}
59
60 6e0b68bf jim-p
61
if ($_GET['act'] == "disconnect") {
62
	if (!empty($_GET['user'])) {
63
		ipsec_disconnect_mobile($_GET['user']);
64
		sleep(1);
65
		$savemsg = gettext("Disconnected user") . " " . $_GET['user'];
66
	}
67
}
68
69 a93e56c5 Matthew Grooms
if (!is_array($config['ipsec']['phase2']))
70
    $config['ipsec']['phase2'] = array();
71
72
$a_phase2 = &$config['ipsec']['phase2'];
73
74
$spd = ipsec_dump_spd();
75
$sad = ipsec_dump_sad();
76 6e0b68bf jim-p
$mobile = ipsec_dump_mobile();
77 a93e56c5 Matthew Grooms
78 cf7d1057 Scott Ullrich
?>
79
80 6e0b68bf jim-p
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?php echo $jsevents["body"]["onload"]; ?>">
81 cf7d1057 Scott Ullrich
<?php include("fbegin.inc"); ?>
82
<div id="inputerrors"></div>
83
<table width="100%" border="0" cellpadding="0" cellspacing="0">
84
	<tr>
85 a93e56c5 Matthew Grooms
		<td>
86
			<?php
87
				$tab_array = array();
88 f8ec8de4 Renato Botelho
				$tab_array[0] = array(gettext("Overview"), true, "diag_ipsec.php");
89
				$tab_array[1] = array(gettext("SAD"), false, "diag_ipsec_sad.php");
90
				$tab_array[2] = array(gettext("SPD"), false, "diag_ipsec_spd.php");
91
				$tab_array[3] = array(gettext("Logs"), false, "diag_logs_ipsec.php");
92 a93e56c5 Matthew Grooms
				display_top_tabs($tab_array);
93
			?>
94 331aa57b Scott Ullrich
		</td>
95 cf7d1057 Scott Ullrich
	</tr>
96 a93e56c5 Matthew Grooms
	<tr>
97 6e0b68bf jim-p
	<td>
98 a93e56c5 Matthew Grooms
			<div id="mainarea">
99 034b4918 Scott Ullrich
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
100 6e0b68bf jim-p
					<thead>
101 a93e56c5 Matthew Grooms
					<tr>
102 6e0b68bf jim-p
						<th nowrap class="listhdrr"><?php echo gettext("Local IP");?></th>
103
						<th nowrap class="listhdrr"><?php echo gettext("Remote IP");?></a></th>
104
						<th nowrap class="listhdrr"><?php echo gettext("Local Network");?></th>
105
						<th nowrap class="listhdrr"><?php echo gettext("Remote Network");?></a></th>
106
						<th nowrap class="listhdrr"><?php echo gettext("Description");?></a></th>
107
						<th nowrap class="listhdrr"><?php echo gettext("Status");?></th>
108 a93e56c5 Matthew Grooms
					</tr>
109 6e0b68bf jim-p
					</thead>
110
					<tbody>
111 a93e56c5 Matthew Grooms
					<?php
112
						foreach ($a_phase2 as $ph2ent) {
113 6e0b68bf jim-p
							if ($ph2ent['remoteid']['type'] == "mobile")
114
								continue;
115 221f5d17 Chris Buechler
							ipsec_lookup_phase1($ph2ent,$ph1ent);
116
							if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
117 4976f453 Cristian Feldman
								if(ipsec_phase2_status($spd,$sad,$ph1ent,$ph2ent)) {
118 a93e56c5 Matthew Grooms
									$icon = "pass";
119 4976f453 Cristian Feldman
									$status = "Active";
120
								} elseif(!isset($config['ipsec']['enable'])) {
121 b385327a Chris Buechler
									$icon = "block";
122 4976f453 Cristian Feldman
									$status = "Disabled";
123
								} else {
124 a93e56c5 Matthew Grooms
									$icon = "reject";
125 4976f453 Cristian Feldman
									$status = "Error";
126
								}
127 a93e56c5 Matthew Grooms
					?>
128
					<tr>
129
						<td class="listlr">
130 6e0b68bf jim-p
							<?php echo htmlspecialchars(ipsec_get_phase1_src($ph1ent));?>
131 a93e56c5 Matthew Grooms
						</td>
132
						<td class="listr">
133 6e0b68bf jim-p
							<?php echo htmlspecialchars($ph1ent['remote-gateway']);?>
134 a93e56c5 Matthew Grooms
						</td>
135
						<td class="listr">
136
							<?php echo ipsec_idinfo_to_text($ph2ent['localid']); ?>
137
						</td>
138
						<td class="listr">
139
							<?php echo ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
140
						</td>
141 6e0b68bf jim-p
						<td class="listr"><?php echo htmlspecialchars($ph2ent['descr']);?></td>
142 a93e56c5 Matthew Grooms
						<td class="listr">
143 ba363183 Scott Ullrich
							<center>
144 6e0b68bf jim-p
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_<?php echo $icon; ?>.gif" title="<?php echo $status; ?>">
145 ba363183 Scott Ullrich
							</center>
146 a93e56c5 Matthew Grooms
						</td>
147 6e8b0ec3 jim-p
						<td class="list">
148
							<?php
149
							$source = "";
150 59231855 Darren Embry
							$ip_interface = null;
151
							$ip_alias = null;
152 6e8b0ec3 jim-p
							if ($ph2ent['localid']['type'] == 'lan') {
153
								$source = get_interface_ip('lan');
154 59231855 Darren Embry
							} else if ($ph2ent['localid']['type'] == 'network') {
155
								$ip_interface = find_ip_interface($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
156
								if (!$ip_interface) {
157
									$ip_alias = find_virtual_ip_alias($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
158
								}
159 6e8b0ec3 jim-p
							} else {
160 59231855 Darren Embry
								$ip_interface = find_ip_interface($ph2ent['localid']['address']);
161
								if (!$ip_interface) {
162
									$ip_alias = find_virtual_ip_alias($ph2ent['localid']['address']);
163
								}
164
							}
165
							if ($ip_interface) {
166
								$source = get_interface_ip($ip_interface);
167
							} else if ($ip_alias) {
168
								$source = $ip_alias['subnet'];
169 6e8b0ec3 jim-p
							}
170
							?>
171
							<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
172
							<center>
173 6e0b68bf jim-p
								<a href="diag_ipsec.php?act=connect&remoteid=<?php echo $ph2ent['remoteid']['address']; ?>&source=<?php echo $source; ?>">
174
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0">
175 6e8b0ec3 jim-p
								</a>
176
							</center>
177
							<?php else: ?>
178
								&nbsp;
179
							<?php endif; ?>
180
						</td>
181 a93e56c5 Matthew Grooms
					</tr>
182
					<?php
183
							}
184
						}
185
					?>
186 6e0b68bf jim-p
					</tbody>
187
				</table>
188
				<?php if (isset($config['ipsec']['client']['enable'])): ?>
189
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
190
					<thead>
191
					<tr>
192
						<th nowrap class="listhdrr"><?php echo gettext("Mobile User");?></th>
193
						<th nowrap class="listhdrr"><?php echo gettext("Login Time");?></a></th>
194
						<th nowrap class="listhdrr"><?php echo gettext("Local");?></th>
195
						<th nowrap class="listhdrr"><?php echo gettext("Remote");?></a></th>
196
						<th nowrap class="list">&nbsp;</th>
197
					</tr>
198
					</thead>
199
					<tbody>
200
					<?php	foreach ($mobile as $muser): ?>
201
					<tr>
202
						<td class="listlr"><?php echo $muser['username']; ?></td>
203
						<td class="listr" align="center"><?php echo $muser['logintime']; ?></td>
204
						<td class="listr" align="center"><?php echo $muser['local']; ?></td>
205
						<td class="listr" align="center"><?php echo $muser['remote']; ?></td>
206
						<td class="list" align="center"><a href="diag_ipsec.php?act=disconnect&user=<?php echo $muser['username']; ?>"><img src='/themes/<?php echo $g['theme']; ?>/images/icons/icon_x.gif' height='17' width='17' border='0'/></a></td>
207
					</tr>
208
					<?php	endforeach; ?>
209
					</tbody>
210 a93e56c5 Matthew Grooms
				</table>
211 6e0b68bf jim-p
				<?php endif; ?>
212 a93e56c5 Matthew Grooms
			</div>
213 cf7d1057 Scott Ullrich
		</td>
214 a93e56c5 Matthew Grooms
	</tr>
215 cf7d1057 Scott Ullrich
</table>
216
217 0f78d3ad Scott Ullrich
<p/>
218
219
<span class="vexpl">
220
	<span class="red">
221 6e0b68bf jim-p
		<strong><?php echo gettext("Note:");?><br /></strong>
222 0f78d3ad Scott Ullrich
	</span>
223 6e0b68bf jim-p
	<?php echo gettext("You can configure IPsec");?>
224 0f78d3ad Scott Ullrich
	<a href="vpn_ipsec.php">here</a>.
225
</span>
226
227 cf7d1057 Scott Ullrich
<?php include("fend.inc"); ?>
228
</body>
229
</html>