1 |
5b237745
|
Scott Ullrich
|
#!/usr/local/bin/php
|
2 |
|
|
<?php
|
3 |
|
|
/*
|
4 |
|
|
vpn_ipsec.php
|
5 |
cfc707f7
|
Scott Ullrich
|
Copyright (C) 2004 Scott Ullrich
|
6 |
|
|
All rights reserved.
|
7 |
f0fe3d30
|
Scott Ullrich
|
|
8 |
cfc707f7
|
Scott Ullrich
|
originally part of m0n0wall (http://m0n0.ch/wall)
|
9 |
5b237745
|
Scott Ullrich
|
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
|
10 |
|
|
All rights reserved.
|
11 |
3da9a135
|
Scott Ullrich
|
|
12 |
5b237745
|
Scott Ullrich
|
Redistribution and use in source and binary forms, with or without
|
13 |
|
|
modification, are permitted provided that the following conditions are met:
|
14 |
f0fe3d30
|
Scott Ullrich
|
|
15 |
5b237745
|
Scott Ullrich
|
1. Redistributions of source code must retain the above copyright notice,
|
16 |
|
|
this list of conditions and the following disclaimer.
|
17 |
f0fe3d30
|
Scott Ullrich
|
|
18 |
5b237745
|
Scott Ullrich
|
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 |
f0fe3d30
|
Scott Ullrich
|
|
22 |
5b237745
|
Scott Ullrich
|
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 |
|
|
require("guiconfig.inc");
|
35 |
|
|
|
36 |
|
|
if (!is_array($config['ipsec']['tunnel'])) {
|
37 |
|
|
$config['ipsec']['tunnel'] = array();
|
38 |
|
|
}
|
39 |
|
|
$a_ipsec = &$config['ipsec']['tunnel'];
|
40 |
|
|
$wancfg = &$config['interfaces']['wan'];
|
41 |
|
|
|
42 |
|
|
$pconfig['enable'] = isset($config['ipsec']['enable']);
|
43 |
dacc4f59
|
Scott Ullrich
|
$pconfig['preferredoldsa'] = isset($config['ipsec']['preferredoldsa']);
|
44 |
3da9a135
|
Scott Ullrich
|
$pconfig['ipcomp'] = isset($config['ipsec']['ipcomp']);
|
45 |
5b237745
|
Scott Ullrich
|
|
46 |
|
|
if ($_POST) {
|
47 |
|
|
|
48 |
|
|
if ($_POST['apply']) {
|
49 |
|
|
$retval = 0;
|
50 |
|
|
if (!file_exists($d_sysrebootreqd_path))
|
51 |
|
|
$retval = vpn_ipsec_configure();
|
52 |
|
|
$savemsg = get_std_save_message($retval);
|
53 |
|
|
if ($retval == 0) {
|
54 |
|
|
if (file_exists($d_ipsecconfdirty_path))
|
55 |
|
|
unlink($d_ipsecconfdirty_path);
|
56 |
|
|
}
|
57 |
|
|
} else if ($_POST['submit']) {
|
58 |
|
|
$pconfig = $_POST;
|
59 |
f0fe3d30
|
Scott Ullrich
|
|
60 |
5b237745
|
Scott Ullrich
|
$config['ipsec']['enable'] = $_POST['enable'] ? true : false;
|
61 |
dacc4f59
|
Scott Ullrich
|
$config['ipsec']['preferredoldsa'] = $_POST['preferredoldsa'] ? true : false;
|
62 |
3da9a135
|
Scott Ullrich
|
$config['ipsec']['ipcomp'] = $_POST['ipcomp'] ? true : false;
|
63 |
f0fe3d30
|
Scott Ullrich
|
|
64 |
5b237745
|
Scott Ullrich
|
write_config();
|
65 |
f0fe3d30
|
Scott Ullrich
|
|
66 |
5b237745
|
Scott Ullrich
|
$retval = 0;
|
67 |
|
|
if (!file_exists($d_sysrebootreqd_path)) {
|
68 |
|
|
config_lock();
|
69 |
|
|
$retval = vpn_ipsec_configure();
|
70 |
|
|
config_unlock();
|
71 |
|
|
}
|
72 |
|
|
$savemsg = get_std_save_message($retval);
|
73 |
|
|
if ($retval == 0) {
|
74 |
|
|
if (file_exists($d_ipsecconfdirty_path))
|
75 |
|
|
unlink($d_ipsecconfdirty_path);
|
76 |
|
|
}
|
77 |
|
|
}
|
78 |
|
|
}
|
79 |
|
|
|
80 |
|
|
if ($_GET['act'] == "del") {
|
81 |
|
|
if ($a_ipsec[$_GET['id']]) {
|
82 |
|
|
unset($a_ipsec[$_GET['id']]);
|
83 |
|
|
write_config();
|
84 |
|
|
touch($d_ipsecconfdirty_path);
|
85 |
|
|
header("Location: vpn_ipsec.php");
|
86 |
|
|
exit;
|
87 |
|
|
}
|
88 |
|
|
}
|
89 |
|
|
?>
|
90 |
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
91 |
|
|
<html>
|
92 |
|
|
<head>
|
93 |
|
|
<title><?=gentitle("VPN: IPsec");?></title>
|
94 |
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
95 |
|
|
<link href="gui.css" rel="stylesheet" type="text/css">
|
96 |
|
|
</head>
|
97 |
|
|
|
98 |
|
|
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
|
99 |
|
|
<?php include("fbegin.inc"); ?>
|
100 |
|
|
<p class="pgtitle">VPN: IPsec</p>
|
101 |
|
|
<form action="vpn_ipsec.php" method="post">
|
102 |
|
|
<?php if ($savemsg) print_info_box($savemsg); ?>
|
103 |
|
|
<?php if (file_exists($d_ipsecconfdirty_path)): ?><p>
|
104 |
|
|
<?php print_info_box_np("The IPsec tunnel configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
|
105 |
|
|
<input name="apply" type="submit" class="formbtn" id="apply" value="Apply changes"></p>
|
106 |
|
|
<?php endif; ?>
|
107 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
108 |
|
|
<tr><td>
|
109 |
|
|
<ul id="tabnav">
|
110 |
|
|
<li class="tabact">Tunnels</li>
|
111 |
|
|
<li class="tabinact"><a href="vpn_ipsec_mobile.php">Mobile clients</a></li>
|
112 |
|
|
<li class="tabinact"><a href="vpn_ipsec_keys.php">Pre-shared keys</a></li>
|
113 |
|
|
</ul>
|
114 |
|
|
</td></tr>
|
115 |
f0fe3d30
|
Scott Ullrich
|
<tr>
|
116 |
5b237745
|
Scott Ullrich
|
<td class="tabcont">
|
117 |
bafc1e3f
|
Scott Ullrich
|
<table width="100%" border="0" cellpadding="6" cellspacing="0">
|
118 |
f0fe3d30
|
Scott Ullrich
|
<tr>
|
119 |
|
|
<td class="vtable"><p><span class="vexpl"> </span>
|
120 |
5b237745
|
Scott Ullrich
|
<input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable'] == "yes") echo "checked";?>>
|
121 |
|
|
<strong>Enable IPsec<br>
|
122 |
dacc4f59
|
Scott Ullrich
|
</strong></p>
|
123 |
|
|
</td>
|
124 |
|
|
<td class="vtable"><p><span class="vexpl"> </span>
|
125 |
|
|
<input name="preferredoldsa" type="checkbox" id="preferredoldsa" value="yes" <?php if ($pconfig['preferredoldsa'] == "yes") echo "checked";?>>
|
126 |
|
|
<strong>Prefer newer SA's.<br>
|
127 |
|
|
</strong></p>
|
128 |
|
|
</td>
|
129 |
3da9a135
|
Scott Ullrich
|
<td class="vtable"><p><span class="vexpl"> </span>
|
130 |
|
|
<input name="ipcomp" type="checkbox" id="ipcomp" value="yes" <?php if ($pconfig['ipcomp'] == "yes") echo "checked";?>>
|
131 |
|
|
<strong>Enable VPN IP Compression<br>
|
132 |
|
|
</strong></p>
|
133 |
|
|
</td>
|
134 |
5b237745
|
Scott Ullrich
|
</tr>
|
135 |
f0fe3d30
|
Scott Ullrich
|
<tr>
|
136 |
|
|
<td> <input name="submit" type="submit" class="formbtn" value="Save">
|
137 |
5b237745
|
Scott Ullrich
|
</td>
|
138 |
|
|
</tr>
|
139 |
|
|
</table>
|
140 |
|
|
<br>
|
141 |
|
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
142 |
|
|
<tr>
|
143 |
|
|
<td nowrap class="listhdrr">Local net<br>
|
144 |
|
|
Remote net</td>
|
145 |
|
|
<td class="listhdrr">Interface<br>Remote gw</td>
|
146 |
|
|
<td class="listhdrr">P1 mode</td>
|
147 |
|
|
<td class="listhdrr">P1 Enc. Algo</td>
|
148 |
|
|
<td class="listhdrr">P1 Hash Algo</td>
|
149 |
|
|
<td class="listhdr">Description</td>
|
150 |
|
|
<td class="list"></td>
|
151 |
|
|
</tr>
|
152 |
|
|
<?php $i = 0; foreach ($a_ipsec as $ipsecent):
|
153 |
|
|
if (isset($ipsecent['disabled'])) {
|
154 |
|
|
$spans = "<span class=\"gray\">";
|
155 |
|
|
$spane = "</span>";
|
156 |
|
|
} else {
|
157 |
|
|
$spans = $spane = "";
|
158 |
|
|
}
|
159 |
|
|
?>
|
160 |
|
|
<tr valign="top">
|
161 |
f0fe3d30
|
Scott Ullrich
|
<td nowrap class="listlr"><?=$spans;?>
|
162 |
5b237745
|
Scott Ullrich
|
<?php if ($ipsecent['local-subnet']['network'])
|
163 |
|
|
echo strtoupper($ipsecent['local-subnet']['network']);
|
164 |
|
|
else
|
165 |
|
|
echo $ipsecent['local-subnet']['address'];
|
166 |
|
|
?>
|
167 |
|
|
<br>
|
168 |
|
|
<?=$ipsecent['remote-subnet'];?>
|
169 |
|
|
<?=$spane;?></td>
|
170 |
|
|
<td class="listr"><?=$spans;?>
|
171 |
|
|
<?php if ($ipsecent['interface']) {
|
172 |
|
|
$iflabels = array('lan' => 'LAN', 'wan' => 'WAN');
|
173 |
|
|
for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
|
174 |
|
|
$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
|
175 |
|
|
$if = htmlspecialchars($iflabels[$ipsecent['interface']]);
|
176 |
|
|
} else
|
177 |
|
|
$if = "WAN";
|
178 |
f0fe3d30
|
Scott Ullrich
|
|
179 |
5b237745
|
Scott Ullrich
|
echo $if . "<br>" . $ipsecent['remote-gateway'];
|
180 |
|
|
?>
|
181 |
|
|
<?=$spane;?></td>
|
182 |
|
|
<td class="listr"><?=$spans;?>
|
183 |
|
|
<?=$ipsecent['p1']['mode'];?>
|
184 |
|
|
<?=$spane;?></td>
|
185 |
|
|
<td class="listr"><?=$spans;?>
|
186 |
|
|
<?=$p1_ealgos[$ipsecent['p1']['encryption-algorithm']];?>
|
187 |
|
|
<?=$spane;?></td>
|
188 |
|
|
<td class="listr"><?=$spans;?>
|
189 |
|
|
<?=$p1_halgos[$ipsecent['p1']['hash-algorithm']];?>
|
190 |
|
|
<?=$spane;?></td>
|
191 |
|
|
<td class="listbg"><?=$spans;?>
|
192 |
f0fe3d30
|
Scott Ullrich
|
<font color="#FFFFFF"><?=htmlspecialchars($ipsecent['descr']);?>
|
193 |
5b237745
|
Scott Ullrich
|
<?=$spane;?></td>
|
194 |
f0fe3d30
|
Scott Ullrich
|
<td valign="middle" nowrap class="list"> <a href="vpn_ipsec_edit.php?id=<?=$i;?>"><img src="e.gif" width="17" height="17" border="0"></a>
|
195 |
5b237745
|
Scott Ullrich
|
<a href="vpn_ipsec.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this tunnel?')"><img src="x.gif" width="17" height="17" border="0"></a></td>
|
196 |
|
|
</tr>
|
197 |
|
|
<?php $i++; endforeach; ?>
|
198 |
f0fe3d30
|
Scott Ullrich
|
<tr>
|
199 |
5b237745
|
Scott Ullrich
|
<td class="list" colspan="6"></td>
|
200 |
|
|
<td class="list"> <a href="vpn_ipsec_edit.php"><img src="plus.gif" width="17" height="17" border="0"></a></td>
|
201 |
|
|
</tr>
|
202 |
|
|
</table>
|
203 |
|
|
</td>
|
204 |
|
|
</tr>
|
205 |
|
|
</table>
|
206 |
|
|
</form>
|
207 |
|
|
<?php include("fend.inc"); ?>
|
208 |
|
|
</body>
|
209 |
|
|
</html>
|