Project

General

Profile

Download (19 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/* $Id$ */
3
/*
4
	system_advanced_misc.php
5
	part of pfSense
6
	Copyright (C) 2005-2007 Scott Ullrich
7
	Copyright (C) 2008 Shrew Soft Inc
8
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
9

    
10
	originally part of m0n0wall (http://m0n0.ch/wall)
11
	Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>.
12
	All rights reserved.
13

    
14
	Redistribution and use in source and binary forms, with or without
15
	modification, are permitted provided that the following conditions are met:
16

    
17
	1. Redistributions of source code must retain the above copyright notice,
18
	   this list of conditions and the following disclaimer.
19

    
20
	2. Redistributions in binary form must reproduce the above copyright
21
	   notice, this list of conditions and the following disclaimer in the
22
	   documentation and/or other materials provided with the distribution.
23

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

    
39
##|+PRIV
40
##|*IDENT=page-system-advanced-misc
41
##|*NAME=System: Advanced: Miscellaneous page
42
##|*DESCR=Allow access to the 'System: Advanced: Miscellaneous' page.
43
##|*MATCH=system_advanced_misc.php*
44
##|-PRIV
45

    
46
require("guiconfig.inc");
47
require_once("functions.inc");
48
require_once("filter.inc");
49
require_once("shaper.inc");
50
require_once("vpn.inc");
51
require_once("vslb.inc");
52

    
53
$pconfig['proxyurl'] = $config['system']['proxyurl'];
54
$pconfig['proxyport'] = $config['system']['proxyport'];
55
$pconfig['proxyuser'] = $config['system']['proxyuser'];
56
$pconfig['proxypass'] = $config['system']['proxypass'];
57
$pconfig['harddiskstandby'] = $config['system']['harddiskstandby'];
58
$pconfig['lb_use_sticky'] = isset($config['system']['lb_use_sticky']);
59
$pconfig['srctrack'] = $config['system']['srctrack'];
60
$pconfig['gw_switch_default'] = isset($config['system']['gw_switch_default']);
61
$pconfig['powerd_enable'] = isset($config['system']['powerd_enable']);
62
$pconfig['crypto_hardware'] = $config['system']['crypto_hardware'];
63
$pconfig['thermal_hardware'] = $config['system']['thermal_hardware'];
64
$pconfig['schedule_states'] = isset($config['system']['schedule_states']);
65
$pconfig['kill_states'] = isset($config['system']['kill_states']);
66
$pconfig['skip_rules_gw_down'] = isset($config['system']['skip_rules_gw_down']);
67
$pconfig['apinger_debug'] = isset($config['system']['apinger_debug']);
68
$pconfig['use_mfs_tmpvar'] = isset($config['system']['use_mfs_tmpvar']);
69
$pconfig['use_mfs_tmp_size'] = $config['system']['use_mfs_tmp_size'];
70
$pconfig['use_mfs_var_size'] = $config['system']['use_mfs_var_size'];
71
$pconfig['pkg_nochecksig'] = isset($config['system']['pkg_nochecksig']);
72

    
73
$pconfig['powerd_ac_mode'] = "hadp";
74
if (!empty($config['system']['powerd_ac_mode']))
75
	$pconfig['powerd_ac_mode'] = $config['system']['powerd_ac_mode'];
76

    
77
$pconfig['powerd_battery_mode'] = "hadp";
78
if (!empty($config['system']['powerd_battery_mode']))
79
	$pconfig['powerd_battery_mode'] = $config['system']['powerd_battery_mode'];
80

    
81
$pconfig['powerd_normal_mode'] = "hadp";
82
if (!empty($config['system']['powerd_normal_mode']))
83
	$pconfig['powerd_normal_mode'] = $config['system']['powerd_normal_mode'];
84

    
85
$crypto_modules = array('glxsb' => gettext("AMD Geode LX Security Block"),
86
			'aesni' => gettext("AES-NI CPU-based Acceleration"));
87

    
88
$thermal_hardware_modules = array(	'coretemp' => gettext("Intel Core* CPU on-die thermal sensor"),
89
					'amdtemp' => gettext("AMD K8, K10 and K11 CPU on-die thermal sensor"));
90

    
91
if ($_POST) {
92

    
93
	unset($input_errors);
94
	$pconfig = $_POST;
95

    
96
	ob_flush();
97
	flush();
98

    
99
	if (!empty($_POST['cryptographic-hardware']) && !array_key_exists($_POST['cryptographic-hardware'], $crypto_modules))
100
		$input_errors[] = gettext("Please select a valid Cryptographic Accelerator.");
101

    
102
	if (!empty($_POST['thermal-sensors']) && !array_key_exists($_POST['thermal-sensors'], $thermal_hardware_modules))
103
		$input_errors[] = gettext("Please select a valid Thermal Hardware Sensor.");
104

    
105
	if (!empty($_POST['-tmp-ram-disk-size']) && (!is_numeric($_POST['-tmp-ram-disk-size']) || ($_POST['-tmp-ram-disk-size'] < 40)))
106
		$input_errors[] = gettext("/tmp Size must be numeric and should not be less than 40MB.");
107

    
108
	if (!empty($_POST['-var-ram-disk-size']) && (!is_numeric($_POST['-var-ram-disk-size']) || ($_POST['-var-ram-disk-size'] < 60)))
109
		$input_errors[] = gettext("/var Size must be numeric and should not be less than 60MB.");
110

    
111
	if (!$input_errors) {
112

    
113
		if($_POST['proxy-url'] != "")
114
			$config['system']['proxyurl'] = $_POST['proxy-url'];
115
		else
116
			unset($config['system']['proxyurl']);
117

    
118
		if($_POST['proxy-port'] != "")
119
			$config['system']['proxyport'] = $_POST['proxy-port'];
120
		else
121
			unset($config['system']['proxyport']);
122

    
123
		if($_POST['proxy-username'] != "")
124
			$config['system']['proxyuser'] = $_POST['proxy-username'];
125
		else
126
			unset($config['system']['proxyuser']);
127

    
128
		if($_POST['proxy-password'] != "")
129
			$config['system']['proxypass'] = $_POST['proxy-password'];
130
		else
131
			unset($config['system']['proxypass']);
132

    
133
		$need_relayd_restart = false;
134
		if($_POST['use-sticky-connections'] == "yes") {
135
			if (!isset($config['system']['lb_use_sticky'])) {
136
				$config['system']['lb_use_sticky'] = true;
137
				$need_relayd_restart = true;
138
			}
139
			if ($config['system']['srctrack'] != $_POST['source-tracking-timeout']) {
140
				$config['system']['srctrack'] = $_POST['source-tracking-timeout'];
141
				$need_relayd_restart = true;
142
			}
143
		} else {
144
			if (isset($config['system']['lb_use_sticky'])) {
145
				unset($config['system']['lb_use_sticky']);
146
				$need_relayd_restart = true;
147
			}
148
		}
149

    
150
		if($_POST['default-gateway-switching'] == "yes")
151
			$config['system']['gw_switch_default'] = true;
152
		else
153
			unset($config['system']['gw_switch_default']);
154

    
155
		if($_POST['package-signature'] == "yes")
156
			$config['system']['pkg_nochecksig'] = true;
157
		elseif (isset($config['system']['pkg_nochecksig']))
158
			unset($config['system']['pkg_nochecksig']);
159

    
160
		if($_POST['powerd'] == "yes")
161
			$config['system']['powerd_enable'] = true;
162
		else
163
			unset($config['system']['powerd_enable']);
164

    
165
		$config['system']['powerd_ac_mode'] = $_POST['ac-power'];
166
		$config['system']['powerd_battery_mode'] = $_POST['battery-power'];
167
		$config['system']['powerd_normal_mode'] = $_POST['unknown-power'];
168

    
169
		if($_POST['cryptographic-hardware'])
170
			$config['system']['crypto_hardware'] = $_POST['cryptographic-hardware'];
171
		else
172
			unset($config['system']['crypto_hardware']);
173

    
174
		if($_POST['thermal-sensors'])
175
			$config['system']['thermal_hardware'] = $_POST['thermal-sensors'];
176
		else
177
			unset($config['system']['thermal_hardware']);
178

    
179
		if($_POST['schedule-states'] == "yes")
180
			$config['system']['schedule_states'] = true;
181
		else
182
			unset($config['system']['schedule_states']);
183

    
184
		if($_POST['state-killing-on-gateway-failure'] == "yes")
185
			$config['system']['kill_states'] = true;
186
		else
187
			unset($config['system']['kill_states']);
188

    
189
		if($_POST['skip-rules-when-gateway-is-down'] == "yes")
190
			$config['system']['skip_rules_gw_down'] = true;
191
		else
192
			unset($config['system']['skip_rules_gw_down']);
193

    
194
		$need_apinger_restart = false;
195
		if($_POST['gateway-monitoring-logging'] == "yes") {
196
			if (!isset($config['system']['apinger_debug']))
197
				$need_apinger_restart = true;
198
			$config['system']['apinger_debug'] = true;
199
		} else {
200
			if (isset($config['system']['apinger_debug']))
201
				$need_apinger_restart = true;
202
			unset($config['system']['apinger_debug']);
203
		}
204

    
205
		if($_POST['use-ram-disks'] == "yes")
206
			$config['system']['use_mfs_tmpvar'] = true;
207
		else
208
			unset($config['system']['use_mfs_tmpvar']);
209

    
210
		$config['system']['use_mfs_tmp_size'] = $_POST['-tmp-ram-disk-size'];
211
		$config['system']['use_mfs_var_size'] = $_POST['-var-ram-disk-size'];
212

    
213
		if (isset($_POST['periodic-rrd-backup'])) {
214
			$config['system']['rrdbackup'] = $_POST['periodic-rrd-backup'];
215
			install_cron_job("/etc/rc.backup_rrd.sh", ($config['system']['rrdbackup'] > 0), $minute="0", "*/{$config['system']['rrdbackup']}");
216
		}
