Projet

Général

Profil

Télécharger (8,06 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / diag_ipsec.php @ 7e736f38

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_ipaddrv4($_GET['remoteid']) && is_ipaddrv4($_GET['source'])) {
57
		exec("/sbin/ping -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
58
	}
59
	else if (is_ipaddrv6($_GET['remoteid']) && is_ipaddrv6($_GET['source'])) {
60
		exec("/sbin/ping6 -S " . escapeshellarg($_GET['source']) . " -c 1 " . escapeshellarg($_GET['remoteid']));
61
	}
62
}
63

    
64
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
$spd = ipsec_dump_spd();
78
$sad = ipsec_dump_sad();
79
$mobile = ipsec_dump_mobile();
80

    
81
?>
82

    
83
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?php echo $jsevents["body"]["onload"]; ?>">
84
<?php include("fbegin.inc"); ?>
85
<div id="inputerrors"></div>
86
<table width="100%" border="0" cellpadding="0" cellspacing="0">
87
	<tr>
88
		<td>
89
			<?php
90
				$tab_array = array();
91
				$tab_array[0] = array(gettext("Overview"), true, "diag_ipsec.php");
92
				$tab_array[1] = array(gettext("SAD"), false, "diag_ipsec_sad.php");
93
				$tab_array[2] = array(gettext("SPD"), false, "diag_ipsec_spd.php");
94
				$tab_array[3] = array(gettext("Logs"), false, "diag_logs_ipsec.php");
95
				display_top_tabs($tab_array);
96
			?>
97
		</td>
98
	</tr>
99
	<tr>
100
	<td>
101
			<div id="mainarea">
102
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
103
					<thead>
104
					<tr>
105
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Local IP");?></th>
106
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Remote IP");?></th>
107
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Local Network");?></th>
108
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Remote Network");?></th>
109
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Description");?></th>
110
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Status");?></th>
111
					</tr>
112
					</thead>
113
					<tbody>
114
					<?php
115
						$rowIndex = 0;
116
						foreach ($a_phase2 as $ph2ent) {
117
							if ($ph2ent['remoteid']['type'] == "mobile")
118
								continue;
119
							ipsec_lookup_phase1($ph2ent,$ph1ent);
120
							if (!isset($ph2ent['disabled']) && !isset($ph1ent['disabled'])) {
121
								$rowIndex++;
122
								if(ipsec_phase2_status($spd,$sad,$ph1ent,$ph2ent)) {
123
									$icon = "pass";
124
									$status = "Active";
125
								} elseif(!isset($config['ipsec']['enable'])) {
126
									$icon = "block";
127
									$status = "Disabled";
128
								} else {
129
									$icon = "reject";
130
									$status = "Error";
131
								}
132
					?>
133
					<tr>
134
						<td class="listlr">
135
							<?php echo htmlspecialchars(ipsec_get_phase1_src($ph1ent));?>
136
						</td>
137
						<td class="listr">
138
							<?php echo htmlspecialchars($ph1ent['remote-gateway']);?>
139
						</td>
140
						<td class="listr">
141
							<?php echo ipsec_idinfo_to_text($ph2ent['localid']); ?>
142
						</td>
143
						<td class="listr">
144
							<?php echo ipsec_idinfo_to_text($ph2ent['remoteid']); ?>
145
						</td>
146
						<td class="listr"><?php echo htmlspecialchars($ph2ent['descr']);?></td>
147
						<td class="listr">
148
							<center>
149
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_<?php echo $icon; ?>.gif" title="<?php echo $status; ?>" alt=""/>
150
							</center>
151
						</td>
152
						<td class="list">
153
							<?php
154
							$source = "";
155
							$ip_interface = null;
156
							$ip_alias = null;
157
							$localinfo = ipsec_idinfo_to_cidr($ph2ent['localid'], false, $ph2ent['mode']);
158
							list($localip, $localsub) = explode("/", $localinfo);
159
							$ip_interface = find_ip_interface($localip, $localsub);
160
							if (!$ip_interface)
161
								$ip_alias = find_virtual_ip_alias($localip, $localsub);
162
							if ($ip_interface) {
163
								if (is_ipaddrv6($localip))
164
									$source = get_interface_ipv6($ip_interface);
165
								else
166
									$source = get_interface_ip($ip_interface);
167
							} else if ($ip_alias) {
168
								$source = $ip_alias['subnet'];
169
							}
170
							if (!empty($ph2ent['pinghost']))
171
								$remoteid = $ph2ent['pinghost'];
172
							else
173
								$remoteid = $ph2ent['remoteid']['address'];
174
							?>
175
							<?php if (($ph2ent['remoteid']['type'] != "mobile") && ($icon != "pass") && ($source != "")): ?>
176
							<center>
177
								<a href="diag_ipsec.php?act=connect&amp;remoteid=<?php echo $remoteid; ?>&amp;source=<?php echo $source; ?>">
178
								<img src ="/themes/<?php echo $g['theme']; ?>/images/icons/icon_service_start.gif" alt="Connect VPN" title="Connect VPN" border="0"/>
179
								</a>
180
							</center>
181
							<?php else: ?>
182
								&nbsp;
183
							<?php endif; ?>
184
						</td>
185
					</tr>
186
					<?php
187
							}
188
						}
189
						if ($rowIndex == 0) {
190
					?>
191
					<tr><td></td></tr>
192
					<?php
193
						}
194
					?>
195
					</tbody>
196
				</table>
197
				<?php if (isset($config['ipsec']['client']['enable'])): ?>
198
				<table width="100%" border="0" cellpadding="6" cellspacing="0" class="tabcont sortable">
199
					<thead>
200
					<tr>
201
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Mobile User");?></th>
202
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Login Time");?></th>
203
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Local");?></th>
204
						<th nowrap="nowrap" class="listhdrr"><?php echo gettext("Remote");?></th>
205
						<th nowrap="nowrap" class="list">&nbsp;</th>
206
					</tr>
207
					</thead>
208
					<tbody>
209
					<?php	foreach ($mobile as $muser): ?>
210
					<tr>
211
						<td class="listlr"><?php echo $muser['username']; ?></td>
212
						<td class="listr" align="center"><?php echo $muser['logintime']; ?></td>
213
						<td class="listr" align="center"><?php echo $muser['local']; ?></td>
214
						<td class="listr" align="center"><?php echo $muser['remote']; ?></td>
215
						<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' alt=''/></a></td>
216
					</tr>
217
					<?php	endforeach; ?>
218
					</tbody>
219
				</table>
220
				<?php endif; ?>
221
			</div>
222
		</td>
223
	</tr>
224
</table>
225

    
226
<p/>
227

    
228
<span class="vexpl">
229
	<span class="red">
230
		<strong><?php echo gettext("Note:");?><br /></strong>
231
	</span>
232
	<?php echo gettext("You can configure IPsec");?>
233
	<a href="vpn_ipsec.php">here</a>.
234
</span>
235

    
236
<?php include("fend.inc"); ?>
237
</body>
238
</html>
(13-13/246)