Project

General

Profile

Download (19.8 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	system_advanced.php
5
        part of pfSense
6
        Copyright (C) 2005 Scott Ullrich
7

    
8
	originally part of m0n0wall (http://m0n0.ch/wall)
9
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
10
	All rights reserved.
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
require("guiconfig.inc");
35

    
36
$pconfig['disablefilter'] = $config['system']['disablefilter'];
37
$pconfig['disableftpproxy'] = $config['system']['disableftpproxy'];
38
$pconfig['filteringbridge_enable'] = isset($config['bridge']['filteringbridge']);
39
$pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']);
40
$pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr'];
41
$pconfig['cert'] = base64_decode($config['system']['webgui']['certificate']);
42
$pconfig['key'] = base64_decode($config['system']['webgui']['private-key']);
43
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
44
$pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']);
45
$pconfig['expanddiags'] = isset($config['system']['webgui']['expanddiags']);
46
if ($g['platform'] == "generic-pc")
47
	$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
48
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
49
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
50

    
51
$pconfig['schedulertype'] = $config['system']['schedulertype'];
52
$pconfig['maximumstates'] = $config['system']['maximumstates'];
53

    
54
if ($_POST) {
55

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

    
59
	/* input validation */
60
	if ($_POST['ipv6nat_enable'] && !is_ipaddr($_POST['ipv6nat_ipaddr'])) {
61
		$input_errors[] = "You must specify an IP address to NAT IPv6 packets.";
62
	}
63
	if ($_POST['maximumstates'] && !is_numericint($_POST['maximumstates'])) {
64
		$input_errors[] = "The Firewall Maximum States value must be an integer.";
65
	}
66
	if ($_POST['tcpidletimeout'] && !is_numericint($_POST['tcpidletimeout'])) {
67
		$input_errors[] = "The TCP idle timeout must be an integer.";
68
	}
69
	if (($_POST['cert'] && !$_POST['key']) || ($_POST['key'] && !$_POST['cert'])) {
70
		$input_errors[] = "Certificate and key must always be specified together.";
71
	} else if ($_POST['cert'] && $_POST['key']) {
72
		if (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE"))
73
			$input_errors[] = "This certificate does not appear to be valid.";
74
		if (!strstr($_POST['key'], "BEGIN RSA PRIVATE KEY") || !strstr($_POST['key'], "END RSA PRIVATE KEY"))
75
			$input_errors[] = "This key does not appear to be valid.";
76
	}
77

    
78
	if (!$input_errors) {
79
		if($_POST['disablefilter'] == "yes") {
80
			$config['system']['disablefilter'] = "enabled";
81
		} else {
82
			unset($config['system']['disablefilter']);
83
		}
84
		if($_POST['disableftpproxy'] == "yes") {
85
			$config['system']['disableftpproxy'] = "enabled";
86
		} else {
87
			unset($config['system']['disableftpproxy']);
88
		}
89
		$config['bridge']['filteringbridge'] = $_POST['filteringbridge_enable'] ? true : false;
90
		$config['diag']['ipv6nat']['enable'] = $_POST['ipv6nat_enable'] ? true : false;
91
		$config['diag']['ipv6nat']['ipaddr'] = $_POST['ipv6nat_ipaddr'];
92
		$oldcert = $config['system']['webgui']['certificate'];
93
		$oldkey = $config['system']['webgui']['private-key'];
94
		$config['system']['webgui']['certificate'] = base64_encode($_POST['cert']);
95
		$config['system']['webgui']['private-key'] = base64_encode($_POST['key']);
96
		$config['system']['disableconsolemenu'] = $_POST['disableconsolemenu'] ? true : false;
97
		$config['system']['disablefirmwarecheck'] = $_POST['disablefirmwarecheck'] ? true : false;
98
		$config['system']['webgui']['expanddiags'] = $_POST['expanddiags'] ? true : false;
99

    
100
		$config['system']['optimization'] = $_POST['optimization'];
101

    
102
		if ($g['platform'] == "generic-pc") {
103
			$oldharddiskstandby = $config['system']['harddiskstandby'];
104
			$config['system']['harddiskstandby'] = $_POST['harddiskstandby'];
105
		}
106
		$config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false;
107

    
108
		/* Firewall and ALTQ options */
109
		$config['system']['schedulertype'] = $_POST['schedulertype'];
110
		$config['system']['maximumstates'] = $_POST['maximumstates'];
111

    
112
		write_config();
113

    
114
		if (($config['system']['webgui']['certificate'] != $oldcert)
115
				|| ($config['system']['webgui']['private-key'] != $oldkey)) {
116
			touch($d_sysrebootreqd_path);
117
		} else if (($g['platform'] == "generic-pc") && ($config['system']['harddiskstandby'] != $oldharddiskstandby)) {
118
			if (!$config['system']['harddiskstandby']) {
119
				// Reboot needed to deactivate standby due to a stupid ATA-protocol
120
				touch($d_sysrebootreqd_path);
121
				unset($config['system']['harddiskstandby']);
122
			} else {
123
				// No need to set the standby-time if a reboot is needed anyway
124
				system_set_harddisk_standby();
125
			}
126
		}
127

    
128
		$retval = 0;
129
		if (!file_exists($d_sysrebootreqd_path)) {
130
			config_lock();
131
			$retval = filter_configure();
132
			$retval |= interfaces_optional_configure();
133
			config_unlock();
134
		}
135
		$savemsg = get_std_save_message($retval);
136

    
137
		/* Setup pf rules since the user may have changed the optimization value */
138
		config_lock();
139
		$retval = filter_configure();
140
		config_unlock();
141

    
142
	}
143
}
144
?>
145
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
146
<html>
147
<head>
148
<title><?=gentitle("System: Advanced functions");?></title>
149
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
150
<link href="gui.css" rel="stylesheet" type="text/css">
151
<script language="JavaScript">
152
<!--
153
function enable_change(enable_over) {
154
	if (document.iform.ipv6nat_enable.checked || enable_over) {
155
		document.iform.ipv6nat_ipaddr.disabled = 0;
156
		document.iform.schedulertype.disabled = 0;
157
	} else {
158
		document.iform.ipv6nat_ipaddr.disabled = 1;
159
	}
160
}
161
// -->
162
</script>
163
</head>
164

    
165
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
166
<form action="system_advanced.php" method="post" name="iform" id="iform">
167
<?php include("fbegin.inc"); ?>
168
      <p class="pgtitle">System: Advanced functions</p>
169
            <?php if ($input_errors) print_input_errors($input_errors); ?>
170
            <?php if ($savemsg) print_info_box($savemsg); ?>
171
            <p><span class="vexpl"><span class="red"><strong>Note: </strong></span>the
172
              options on this page are intended for use by advanced users only,
173
              and there's <strong>NO</strong> support for them.</span></p><br>
174

    
175
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
176

    
177
                <tr>
178
                  <td colspan="2" valign="top" class="listtopic">IPv6 tunneling</td>
179
                </tr>
180
                <tr>
181
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
182
                  <td width="78%" class="vtable">
183
                    <input name="ipv6nat_enable" type="checkbox" id="ipv6nat_enable" value="yes" <?php if ($pconfig['ipv6nat_enable']) echo "checked"; ?> onclick="enable_change(false)">
184
                    <strong>NAT encapsulated IPv6 packets (IP protocol 41/RFC2893)
185
                    to:</strong><br> <br> <input name="ipv6nat_ipaddr" type="text" class="formfld" id="ipv6nat_ipaddr" size="20" value="<?=htmlspecialchars($pconfig['ipv6nat_ipaddr']);?>">
186
                    &nbsp;(IP address)<span class="vexpl"><br>
187
                    Don't forget to add a firewall rule to permit IPv6 packets!</span></td>
188
                </tr>
189
                <tr>
190
                  <td width="22%" valign="top">&nbsp;</td>
191
                  <td width="78%">
192
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
193
                  </td>
194
                </tr>
195
                <tr>
196
                  <td colspan="2" class="list" height="12"></td>
197
                </tr>
198
		<tr>
199
                  <td colspan="2" valign="top" class="listtopic">Filtering bridge</td>
200
                </tr>
201
                <tr>
202
                  <td width="22%" valign="top" class="vncell">&nbsp;</td>
203
                  <td width="78%" class="vtable">
204
                    <input name="filteringbridge_enable" type="checkbox" id="filteringbridge_enable" value="yes" <?php if ($pconfig['filteringbridge_enable']) echo "checked"; ?>>
205
                    <strong>Enable filtering bridge</strong><span class="vexpl"><br>
206
                    This will cause bridged packets to pass through the packet
207
                    filter in the same way as routed packets do (by default bridged
208
                    packets are always passed). If you enable this option, you'll
209
                    have to add filter rules to selectively permit traffic from
210
                    bridged interfaces.</span></td>
211
                </tr>
212
                <tr>
213
                  <td width="22%" valign="top">&nbsp;</td>
214
                  <td width="78%">
215
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
216
                  </td>
217
                </tr>
218
                <tr>
219
                  <td colspan="2" class="list" height="12"></td>
220
                </tr>
221
                <tr>
222
                  <td colspan="2" valign="top" class="listtopic">webGUI SSL certificate/key</td>
223
                </tr>
224
                <tr>
225
                  <td width="22%" valign="top" class="vncell">Certificate</td>
226
                  <td width="78%" class="vtable">
227
                    <textarea name="cert" cols="65" rows="7" id="cert" class="formpre"><?=htmlspecialchars($pconfig['cert']);?></textarea>
228
                    <br>
229
                    Paste a signed certificate in X.509 PEM format here. <A target="_new" HREF='system_advanced_create_certs.php'>Create</a> certificates automatically.</td>
230
                </tr>
231
                <tr>
232
                  <td width="22%" valign="top" class="vncell">Key</td>
233
                  <td width="78%" class="vtable">
234
                    <textarea name="key" cols="65" rows="7" id="key" class="formpre"><?=htmlspecialchars($pconfig['key']);?></textarea>
235
                    <br>
236
                    Paste an RSA private key in PEM format here.</td>
237
                </tr>
238
                <tr>
239
                  <td width="22%" valign="top">&nbsp;</td>
240
                  <td width="78%">
241
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
242
                  </td>
243
                </tr>
244
                <tr>
245
                  <td colspan="2" class="list" height="12"></td>
246
                </tr>
247
                <tr>
248
                  <td colspan="2" valign="top" class="listtopic">Miscellaneous</td>
249
                </tr>
250
				<tr>
251
                  <td width="22%" valign="top" class="vncell">Console menu </td>
252
                  <td width="78%" class="vtable">
253
                    <input name="disableconsolemenu" type="checkbox" id="disableconsolemenu" value="yes" <?php if ($pconfig['disableconsolemenu']) echo "checked"; ?>>
254
                    <strong>Disable console menu</strong><span class="vexpl"><br>
255
                    Changes to this option will take effect after a reboot.</span></td>
256
                </tr>
257
				<tr>
258
                  <td valign="top" class="vncell">Firmware version check </td>
259
                  <td class="vtable">
260
                    <input name="disablefirmwarecheck" type="checkbox" id="disablefirmwarecheck" value="yes" <?php if ($pconfig['disablefirmwarecheck']) echo "checked"; ?>>
261
                    <strong>Disable firmware version check</strong><span class="vexpl"><br>
262
    This will cause pfSense not to check for newer firmware versions when the <a href="system_firmware.php">System: Firmware</a> page is viewed.</span></td>
263
			    </tr>
264
				<tr>
265
                  <td width="22%" valign="top" class="vncell">Hard disk standby time </td>
266
                  <td width="78%" class="vtable">
267
                    <select name="harddiskstandby" class="formfld">
268
					<?php
269
                        /* Values from ATA-2
270
                           http://www.t13.org/project/d0948r3-ATA-2.pdf
271
                           Page 66 */
272
						$sbvals = explode(" ", "0.5,6 1,12 2,24 3,36 4,48 5,60 7.5,90 10,120 15,180 20,240 30,241 60,242");
273
					?>
274
                      <option value="" <?php if(!$pconfig['harddiskstandby']) echo('selected');?>>Always on</option>
275
					<?php
276
					foreach ($sbvals as $sbval):
277
						list($min,$val) = explode(",", $sbval); ?>
278
                      <option value="<?=$val;?>" <?php if($pconfig['harddiskstandby'] == $val) echo('selected');?>><?=$min;?> minutes</option>
279
					<?php endforeach; ?>
280
                    </select>
281
                    <br>
282
                    Puts the hard disk into standby mode when the selected amount of time after the last
283
                    access has elapsed. <em>Do not set this for CF cards.</em></td>
284
				</tr>
285
				<tr>
286
                  <td width="22%" valign="top" class="vncell">Navigation</td>
287
                  <td width="78%" class="vtable">
288
                    <input name="expanddiags" type="checkbox" id="expanddiags" value="yes" <?php if ($pconfig['expanddiags']) echo "checked"; ?>>
289
                    <strong>Keep diagnostics in navigation expanded </strong></td>
290
                </tr>
291
		<tr>
292
                  <td width="22%" valign="top" class="vncell">webGUI anti-lockout</td>
293
                  <td width="78%" class="vtable">
294
                    <input name="noantilockout" type="checkbox" id="noantilockout" value="yes" <?php if ($pconfig['noantilockout']) echo "checked"; ?>>
295
                    <strong>Disable webGUI anti-lockout rule</strong><br>
296
					By default, access to the webGUI on the LAN interface is always permitted, regardless of the user-defined filter rule set. Enable this feature to control webGUI access (make sure to have a filter rule in place that allows you in, or you will lock yourself out!).<br>
297
					Hint:
298
					the &quot;set LAN IP address&quot; option in the console menu  resets this setting as well.</td>
299
                </tr>
300
                <tr>
301
                  <td width="22%" valign="top">&nbsp;</td>
302
                  <td width="78%">
303
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
304
                  </td>
305
                </tr>
306
                <tr>
307
                  <td colspan="2" class="list" height="12"></td>
308
                </tr>
309
                <tr>
310
                  <td colspan="2" valign="top" class="listtopic">Traffic Shaper and Firewall Advanced</td>
311
                </tr>
312
                <tr>
313
                  <td width="22%" valign="top" class="vncell">FTP Helper</td>
314
                  <td width="78%" class="vtable">
315
                    <input name="disableftpproxy" type="checkbox" id="disableftpproxy" value="yes" <?php if (isset($config['system']['disableftpproxy'])) echo "checked"; ?> onclick="enable_change(false)">
316
                    <strong class="vexpl">Disable the userland FTP-Proxy application</strong><br>
317
                </tr>
318

    
319
		<tr>
320
		  <td width="22%" valign="top" class="vncell"><b>Traffic Shaper Scheduler</b> </td>
321
		  <td width="78%" class="vtable">
322
		    <select id="schedulertype" name="schedulertype" <?= $style ?>>
323
		    <?php
324
			    if($pconfig['schedulertype'] == 'priq')
325
				    echo "<option value=\"priq\">Priority based queueing</option>";
326
			    if($pconfig['schedulertype'] == 'cbq')
327
				    echo "<option value=\"cbq\">Class based queueing</option>";
328
			    if($pconfig['schedulertype'] == 'hfsc')
329
				    echo "<option value=\"hfsc\">Hierarchical Fair Service Curve queueing</option>";
330
		    ?>
331
			    <option value="priq">Priority based queueing</option>
332
			    <option value="cbq">Class based queueing</option>
333
			    <option value="hfsc">Hierarchical Fair Service Curve queueing</option>
334
		    </select>
335
		    <br> <span class="vexpl">Select which type of queueing you would like to use
336
		  <?php if (is_array($config['shaper']['queue']) > 0): ?>
337
			<script language="javascript">
338
			document.iform.schedulertype.disabled = 1;
339
			</script>
340
			<br>
341
			NOTE: This option is disabled since there are queues defined.
342
		  <?php endif; ?>
343
		    </span></td>
344
		</tr>
345

    
346
		<tr>
347
                  <td width="22%" valign="top" class="vncell">Firewall Optimization Options</td>
348
                  <td width="78%" class="vtable">
349
		    <select name="optimization" id="optimization">
350
			<option value="normal"<?php if($config['system']['optimization']=="normal") echo " SELECTED"; ?>>normal - as the name says, it's the normal optimization algorithm.</option>
351
			<option value="high-latency"<?php if($config['system']['optimization']=="high-latency") echo " SELECTED"; ?>>high-latency - used for high latency links, such as satellite links.  Expires idle connections later than default.</option>
352
			<option value="aggressive"<?php if($config['system']['optimization']=="aggressive") echo " SELECTED"; ?>>aggressive - expires idle connections earlier than default; using less memory and CPU time while possibly dropping some legitimate connections.</option>
353
			<option value="conservative"<?php if($config['system']['optimization']=="conservative") echo " SELECTED"; ?>>conservative - tries to avoid dropping any legitimate connections at the expense of increased memory usage and CPU utilization.</option>
354
		    </select>
355
                    <strong>Disable webGUI anti-lockout rule</strong><br>
356
					the &quot;set LAN IP address&quot; option in the console menu  resets this setting as well.</td>
357
                </tr>
358
                <tr>
359
                  <td width="22%" valign="top" class="vncell">Disable Firewall</td>
360
                  <td width="78%" class="vtable">
361
                    <input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> onclick="enable_change(false)">
362
                    <strong>Disable the firewalls filter altogether.</strong><br>
363
                    <span class="vexpl">NOTE!  This basically converts pfSense into a routing only platform!</span></td>
364
                </tr>
365

    
366
                <tr>
367
                  <td width="22%" valign="top" class="vncell">Firewall Maximum States</td>
368
                  <td width="78%" class="vtable">
369
                    <input name="maximumstates" type="input" id="maximumstates" value="<?php echo $pconfig['maximumstates']; ?>" onclick="enable_change(false)"><br>
370
                    <strong>Maximum number of connections to hold in the firewall state table.</strong><br>
371
                    <span class="vexpl">NOTE!  Leave this blank for the default of 10000</span></td>
372
                </tr>
373

    
374
                <tr>
375
                  <td width="22%" valign="top">&nbsp;</td>
376
                  <td width="78%">
377
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
378
                  </td>
379
                </tr>
380
                <tr>
381
                  <td colspan="2" class="list" height="12"></td>
382
                </tr>
383

    
384

    
385

    
386

    
387

    
388

    
389
              </table>
390
</form>
391
            <script language="JavaScript">
392
<!--
393
enable_change(false);
394
//-->
395
</script>
396
<?php include("fend.inc"); ?>
397
</body>
398
</html>
(83-83/100)