217
		if (isset($_POST['periodic-dhcp-leases-backup'])) {
218
			$config['system']['dhcpbackup'] = $_POST['periodic-dhcp-leases-backup'];
219
			install_cron_job("/etc/rc.backup_dhcpleases.sh", ($config['system']['dhcpbackup'] > 0), $minute="0", "*/{$config['system']['dhcpbackup']}");
220
		}
221

    
222
		write_config();
223

    
224
		$retval = 0;
225
		system_resolvconf_generate(true);
226
		$retval = filter_configure();
227
		if(stristr($retval, "error") <> true)
228
			$savemsg = get_std_save_message(gettext($retval));
229
		else
230
			$savemsg = gettext($retval);
231

    
232
		activate_powerd();
233
		load_crypto();
234
		load_thermal_hardware();
235
		if ($need_relayd_restart)
236
			relayd_configure();
237
		if ($need_apinger_restart)
238
			setup_gateways_monitor();
239
	}
240
}
241

    
242
$pgtitle = array(gettext("System"),gettext("Advanced: Miscellaneous"));
243
include("head.inc");
244

    
245
if ($input_errors)
246
	print_input_errors($input_errors);
247
if ($savemsg)
248
	print_info_box($savemsg);
249

    
250
$tab_array = array();
251
$tab_array[] = array(gettext("Admin Access"), false, "system_advanced_admin.php");
252
$tab_array[] = array(gettext("Firewall / NAT"), false, "system_advanced_firewall.php");
253
$tab_array[] = array(gettext("Networking"), false, "system_advanced_network.php");
254
$tab_array[] = array(gettext("Miscellaneous"), true, "system_advanced_misc.php");
255
$tab_array[] = array(gettext("System Tunables"), false, "system_advanced_sysctl.php");
256
$tab_array[] = array(gettext("Notifications"), false, "system_advanced_notifications.php");
257
display_top_tabs($tab_array);
258

    
259
?><div id="container"><?php
260

    
261
require('classes/Form.class.php');
262
$form = new Form;
263
$section = new Form_Section('Proxy support');
264

    
265
$section->addInput(new Form_Input(
266
	'proxy-url',
267
	'Proxy URL',
268
	'text',
269
	$pconfig['proxyurl']
270
))->setHelp('Hostname or IP address of proxy server this system will '.
271
	'use for its outbound Internet access.');
