Project

General

Profile

Download (7.74 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 (is_ipaddr($_GET['remoteid']) && is_ipaddr($_GET['source'])) {
57
		exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
58
	}
59
}
60

    
61

    
62
if ($_GET['act'] == "disconnect") {
63
	if (!empty($_GET['user'])) {
64
		ipsec_disconnect_mobile($_GET['user']);
65
		sleep(1);
66
		$savemsg = gettext("Disconnected user") . " " . $_GET['user'];
67
	}
68
}
69

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

    
73
$a_phase2 = &$config['ipsec']['phase2'];
74

    
75
$spd = ipsec_dump_spd();
76
$sad = ipsec_dump_sad();
77
$mobile = ipsec_dump_mobile();
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">
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">
101
					<thead>
102
					<tr>
103
						<th nowrap class="listhdrr"><?php echo gettext("Local IP");?></th>
104
						<th nowrap class="listhdrr"><?php echo gettext("Remote IP");?></a></th>
105
						<th nowrap class="listhdrr"><?php echo gettext("Local Network");?></th>
106
						<th nowrap class="listhdrr"><?php echo gettext("Remote Network");?></a></th>
107
						<th nowrap class="listhdrr"><?php echo gettext("Description");?></a></th>
108
						<th nowrap class="listhdrr"><?php echo gettext("Status");?></th>
109
					</tr>
110
					</thead>
111
					<tbody>
112
					<?php
113
						foreach ($a_phase2 as $ph2ent) {
114
							if ($ph2ent['remoteid']['type'] == "mobile")
115
								continue;
116
							ipsec_lookup_phase1($ph2ent,$ph1ent);
117
							if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
118
								if(ipsec_phase2_status($spd,$sad,$ph1ent,$ph2ent)) {
119
									$icon = "pass";
120
									$status = "Active";
121
								} elseif(!isset($config['ipsec']['enable'])) {
122
									$icon = "block";
123
									$status = "Disabled";
124
								} else {
125
									$icon = "reject";
126
									$status = "Error";
127
								}
128
					?>
129
					<tr>
130
						<td class="listlr">
131
							<?php echo htmlspecialchars(ipsec_get_phase1_src($ph1ent));?>
132
						</td>
133
						<td class="listr">
134
							<?php echo htmlspecialchars($ph1ent['remote-gateway']);?>
135
						</td>
136
						<td class="listr">
137
							<?php echo ipsec_idinfo_to_text($ph2ent['localid']); ?>
138
						</td>
139
						<td class="listr">
140
							<?php echo ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
141
						</td>
142
						<td class="listr"><?php echo htmlspecialchars($ph2ent['descr']);?></td>
143
						<td class="listr">
144
							<center>
145
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_<?php echo $icon; ?>.gif" title="<?php echo $status; ?>">
146
							</center>
147
						</td>
148
						<td class="list">
149
							<?php
150
							$source = "";
151
							$ip_interface = null;
152
							$ip_alias = null;
153
							if ($ph2ent['localid']['type'] == 'lan') {
154
								$source = get_interface_ip('lan');
155
							} else if ($ph2ent['localid']['type'] == 'network') {
156
								$ip_interface = find_ip_interface($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
157
								if (!$ip_interface) {
158
									$ip_alias = find_virtual_ip_alias($ph2ent['localid']['address'], $ph2ent['localid']['netbits']);
159
								}
160
							} else {
161
								$ip_interface = find_ip_interface($ph2ent['localid']['address']);
162
								if (!$ip_interface) {
163
									$ip_alias = find_virtual_ip_alias($ph2ent['localid']['address']);
164
								}
165
							}
166
							if ($ip_interface) {
167
								$source = get_interface_ip($ip_interface);
168
							} else if ($ip_alias) {
169
								$source = $ip_alias['subnet'];
170
							}
171
							?>
172
							<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
173
							<center>
174
								<a href="diag_ipsec.php?act=connect&remoteid=<?php echo $ph2ent['remoteid']['address']; ?>&source=<?php echo $source; ?>">
175
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0">
176
								</a>
177
							</center>
178
							<?php else: ?>
179
								&nbsp;
180
							<?php endif; ?>
181
						</td>
182
					</tr>
183
					<?php
184
							}
185
						}
186
					?>
187
					</tbody>
188
				</table>
189
				<?php if (isset($config['ipsec']['client']['enable'])): ?>
190
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
191
					<thead>
192
					<tr>
193
						<th nowrap class="listhdrr"><?php echo gettext("Mobile User");?></th>
194
						<th nowrap class="listhdrr"><?php echo gettext("Login Time");?></a></th>
195
						<th nowrap class="listhdrr"><?php echo gettext("Local");?></th>
196
						<th nowrap class="listhdrr"><?php echo gettext("Remote");?></a></th>
197
						<th nowrap class="list">&nbsp;</th>
198
					</tr>
199
					</thead>
200
					<tbody>
201
					<?php	foreach ($mobile as $muser): ?>
202
					<tr>
203
						<td class="listlr"><?php echo $muser['username']; ?></td>
204
						<td class="listr" align="center"><?php echo $muser['logintime']; ?></td>
205
						<td class="listr" align="center"><?php echo $muser['local']; ?></td>
206
						<td class="listr" align="center"><?php echo $muser['remote']; ?></td>
207
						<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>
208
					</tr>
209
					<?php	endforeach; ?>
210
					</tbody>
211
				</table>
212
				<?php endif; ?>
213
			</div>
214
		</td>
215
	</tr>
216
</table>
217

    
218
<p/>
219

    
220
<span class="vexpl">
221
	<span class="red">
222
		<strong><?php echo gettext("Note:");?><br /></strong>
223
	</span>
224
	<?php echo gettext("You can configure IPsec");?>
225
	<a href="vpn_ipsec.php">here</a>.
226
</span>
227

    
228
<?php include("fend.inc"); ?>
229
</body>
230
</html>
(13-13/248)