Project

General

Profile

Download (20.6 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['rfc959workaround'] = $config['system']['rfc959workaround'];
39
$pconfig['filteringbridge_enable'] = isset($config['bridge']['filteringbridge']);
40
$pconfig['ipv6nat_enable'] = isset($config['diag']['ipv6nat']['enable']);
41
$pconfig['ipv6nat_ipaddr'] = $config['diag']['ipv6nat']['ipaddr'];
42
$pconfig['cert'] = base64_decode($config['system']['webgui']['certificate']);
43
$pconfig['key'] = base64_decode($config['system']['webgui']['private-key']);
44
$pconfig['disableconsolemenu'] = isset($config['system']['disableconsolemenu']);
45
$pconfig['disablefirmwarecheck'] = isset($config['system']['disablefirmwarecheck']);
46
$pconfig['expanddiags'] = isset($config['system']['webgui']['expanddiags']);
47
if ($g['platform'] == "generic-pc")
48
	$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
49
$pconfig['noantilockout'] = isset($config['system']['webgui']['noantilockout']);
50
$pconfig['tcpidletimeout'] = $config['filter']['tcpidletimeout'];
51

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

    
55
if ($_POST) {
56

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

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

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

    
105
		$config['system']['optimization'] = $_POST['optimization'];
106

    
107
		if ($g['platform'] == "generic-pc") {
108
			$oldharddiskstandby = $config['system']['harddiskstandby'];
109
			$config['system']['harddiskstandby'] = $_POST['harddiskstandby'];
110
		}
111
		$config['system']['webgui']['noantilockout'] = $_POST['noantilockout'] ? true : false;
112

    
113
		/* Firewall and ALTQ options */
114
		$config['system']['schedulertype'] = $_POST['schedulertype'];
115
		$config['system']['maximumstates'] = $_POST['maximumstates'];
116

    
117
		write_config();
118

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

    
133
		$retval = 0;
134
		if (!file_exists($d_sysrebootreqd_path)) {
135
			config_lock();
136
			$retval = filter_configure();
137
			if(stristr($retval, "error") <> true)
138
			    $savemsg = get_std_save_message($retval);
139
			else
140
			    $savemsg = $retval;
141
			$retval |= interfaces_optional_configure();
142
			config_unlock();
143
		}
144
	}
145
}
146
?>
147
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
148
<html>
149
<head>
150
<title><?=gentitle("System: Advanced functions");?></title>
151
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
152
<link href="gui.css" rel="stylesheet" type="text/css">
153
<script language="JavaScript">
154
<!--
155
function enable_change(enable_over) {
156
	if (document.iform.ipv6nat_enable.checked || enable_over) {
157
		document.iform.ipv6nat_ipaddr.disabled = 0;
158
		document.iform.schedulertype.disabled = 0;
159
	} else {
160
		document.iform.ipv6nat_ipaddr.disabled = 1;
161
	}
162
}
163
// -->
164
</script>
165
</head>
166

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

    
177
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
178

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

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

    
354
		<tr>
355
                  <td width="22%" valign="top" class="vncell">Firewall Optimization Options</td>
356
                  <td width="78%" class="vtable">
357
		    <select name="optimization" id="optimization">
358
			<option value="normal"<?php if($config['system']['optimization']=="normal") echo " SELECTED"; ?>>normal - as the name says, it's the normal optimization algorithm.</option>
359
			<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>
360
			<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>
361
			<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>
362
		    </select>
363
		    <br> <span class="vexpl"><b>Select which type of state table optimization your would like to use</b></td>
364
                </tr>
365
                <tr>
366
                  <td width="22%" valign="top" class="vncell">Disable Firewall</td>
367
                  <td width="78%" class="vtable">
368
                    <input name="disablefilter" type="checkbox" id="disablefilter" value="yes" <?php if (isset($config['system']['disablefilter'])) echo "checked"; ?> onclick="enable_change(false)">
369
                    <strong>Disable the firewalls filter altogether.</strong><br>
370
                    <span class="vexpl">NOTE!  This basically converts pfSense into a routing only platform!</span></td>
371
                </tr>
372

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

    
381
                <tr>
382
                  <td width="22%" valign="top">&nbsp;</td>
383
                  <td width="78%">
384
                    <input name="Submit" type="submit" class="formbtn" value="Save" onclick="enable_change(true)">
385
                  </td>
386
                </tr>
387
                <tr>
388
                  <td colspan="2" class="list" height="12"></td>
389
                </tr>
390

    
391

    
392

    
393

    
394

    
395

    
396
              </table>
397
</form>
398
            <script language="JavaScript">
399
<!--
400
enable_change(false);
401
//-->
402
</script>
403
<?php include("fend.inc"); ?>
404
</body>
405
</html>
(84-84/101)