272

    
273
$section->addInput(new Form_Input(
274
	'proxy-port',
275
	'Proxy Port',
276
	'text',
277
	$pconfig['proxyport']
278
))->setHelp('Port where proxy server is listening.');
279

    
280
$section->addInput(new Form_Input(
281
	'proxy-username',
282
	'Proxy Username',
283
	'text',
284
	$pconfig['proxyuser']
285
))->setHelp('Username for authentication to proxy server. Optional, '.
286
	'leave blank to not use authentication.');
287

    
288
$section->addInput(new Form_Input(
289
	'proxy-password',
290
	'Proxy Password',
291
	'text',
292
	$pconfig['proxypass']
293
))->setHelp('Password for authentication to proxy server.');
294

    
295
$form->add($section);
296
$section = new Form_Section('Load Balancing');
297

    
298
$group = new Form_Group('Load Balancing');
299

    
300
$group->add(new Form_Checkbox(
301
	'use-sticky-connections',
302
	'Use sticky connections',
303
	'Use sticky connections',
304
	$pconfig['lb_use_sticky']
305
))->setHelp('Successive connections will be redirected to the servers in a '.
306
	'round-robin manner with connections from the same source being sent to the '.
307
	'same web server. This "sticky connection" will exist as long as there are '.
308
	'states that refer to this connection. Once the states expire, so will the '.
309
	'sticky connection. Further connections from that host will be redirected '.
310
	'to the next web server in the round robin. Changing this option will '.
311
	'restart the Load Balancing service.');
