Project

General

Profile

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

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

    
172
              <table width="100%" border="0" cellpadding="6" cellspacing="0">
173

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

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

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

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

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

    
380

    
381

    
382

    
383

    
384

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