Project

General

Profile

Download (8.79 KB) Statistics
| Branch: | Tag: | Revision:
1 5b237745 Scott Ullrich
<?php
2
/*
3
	vpn_ipsec.php
4 e2411886 Scott Ullrich
	part of m0n0wall (http://m0n0.ch/wall)
5 574a2b47 Scott Ullrich
6 e2411886 Scott Ullrich
	Copyright (C) 2003-2005 Manuel Kasper <mk@neon1.net>.
7 cfc707f7 Scott Ullrich
	All rights reserved.
8 574a2b47 Scott Ullrich
9 5b237745 Scott Ullrich
	Redistribution and use in source and binary forms, with or without
10
	modification, are permitted provided that the following conditions are met:
11 574a2b47 Scott Ullrich
12 5b237745 Scott Ullrich
	1. Redistributions of source code must retain the above copyright notice,
13
	   this list of conditions and the following disclaimer.
14 574a2b47 Scott Ullrich
15 5b237745 Scott Ullrich
	2. Redistributions in binary form must reproduce the above copyright
16
	   notice, this list of conditions and the following disclaimer in the
17
	   documentation and/or other materials provided with the distribution.
18 574a2b47 Scott Ullrich
19 5b237745 Scott Ullrich
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
20
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
21
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
23
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
	POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
require("guiconfig.inc");
32
33
if (!is_array($config['ipsec']['tunnel'])) {
34
	$config['ipsec']['tunnel'] = array();
35
}
36
$a_ipsec = &$config['ipsec']['tunnel'];
37 e2411886 Scott Ullrich
$wancfg = &$config['interfaces']['wan'];
38 5b237745 Scott Ullrich
39
$pconfig['enable'] = isset($config['ipsec']['enable']);
40 91f1378c Scott Ullrich
$pconfig['ipcomp'] = isset($config['ipsec']['ipcomp']);
41 5b237745 Scott Ullrich
42
if ($_POST) {
43
44
	if ($_POST['apply']) {
45
		$retval = 0;
46 3851094f Scott Ullrich
		$retval = vpn_ipsec_configure();
47 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
48
		if ($retval == 0) {
49
			if (file_exists($d_ipsecconfdirty_path))
50
				unlink($d_ipsecconfdirty_path);
51
		}
52
	} else if ($_POST['submit']) {
53
		$pconfig = $_POST;
54 574a2b47 Scott Ullrich
55 5b237745 Scott Ullrich
		$config['ipsec']['enable'] = $_POST['enable'] ? true : false;
56 91f1378c Scott Ullrich
		$config['ipsec']['ipcomp'] = $_POST['ipcomp'] ? true : false;
57
		
58 5b237745 Scott Ullrich
		write_config();
59 574a2b47 Scott Ullrich
60 5b237745 Scott Ullrich
		$retval = 0;
61 3851094f Scott Ullrich
		config_lock();
62 24e53389 Scott Ullrich
		$retval = vpn_ipsec_configure();
63 3851094f Scott Ullrich
		config_unlock();
64
		/* reload the filter in the background */
65 574a2b47 Scott Ullrich
		filter_configure();
66 3851094f Scott Ullrich
67 5b237745 Scott Ullrich
		$savemsg = get_std_save_message($retval);
68
		if ($retval == 0) {
69
			if (file_exists($d_ipsecconfdirty_path))
70
				unlink($d_ipsecconfdirty_path);
71
		}
72
	}
73
}
74
75
if ($_GET['act'] == "del") {
76
	if ($a_ipsec[$_GET['id']]) {
77
		unset($a_ipsec[$_GET['id']]);
78 3fdb04a6 Scott Ullrich
		filter_configure();
79 5b237745 Scott Ullrich
		write_config();
80
		header("Location: vpn_ipsec.php");
81
		exit;
82
	}
83
}
84 4df96eff Scott Ullrich
85 d88c6a9f Scott Ullrich
$pgtitle = array("VPN","IPsec");
86 4df96eff Scott Ullrich
include("head.inc");
87
88 5b237745 Scott Ullrich
?>
89 4df96eff Scott Ullrich
90 422f27c0 Scott Ullrich
91
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
92 5b237745 Scott Ullrich
<?php include("fbegin.inc"); ?>
93
<form action="vpn_ipsec.php" method="post">
94
<?php if ($savemsg) print_info_box($savemsg); ?>
95
<?php if (file_exists($d_ipsecconfdirty_path)): ?><p>
96 b8a4d945 Scott Ullrich
<?php if ($pconfig['enable'])
97
			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>