312

    
313
$group->add(new Form_Input(
314
	'source-tracking-timeout',
315
	'Source tracking timeout',
316
	'number',
317
	$pconfig['srctrack'],
318
	['placeholder' => 1400]
319
))->setHelp('Set the source tracking timeout for sticky connections. By default '.
320
	'this is 0, so source tracking is removed as soon as the state expires. '.
321
	'Setting this timeout higher will cause the source/destination relationship '.
322
	'to persist for longer periods of time.');
323

    
324
$section->add($group);
325

    
326
$section->addInput(new Form_Checkbox(
327
	'default-gateway-switching',
328
	'Default gateway switching',
329
	'Enable default gateway switching',
330
	$pconfig['gw_switch_default']
331
))->setHelp('If the default gateway goes down, switch the default gateway to '.
332
	'another available one. This is not enabled by default, as it"s unnecessary in '.
333
	'most all scenarios, which instead use gateway groups.');
334

    
335
$form->add($section);
336
$section = new Form_Section('Power savings');
337

    
338
$section->addInput(new Form_Checkbox(
339
	'powerd',
340
	'PowerD',
341
	'Enable PowerD',
342
	$pconfig['powerd_enable']
343
))->setHelp('The powerd utility monitors '.
344
	'the system state and sets various power control options accordingly.  It offers '.
345
	'four modes (maximum, minimum, adaptive and hiadaptive) that can be individually '.
346
	'selected while on AC power or batteries. The modes maximum, minimum, adaptive '.
347
	'and hiadaptive may be abbreviated max, min, adp, hadp.  Maximum mode chooses the '.
348
	'highest performance values.  Minimum mode selects the lowest performance values '.
349
	'to get the most power savings. Adaptive mode attempts to strike a balance by '.
350
	'degrading performance when the system appears idle and increasing it when the '.
351
	'system is busy.  It offers a good balance between a small performance loss for '.
352
	'greatly increased power savings.  Hiadaptive mode is alike adaptive mode, but '.
353
	'tuned for systems where performance and interactivity are more important than '.
354
	'power consumption.  It raises frequency faster, drops slower and keeps twice '.
355
	'lower CPU load.');
