Project

General

Profile

Download (10.7 KB) Statistics
| Branch: | Tag: | Revision:

univnautes / usr / local / www / vpn_ipsec_settings.php @ a1b66bec

1
<?php
2
/*
3
	vpn_ipsec_settings.php
4

    
5
	Copyright (C) 2014 Electric Sheep Fencing, LLC
6
	All rights reserved.
7

    
8
	Redistribution and use in source and binary forms, with or without
9
	modification, are permitted provided that the following conditions are met:
10

    
11
	1. Redistributions of source code must retain the above copyright notice,
12
	   this list of conditions and the following disclaimer.
13

    
14
	2. Redistributions in binary form must reproduce the above copyright
15
	   notice, this list of conditions and the following disclaimer in the
16
	   documentation and/or other materials provided with the distribution.
17

    
18
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
	POSSIBILITY OF SUCH DAMAGE.
28
*/
29

    
30
##|+PRIV
31
##|*IDENT=page-vpn-ipsec-settings
32
##|*NAME=VPN: IPsec: Settings page
33
##|*DESCR=Allow access to the 'VPN: IPsec: Settings' page.
34
##|*MATCH=vpn_ipsec_settings.php*
35
##|-PRIV
36

    
37
require("functions.inc");
38
require("guiconfig.inc");
39
require_once("filter.inc");
40
require_once("shaper.inc");
41
require_once("ipsec.inc");
42
require_once("vpn.inc");
43

    
44
$pconfig['noinstalllanspd'] = $config['system']['noinstalllanspd'];
45
$pconfig['preferoldsa_enable'] = isset($config['ipsec']['preferoldsa']);
46
foreach ($ipsec_loglevels as $lkey => $ldescr) {
47
	if (!empty($config['ipsec']["ipsec_{$lkey}"]))
48
		$pconfig["ipsec_{$lkey}"] = $config['ipsec']["ipsec_{$lkey}"];
49
}
50
$pconfig['failoverforcereload'] = isset($config['ipsec']['failoverforcereload']);
51
$pconfig['acceptunencryptedmainmode'] = isset($config['ipsec']['acceptunencryptedmainmode']);
52
$pconfig['maxmss_enable'] = isset($config['system']['maxmss_enable']);
53
$pconfig['maxmss'] = $config['system']['maxmss'];
54

    
55
if ($_POST) {
56

    
57
	unset($input_errors);
58
	$pconfig = $_POST;
59

    
60
	if (!$input_errors) {
61

    
62
		if($_POST['noinstalllanspd'] == "yes") {
63
			if (!isset($pconfig['noinstalllanspd']))
64
			$config['system']['noinstalllanspd'] = true;
65
		} else {
66
			if (isset($config['system']['noinstalllanspd']))
67
			unset($config['system']['noinstalllanspd']);
68
		}
69

    
70
		if($_POST['preferoldsa_enable'] == "yes")
71
			$config['ipsec']['preferoldsa'] = true;
72
		elseif (isset($config['ipsec']['preferoldsa']))
73
			unset($config['ipsec']['preferoldsa']);
74

    
75
		if (is_array($config['ipsec'])) {
76
			foreach ($ipsec_loglevels as $lkey => $ldescr) {
77
				if (empty($_POST["ipsec_{$lkey}"])) {
78
					if (isset($config['ipsec']["ipsec_{$lkey}"]))
79
						unset($config['ipsec']["ipsec_{$lkey}"]);
80
				} else
81
					$config['ipsec']["ipsec_{$lkey}"] = $_POST["ipsec_{$lkey}"];
82
			}
83
		}
84

    
85
		if($_POST['failoverforcereload'] == "yes")
86
			$config['ipsec']['failoverforcereload'] = true;
87
		elseif (isset($config['ipsec']['failoverforcereload']))
88
			unset($config['ipsec']['failoverforcereload']);
89

    
90
		if($_POST['acceptunencryptedmainmode'] == "yes")
91
			$config['ipsec']['acceptunencryptedmainmode'] = true;
92
		elseif (isset($config['ipsec']['acceptunencryptedmainmode']))
93
			unset($config['ipsec']['acceptunencryptedmainmode']);
94

    
95
		if($_POST['maxmss_enable'] == "yes") {
96
			$config['system']['maxmss_enable'] = true;
97
			$config['system']['maxmss'] = $_POST['maxmss'];
98
		} else {
99
			unset($config['system']['maxmss_enable']);
100
			unset($config['system']['maxmss']);
101
		}
102

    
103
		write_config();
104

    
105
		$retval = 0;
106
		$retval = filter_configure();
107
		if(stristr($retval, "error") <> true)
108
			$savemsg = get_std_save_message(gettext($retval));
109
		else
110
			$savemsg = gettext($retval);
111

    
112
		vpn_ipsec_configure_preferoldsa();
113
		vpn_ipsec_configure();
114
		vpn_ipsec_configure_loglevels();
115

    
116
//		header("Location: vpn_ipsec_settings.php");
117
//		return;
118
	}
119
}
120

    
121
$pgtitle = array(gettext("VPN"),gettext("IPsec"),gettext("Settings"));
122
$shortcut_section = "ipsec";
123

    
124
include("head.inc");
125
?>
126

    
127
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
128
<?php include("fbegin.inc"); ?>
129

    
130
<script type="text/javascript">
131
//<![CDATA[
132

    
133
function maxmss_checked(obj) {
134
	if (obj.checked)
135
		jQuery('#maxmss').attr('disabled',false);
136
	else
137
		jQuery('#maxmss').attr('disabled','true');
138
}
139

    
140
//]]>
141
</script>
142

    
143
<form action="vpn_ipsec_settings.php" method="post" name="iform" id="iform">
144

    
145
<?php
146
	if ($savemsg)