98 5b237745 Scott Ullrich
<?php endif; ?>
99
<table width="100%" border="0" cellpadding="0" cellspacing="0">
100 e2411886 Scott Ullrich
  <tr><td class="tabnavtbl">
101 323d040b Scott Ullrich
<?php
102
	$tab_array = array();
103
	$tab_array[0] = array("Tunnels", true, "vpn_ipsec.php");
104
	$tab_array[1] = array("Mobile clients", false, "vpn_ipsec_mobile.php");
105
	$tab_array[2] = array("Pre-shared keys", false, "vpn_ipsec_keys.php");
106
	$tab_array[3] = array("CAs", false, "vpn_ipsec_ca.php");
107
	display_top_tabs($tab_array);
108 574a2b47 Scott Ullrich
?>
109 5b237745 Scott Ullrich
  </td></tr>
110 574a2b47 Scott Ullrich
  <tr>
111 0f10aee4 Bill Marquette
    <td>
112
	<div id="mainarea">
113
        <table class="tabcont" width="100%" border="0" cellpadding="6" cellspacing="0">
114 574a2b47 Scott Ullrich
                <tr>
115 e2411886 Scott Ullrich
                  <td class="vtable">
116
                      <input name="enable" type="checkbox" id="enable" value="yes" <?php if ($pconfig['enable']) echo "checked";?>>
117
                      <strong>Enable IPsec</strong></td>
118
                </tr>
119 574a2b47 Scott Ullrich
                <tr>
120
                  <td> <input name="submit" type="submit" class="formbtn" value="Save">
121 5b237745 Scott Ullrich
                  </td>
122
                </tr>
123 0f10aee4 Bill Marquette
        </table>
124
        <table class="tabcont" width="100%" border="0" cellpadding="0" cellspacing="0">
125 5b237745 Scott Ullrich
                <tr>
126
                  <td nowrap class="listhdrr">Local net<br>
127
                    Remote net</td>
128
                  <td class="listhdrr">Interface<br>Remote gw</td>
129
                  <td class="listhdrr">P1 mode</td>
130
                  <td class="listhdrr">P1 Enc. Algo</td>
131
                  <td class="listhdrr">P1 Hash Algo</td>
132
                  <td class="listhdr">Description</td>
133 d415d821 Seth Mos
                  <td class="list" >
134
			<table border="0" cellspacing="0" cellpadding="1">
135
			     <tr>
136
				<td width="17" heigth="17"></td>
137
				<td><a href="vpn_ipsec_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add tunnel" width="17" height="17" border="0"></a></td>
138
			     </tr>
139
			</table>
140 127bd0ce Seth Mos
		  </td>
141 d415d821 Seth Mos
		</tr>
142 5b237745 Scott Ullrich
                <?php $i = 0; foreach ($a_ipsec as $ipsecent):
143
					if (isset($ipsecent['disabled'])) {
144
						$spans = "<span class=\"gray\">";
145
						$spane = "</span>";
146
					} else {
147
						$spans = $spane = "";
148
					}
149
				?>
150
                <tr valign="top">
151 574a2b47 Scott Ullrich
                  <td nowrap class="listlr" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?>
152 5b237745 Scott Ullrich
                    <?php	if ($ipsecent['local-subnet']['network'])
153
								echo strtoupper($ipsecent['local-subnet']['network']);
154
							else
155
								echo $ipsecent['local-subnet']['address'];
156
					?>
157
                    <br>
158
                    <?=$ipsecent['remote-subnet'];?>
159
                  <?=$spane;?></td>
160 c62799be Scott Ullrich
                  <td class="listr" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?>