356

    
357
$modes = array(
358
	'hadp' => 'Hiadaptive',
359
	'adp' => 'Adaptive',
360
	'min' => 'Minimum',
361
	'max' => 'Maximum',
362
);
363

    
364
$section->addInput(new Form_Select(
365
	'ac-power',
366
	'AC Power',
367
	$pconfig['powerd_ac_mode'],
368
	$modes
369
));
370

    
371
$section->addInput(new Form_Select(
372
	'battery-power',
373
	'Battery Power',
374
	$pconfig['powerd_battery_mode'],
375
	$modes
376
));
377

    
378
$section->addInput(new Form_Select(
379
	'unknown-power',
380
	'Unknown Power',
381
	$pconfig['powerd_normal_mode'],
382
	$modes
383
));
384

    
385
$form->add($section);
386
$section = new Form_Section('Cryptographic & Thermal Hardware');
387

    
388
$section->addInput(new Form_Select(
389
	'cryptographic-hardware',
390
	'Cryptographic Hardware',
391
	$pconfig['crypto_hardware'],
392
	$crypto_modules
393
))->setHelp('A cryptographic '.
394
	'accelerator module will use hardware support to speed up some cryptographic '.
395
	'functions on systems which have the chip. Do not enable this option if you have '.
396
	'a Hifn cryptographic acceleration card, as this will take precedence and the '.
397
	'Hifn card will not be used. Acceleration should be automatic for IPsec when '.
398
	'using a cipher supported by your chip, such as AES-128. OpenVPN should be set '.
399
	'for AES-128-CBC and have cryptodev enabled for hardware acceleration.If you do '.
400
	'not have a crypto chip in your system, this option will have no effect. To '.
401
	'unload the selected module, set this option to "none" and then reboot.');
402

    
403
$section->addInput(new Form_Select(
404
	'thermal-sensors',
405
	'Thermal Sensors',
406
	$pconfig['thermal_hardware'],
407
	array('' => 'None/ACPI') + $thermal_hardware_modules
408
))->setHelp('If you have a '.
409
	'supported CPU, selecting a themal sensor will load the appropriate driver to '.
410
	'read its temperature. Setting this to "None" will attempt to read the '.
411
	'temperature from an ACPI-compliant motherboard sensor instead, if one is '.
412
	'present.If you do not have a supported thermal sensor chip in your system, this '.
413
	'option will have no effect. To unload the selected module, set this option to '.
414
	'"none" and then reboot.');
415

    
416
$form->add($section);
417
$section = new Form_Section('Schedules');
418

    
419
$section->addInput(new Form_Checkbox(
420
	'schedule-states',
421
	'Schedule States',
422
	'Do not kill connections when schedule expires',
423
	$pconfig['schedule_states']
424
))->setHelp('By default, when a schedule expires, connections permitted by that '.
425
	'schedule are killed. This option overrides that behavior by not clearing states '.
426
	'for existing connections.');
427

    
428
$form->add($section);
429
$section = new Form_Section('Gateway Monitoring');
430

    
431
$section->addInput(new Form_Checkbox(
432
	'state-killing-on-gateway-failure',
433
	'State Killing on Gateway Failure',
434
	'Flush states for a gateway that goes down',
435
	$pconfig['kill_states']
436
))->setHelp('The monitoring process will flush states for a gateway that goes down '.
437
	'if this box is not checked. Check this box to disable this behavior.');