147
		print_info_box($savemsg);
148
	if ($input_errors)
149
		print_input_errors($input_errors);
150
?>
151

    
152
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="vpn ipsec settings">
153
	<tr>
154
		<td class="tabnavtbl">
155
			<?php
156
				$tab_array = array();
157
				$tab_array[0] = array(gettext("Tunnels"), false, "vpn_ipsec.php");
158
				$tab_array[1] = array(gettext("Mobile clients"), false, "vpn_ipsec_mobile.php");
159
				$tab_array[2] = array(gettext("Pre-Shared Key"), false, "vpn_ipsec_keys.php");
160
				$tab_array[3] = array(gettext("Advanced Settings"), true, "vpn_ipsec_settings.php");
161
				display_top_tabs($tab_array);
162
			?>
163
		</td>
164
	</tr>
165
	<tr>
166
		<td id="mainarea">
167
			<div class="tabcont">
168
				<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
169
					<tr>
170
						<td colspan="2" valign="top" class="listtopic"><?=gettext("IPsec Advanced Settings"); ?></td>
171
					</tr>
172
					<tr>
173
						<td width="22%" valign="top" class="vncell"><?=gettext("LAN security associations"); ?></td>
174
						<td width="78%" class="vtable">
175
							<input name="noinstalllanspd" type="checkbox" id="noinstalllanspd" value="yes" <?php if ($pconfig['noinstalllanspd']) echo "checked=\"checked\""; ?> />
176
							<strong><?=gettext("Do not install LAN SPD"); ?></strong>
177
							<br />
178
							<?=gettext("By default, if IPsec is enabled negating SPD are inserted to provide protection. " .
179
							"This behaviour can be changed by enabling this setting which will prevent installing these SPDs."); ?>
180
						</td>
181
					</tr>
182
					<tr>
183
						<td width="22%" valign="top" class="vncell"><?=gettext("Security Associations"); ?></td>
184
						<td width="78%" class="vtable">
185
							<input name="preferoldsa_enable" type="checkbox" id="preferoldsa_enable" value="yes" <?php if ($pconfig['preferoldsa_enable']) echo "checked=\"checked\""; ?> />
186
							<strong><?=gettext("Prefer older IPsec SAs"); ?></strong>
187
							<br />
188
							<?=gettext("By default, if several SAs match, the newest one is " .
189
							"preferred if it's at least 30 seconds old. Select this " .
190
							"option to always prefer old SAs over new ones."); ?>
191
						</td>
192
					</tr>
193
					<tr>
194
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Debug"); ?></td>
195
						<td width="78%" class="vtable">
196
							<strong><?=gettext("Start IPsec in debug mode based on sections selected"); ?></strong>
197
							<br />
198
							<table summary="ipsec debug">
199
						<?php foreach ($ipsec_loglevels as $lkey => $ldescr): ?>
200
							<tr>
201
								<td width="22%" valign="top" class="vncell"><?=$ldescr;?></td>