161 5b237745 Scott Ullrich
				  <?php if ($ipsecent['interface']) {
162
							$iflabels = array('lan' => 'LAN', 'wan' => 'WAN');
163 87e72a58 Scott Ullrich
                 	        $carpips = find_number_of_needed_carp_interfaces();
164 210b0258 Scott Ullrich
                         	    for($j=0; $j<$carpips; $j++) {
165
                       				$carpip = find_interface_ip("carp" . $j);
166 b7aa32c0 Scott Ullrich
                      	 			$iflabels['carp' . $j] = "CARP{$j} ({$carpip})"; 
167 87e72a58 Scott Ullrich
                     		    }
168
							for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++)
169 5b237745 Scott Ullrich
								$iflabels['opt' . $j] = $config['interfaces']['opt' . $j]['descr'];
170 87e72a58 Scott Ullrich
							$if = htmlspecialchars($iflabels[$ipsecent['interface']]);
171 5b237745 Scott Ullrich
						} else
172
							$if = "WAN";
173 574a2b47 Scott Ullrich
174 5b237745 Scott Ullrich
						echo $if . "<br>" . $ipsecent['remote-gateway'];
175
					?>
176
                  <?=$spane;?></td>
177 c62799be Scott Ullrich
                  <td class="listr" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?>
178 5b237745 Scott Ullrich
				    <?=$ipsecent['p1']['mode'];?>
179
                  <?=$spane;?></td>
180 c62799be Scott Ullrich
                  <td class="listr" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?>
181 5b237745 Scott Ullrich
				    <?=$p1_ealgos[$ipsecent['p1']['encryption-algorithm']];?>
182
                  <?=$spane;?></td>
183 c62799be Scott Ullrich
                  <td class="listr" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?>
184 5b237745 Scott Ullrich
				    <?=$p1_halgos[$ipsecent['p1']['hash-algorithm']];?>
185
                  <?=$spane;?></td>
186 c62799be Scott Ullrich
                  <td class="listbg" ondblclick="document.location='vpn_ipsec_edit.php?id=<?=$i;?>'"><?=$spans;?><font color="#FFFFFF">
187 e2411886 Scott Ullrich
                    <?=htmlspecialchars($ipsecent['descr']);?>&nbsp;
188 5b237745 Scott Ullrich
                  <?=$spane;?></td>
189 d415d821 Seth Mos
                  <td valign="middle" nowrap class="list">
190
			<table border="0" cellspacing="0" cellpadding="1">
191
			     <tr>
192
				<td><a href="vpn_ipsec_edit.php?id=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" title="edit tunnel" width="17" height="17" border="0"></a></td>
193
                    		<td><a href="vpn_ipsec.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this tunnel?')"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" title="delete tunnel" width="17" height="17" border="0"></a></td>
194
			     </tr>
195
			     <tr>
196
				<td></td>
197
				<td><a href="vpn_ipsec_edit.php?dup=<?=$i;?>"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add a new rule based on this one" width="17" height="17" border="0"></a></td>
198
			     </tr>
199
			</table>
200
		  </td>
201
		</tr>
202 e2411886 Scott Ullrich
			  <?php $i++; endforeach; ?>
203 574a2b47 Scott Ullrich
                <tr>
204 5b237745 Scott Ullrich
                  <td class="list" colspan="6"></td>
205 d415d821 Seth Mos
		  <td class="list">
206
			<table border="0" cellspacing="0" cellpadding="1">
207
			     <tr>
208
				<td width="17"></td>
209
				<td><a href="vpn_ipsec_edit.php"><img src="./themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" title="add tunnel" width="17" height="17" border="0"></a></td>
210
			     </tr>
211
			</table>
212
		  <td>
213
                </tr>
214 518887aa Seth Mos
		<tr>
215 d415d821 Seth Mos
		    <td colspan="4">
216 c55a8ab9 Holger Bauer
		      <p><span class="vexpl"><span class="red"><strong>Note:<br>
217 69e108df Chris Buechler
                      </strong></span>You can check your IPsec status at <a href="diag_ipsec_sad.php">Status:IPsec</a>.</span></p>
218 c55a8ab9 Holger Bauer
		  </td>
219 1256bba5 Seth Mos
		</tr>
220 5b237745 Scott Ullrich
              </table>
221 0f10aee4 Bill Marquette
	      </div>
222
  	  </td>
223 5b237745 Scott Ullrich
	</tr>
224
</table>
225
</form>
226
<?php include("fend.inc"); ?>
227 323d040b Scott Ullrich
</body>
228
</html>