438

    
439
$section->addInput(new Form_Checkbox(
440
	'skip-rules-when-gateway-is-down',
441
	'Skip rules when gateway is down',
442
	'Do not create rules when gateway is down',
443
	$pconfig['skip_rules_gw_down']
444
))->setHelp('By default, when a rule has a gateway specified and this gateway is '.
445
	'down, the rule is created omitting the gateway. This option overrides that '.
446
	'behavior by omitting the entire rule instead.');
447

    
448
$section->addInput(new Form_Checkbox(
449
	'gateway-monitoring-logging',
450
	'Gateway monitoring logging',
451
	'Enable debug logging',
452
	$pconfig['apinger_debug']
453
))->setHelp('Enable this setting to log debug information from the gateway '.
454
	'monitoring process to the system logs.');
455

    
456
$form->add($section);
457
$section = new Form_Section('RAM Disk Settings (Reboot to Apply Changes)');
458

    
459
$section->addInput(new Form_Checkbox(
460
	'use-ram-disks',
461
	'Use RAM Disks',
462
	'Use memory file system for /tmp and /var',
463
	($pconfig['use_mfs_tmpvar'] || $g['platform'] != "pfSense")
464
))->setHelp('Set this if you wish to use /tmp and /var as RAM disks (memory file '.
465
	'system disks) on a full install rather than use the hard disk. Setting this will '.
466
	'cause the data in /tmp and /var to be lost at reboot, including log data. RRD '.
467
	'and DHCP Leases will be retained.');
468

    
469
$section->addInput(new Form_Input(
470
	'-tmp-ram-disk-size',
471
	'/tmp RAM Disk Size',
472
	'number',
473
	$pconfig['use_mfs_tmp_size'],
474
	['placeholder' => 40]
475
))->setHelp('Set the size, in MB, for the /tmp '.
476
	'RAM disk. Leave blank for 40MB. Do not set lower than 40.');
477

    
478
$section->addInput(new Form_Input(
479
	'-var-ram-disk-size',
480
	'/var RAM Disk Size',
481
	'number',
482
	$pconfig['use_mfs_var_size'],
483
	['placeholder' => 60]
484
))->setHelp('Set the size, in MB, for the /var '.
485
	'RAM disk. Leave blank for 60MB. Do not set lower than 60.');
486

    
487
$section->addInput(new Form_Input(
488
	'periodic-rrd-backup',
489
	'Periodic RRD Backup',
490
	'number',
491
	$config['system']['rrdbackup'],
492
	['min' => 1, 'max' => 24, 'placeholder' => 'frequency between 1 and 24 hours']
493
))->setHelp('This will periodically backup the RRD data so '.
494
	'it can be restored automatically on the next boot. Keep in mind that the more '.
495
	'frequent the backup, the more writes will happen to your media.');
496

    
497
$section->addInput(new Form_Input(
498
	'periodic-dhcp-leases-backup',
499
	'Periodic DHCP Leases Backup',
500
	'number',
501
	$config['system']['rrdbackup'],
502
	['min' => 1, 'max' => 24, 'placeholder' => 'frequency between 1 and 24 hours']
503
))->setHelp('This will periodically backup the DHCP leases so '.
504
	'it can be restored automatically on the next boot. Keep in mind that the more '.
505
	'frequent the backup, the more writes will happen to your media.');
506

    
507
$form->add($section);
508
$section = new Form_Section('Package settings');
509

    
510
$section->addInput(new Form_Checkbox(
511
	'package-signature',
512
	'Package signature',
513
	'Disable check package signature',
514
	$pconfig['pkg_nochecksig']
515
))->setHelp('Enable this option to allow pfSense to install any package without '.
516
	'checking its signature.');
517

    
518
$form->add($section);
519
print $form;
520

    
521
include("foot.inc");
(204-204/252)