202
								<td width="78%" valign="top" class="vncell">
203
								<?php	echo "<select name=\"ipsec_{$lkey}\" id=\"ipsec_{$lkey}\">\n";
204
									foreach (array("Silent", "Audit", "Control", "Diag", "Raw", "Highest") as $lidx => $lvalue) {
205
										echo "<option value=\"{$lidx}\" ";
206
										 if ($pconfig["ipsec_{$lkey}"] == $lidx)
207
											echo "selected=\"selected\"";
208
										echo ">{$lvalue}</option>\n";
209
									}
210
								?>
211
									</select>
212
								</td>
213
							</tr>
214
						<?php endforeach; ?>
215
							<tr style="display:none;"><td></td></tr>
216
							</table>
217
							<br /><?=gettext("Launches IPsec in debug mode so that more verbose logs " .
218
							"will be generated to aid in troubleshooting."); ?>
219
						</td>
220
					</tr>
221
					<tr>
222
						<td width="22%" valign="top" class="vncell"><?=gettext("IPsec Reload on Failover"); ?></td>
223
						<td width="78%" class="vtable">
224
							<input name="failoverforcereload" type="checkbox" id="failoverforcereload" value="yes" <?php if ($pconfig['failoverforcereload']) echo "checked=\"checked\""; ?> />
225
							<strong><?=gettext("Force IPsec Reload on Failover"); ?></strong>
226
							<br />
227
							<?=gettext("In some circumstances using a gateway group as the interface for " .
228
							"an IPsec tunnel does not function properly, and IPsec must be forcefully reloaded " .
229
							"when a failover occurs. Because this will disrupt all IPsec tunnels, this behavior" .
230
							" is disabled by default. Check this box to force IPsec to fully reload on failover."); ?>
231
						</td>
232
					</tr>
233
					<tr>
234
						<td width="22%" valign="top" class="vncell"><?=gettext("Unencrypted payloads in IKEv1 Main Mode"); ?></td>
235
						<td width="78%" class="vtable">
236
							<input name="acceptunencryptedmainmode" type="checkbox" id="acceptunencryptedmainmode" value="yes" <?php if ($pconfig['acceptunencryptedmainmode']) echo "checked=\"checked\""; ?> />
237
							<strong><?=gettext("Accept unencrypted ID and HASH payloads in IKEv1 Main Mode"); ?></strong>
238
							<br />
239
							<?=gettext("Some implementations send the third Main Mode message unencrypted, probably to find the PSKs for the specified ID for authentication." .
240
							"This is very similar to Aggressive Mode, and has the same security implications: " .
241
							"A passive attacker can sniff the negotiated Identity, and start brute forcing the PSK using the HASH payload." .
242
							" It is recommended to keep this option to no, unless you know exactly what the implications are and require compatibility to such devices (for example, some SonicWall boxes).");?>
243
						</td>
244
					</tr>
245
					<tr>
246
						<td width="22%" valign="top" class="vncell"><?=gettext("Maximum MSS"); ?></td>
247
						<td width="78%" class="vtable">
248
							<input name="maxmss_enable" type="checkbox" id="maxmss_enable" value="yes" <?php if ($pconfig['maxmss_enable'] == true) echo "checked=\"checked\""; ?> onclick="maxmss_checked(this)" />
249
							<strong><?=gettext("Enable MSS clamping on VPN traffic"); ?></strong>
250
							<br />
251
							<input name="maxmss" id="maxmss" value="<?php if ($pconfig['maxmss'] <> "") echo $pconfig['maxmss']; else "1400"; ?>" class="formfld unknown" <?php if ($pconfig['maxmss_enable'] == false) echo "disabled=\"disabled\""; ?> />
252
							<br />
253
							<?=gettext("Enable MSS clamping on TCP flows over VPN. " .
254
							"This helps overcome problems with PMTUD on IPsec VPN links. If left blank, the default value is 1400 bytes. "); ?>
255
						</td>
256
					</tr>
257
					<tr>
258
						<td width="22%" valign="top">&nbsp;</td>
259
						<td width="78%">
260
							<input name="submit" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" />
261
						</td>
262
					</tr>
263
				</table>
264
			</div>
265
		</td>
266
	</tr>
267
</table>
268
</form>
269
<?php include("fend.inc"); ?>
270
</body>
271
</html>
(243-243/256)