1
|
<?php
|
2
|
/* $Id$ */
|
3
|
/*
|
4
|
load_balancer_setting.php
|
5
|
part of pfSense (https://www.pfsense.org/)
|
6
|
|
7
|
Copyright (C) 2008 Bill Marquette <bill.marquette@gmail.com>.
|
8
|
Copyright (C) 2012 Pierre POMES <pierre.pomes@gmail.com>.
|
9
|
Copyright (C) 2013-2015 Electric Sheep Fencing, LP
|
10
|
|
11
|
All rights reserved.
|
12
|
|
13
|
Redistribution and use in source and binary forms, with or without
|
14
|
modification, are permitted provided that the following conditions are met:
|
15
|
|
16
|
1. Redistributions of source code must retain the above copyright notice,
|
17
|
this list of conditions and the following disclaimer.
|
18
|
|
19
|
2. Redistributions in binary form must reproduce the above copyright
|
20
|
notice, this list of conditions and the following disclaimer in the
|
21
|
documentation and/or other materials provided with the distribution.
|
22
|
|
23
|
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
24
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
25
|
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
26
|
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
27
|
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
POSSIBILITY OF SUCH DAMAGE.
|
33
|
*/
|
34
|
/*
|
35
|
pfSense_MODULE: routing
|
36
|
*/
|
37
|
|
38
|
##|+PRIV
|
39
|
##|*IDENT=page-services-loadbalancer-setting
|
40
|
##|*NAME=Services: Load Balancer: setting page
|
41
|
##|*DESCR=Allow access to the 'Settings: Load Balancer: Settings' page.
|
42
|
##|*MATCH=load_balancer_setting.php*
|
43
|
##|-PRIV
|
44
|
|
45
|
require_once("guiconfig.inc");
|
46
|
require_once("functions.inc");
|
47
|
require_once("filter.inc");
|
48
|
require_once("shaper.inc");
|
49
|
require_once("util.inc");
|
50
|
|
51
|
if (!is_array($config['load_balancer']['setting'])) {
|
52
|
$config['load_balancer']['setting'] = array();
|
53
|
}
|
54
|
|
55
|
$lbsetting = &$config['load_balancer']['setting'];
|
56
|
|
57
|
if ($_POST) {
|
58
|
if ($_POST['apply']) {
|
59
|
$retval = 0;
|
60
|
$retval |= filter_configure();
|
61
|
$retval |= relayd_configure();
|
62
|
|
63
|
$savemsg = get_std_save_message($retval);
|
64
|
clear_subsystem_dirty('loadbalancer');
|
65
|
} else {
|
66
|
unset($input_errors);
|
67
|
$pconfig = $_POST;
|
68
|
|
69
|
/* input validation */
|
70
|
if ($_POST['timeout'] && !is_numeric($_POST['timeout'])) {
|
71
|
$input_errors[] = gettext("Timeout must be a numeric value");
|
72
|
}
|
73
|
|
74
|
if ($_POST['interval'] && !is_numeric($_POST['interval'])) {
|
75
|
$input_errors[] = gettext("Interval must be a numeric value");
|
76
|
}
|
77
|
|
78
|
if ($_POST['prefork']) {
|
79
|
if (!is_numeric($_POST['prefork'])) {
|
80
|
$input_errors[] = gettext("Prefork must be a numeric value");
|
81
|
} else {
|
82
|
if (($_POST['prefork']<=0) || ($_POST['prefork']>32)) {
|
83
|
$input_errors[] = gettext("Prefork value must be between 1 and 32");
|
84
|
}
|
85
|
}
|
86
|
}
|
87
|
|
88
|
/* update config if user entry is valid */
|
89
|
if (!$input_errors) {
|
90
|
$lbsetting['timeout'] = $_POST['timeout'];
|
91
|
$lbsetting['interval'] = $_POST['interval'];
|
92
|
$lbsetting['prefork'] = $_POST['prefork'];
|
93
|
|
94
|
write_config();
|
95
|
mark_subsystem_dirty('loadbalancer');
|
96
|
}
|
97
|
}
|
98
|
}
|
99
|
|
100
|
$pgtitle = array(gettext("Services"),gettext("Load Balancer"),gettext("Settings"));
|
101
|
$shortcut_section = "relayd";
|
102
|
|
103
|
include("head.inc");
|
104
|
|
105
|
if ($input_errors)
|
106
|
print_input_errors($input_errors);
|
107
|
|
108
|
if ($savemsg)
|
109
|
print_info_box($savemsg, 'success');
|
110
|
|
111
|
if (is_subsystem_dirty('loadbalancer'))
|
112
|
print_info_box_np(gettext("The load balancer configuration has been changed") . ' ' .
|
113
|
gettext("You must apply the changes in order for them to take effect."), 'Apply', null, false, 'danger');
|
114
|
|
115
|
/* active tabs */
|
116
|
$tab_array = array();
|
117
|
$tab_array[] = array(gettext("Pools"), false, "load_balancer_pool.php");
|
118
|
$tab_array[] = array(gettext("Virtual Servers"), false, "load_balancer_virtual_server.php");
|
119
|
$tab_array[] = array(gettext("Monitors"), false, "load_balancer_monitor.php");
|
120
|
$tab_array[] = array(gettext("Settings"), true, "load_balancer_setting.php");
|
121
|
display_top_tabs($tab_array);
|
122
|
|
123
|
require('classes/Form.class.php');
|
124
|
|
125
|
$form = new Form();
|
126
|
|
127
|
$section = new Form_Section('Relayd Global Settings');
|
128
|
|
129
|
$section->addInput(new Form_Input(
|
130
|
'timeout',
|
131
|
'Timeout',
|
132
|
'text',
|
133
|
$pconfig['timeout']
|
134
|
))->setHelp('Set the global timeout in milliseconds for checks. Leave blank to use the default value of 1000 ms');
|
135
|
|
136
|
$section->addInput(new Form_Input(
|
137
|
'interval',
|
138
|
'Interval',
|
139
|
'text',
|
140
|
$pconfig['interval']
|
141
|
))->setHelp('Set the interval in seconds at which the member of a pool will be checked. Leave blank to use the default interval of 10 seconds');
|
142
|
|
143
|
$section->addInput(new Form_Input(
|
144
|
'prefork',
|
145
|
'Prefork',
|
146
|
'text',
|
147
|
$pconfig['prefork']
|
148
|
))->setHelp('Number of processes used by relayd for dns protocol. Leave blank to use the default value of 5 processes');
|
149
|
|
150
|
$form->add($section);
|
151
|
print($form);
|
152
|
|
153
|
include("foot.inc");
|