Project

General

Profile

Download (11.1 KB) Statistics
| Branch: | Tag: | Revision:
1 f97a5b04 Darren Embry
<?php
2
/*
3
	system_hasync.php
4
*/
5 b9043cdc Stephen Beaver
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7 cb41dd63 Renato Botelho
 *	Copyright (c)  2012 Darren Embry <dse@webonastick.com>.
8 b9043cdc Stephen Beaver
 *
9
 *	Redistribution and use in source and binary forms, with or without modification,
10
 *	are permitted provided that the following conditions are met:
11
 *
12
 *	1. Redistributions of source code must retain the above copyright notice,
13
 *		this list of conditions and the following disclaimer.
14
 *
15
 *	2. Redistributions in binary form must reproduce the above copyright
16
 *		notice, this list of conditions and the following disclaimer in
17
 *		the documentation and/or other materials provided with the
18
 *		distribution.
19
 *
20
 *	3. All advertising materials mentioning features or use of this software
21
 *		must display the following acknowledgment:
22
 *		"This product includes software developed by the pfSense Project
23
 *		 for use in the pfSense software distribution. (http://www.pfsense.org/).
24
 *
25
 *	4. The names "pfSense" and "pfSense Project" must not be used to
26
 *		 endorse or promote products derived from this software without
27
 *		 prior written permission. For written permission, please contact
28
 *		 coreteam@pfsense.org.
29
 *
30
 *	5. Products derived from this software may not be called "pfSense"
31
 *		nor may "pfSense" appear in their names without prior written
32
 *		permission of the Electric Sheep Fencing, LLC.
33
 *
34
 *	6. Redistributions of any form whatsoever must retain the following
35
 *		acknowledgment:
36
 *
37
 *	"This product includes software developed by the pfSense Project
38
 *	for use in the pfSense software distribution (http://www.pfsense.org/).
39
 *
40
 *	THIS SOFTWARE IS PROVIDED BY THE pfSense PROJECT ``AS IS'' AND ANY
41
 *	EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
42
 *	IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
43
 *	PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE pfSense PROJECT OR
44
 *	ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
45
 *	SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46
 *	NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
47
 *	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48
 *	HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
49
 *	STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
50
 *	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
51
 *	OF THE POSSIBILITY OF SUCH DAMAGE.
52
 *
53
 *	====================================================================
54
 *
55
 */
56 f97a5b04 Darren Embry
57
##|+PRIV
58
##|*IDENT=page-system-hasync
59
##|*NAME=System: High Availability Sync
60
##|*DESCR=Allow access to the 'System: High Availability Sync' page.
61
##|*MATCH=system_hasync.php*
62
##|-PRIV
63
64
require("guiconfig.inc");
65
66 d61309a0 Phil Davis
if (!is_array($config['hasync'])) {
67 f97a5b04 Darren Embry
	$config['hasync'] = array();
68 d61309a0 Phil Davis
}
69 f97a5b04 Darren Embry
70
$a_hasync = &$config['hasync'];
71
72 d38bd840 Phil Davis
$checkbox_names = array(
73
	'pfsyncenabled',
74
	'synchronizeusers',
75
	'synchronizeauthservers',
76
	'synchronizecerts',
77
	'synchronizerules',
78
	'synchronizeschedules',
79
	'synchronizealiases',
80
	'synchronizenat',
81
	'synchronizeipsec',
82
	'synchronizeopenvpn',
83
	'synchronizedhcpd',
84
	'synchronizewol',
85
	'synchronizestaticroutes',
86
	'synchronizelb',
87
	'synchronizevirtualip',
88
	'synchronizetrafficshaper',
89
	'synchronizetrafficshaperlimiter',
90
	'synchronizednsforwarder',
91
	'synchronizecaptiveportal');
92 f97a5b04 Darren Embry
93
if ($_POST) {
94
	$pconfig = $_POST;
95
	foreach ($checkbox_names as $name) {
96
		$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
97
	}
98 76d6d925 Stephen Beaver
	$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
99 f97a5b04 Darren Embry
	$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
100
	$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
101 76d6d925 Stephen Beaver
	$a_hasync['username'] = $pconfig['username'];
102 c8b10b4c Stephen Beaver
103
	if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
104 76d6d925 Stephen Beaver
		if ($pconfig['passwordfld'] != DMYPWD) {
105
				$a_hasync['password'] = $pconfig['passwordfld'];
106
		}
107 c8b10b4c Stephen Beaver
	} else {
108
		$input_errors[] = gettext("Password and confirmation must match.");
109
	}
110
111 0eb688c5 Chris Buechler
	if ($pconfig['pfsyncpeerip'] != "") {
112
		if (!is_ipaddrv4($pconfig['pfsyncpeerip'])) {
113
			$input_errors[] = gettext("pfsync Synchronize Peer IP must be an IPv4 IP.");
114
		}
115
	}
116
117 c8b10b4c Stephen Beaver
	if (!$input_errors) {
118
		write_config("Updated High Availability Sync configuration");
119
		interfaces_sync_setup();
120
		header("Location: system_hasync.php");
121
		exit();
122
	}
123 f97a5b04 Darren Embry
}
124
125
foreach ($checkbox_names as $name) {
126
	$pconfig[$name] = $a_hasync[$name];
127
}
128 cb7b3761 sbeaver
$pconfig['pfsyncpeerip']	= $a_hasync['pfsyncpeerip'];
129 f97a5b04 Darren Embry
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
130
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
131 cb7b3761 sbeaver
$pconfig['username']		= $a_hasync['username'];
132
$pconfig['passwordfld']	 = $a_hasync['password'];
133 f97a5b04 Darren Embry
134
$ifaces = get_configured_interface_with_descr();
135
$ifaces["lo0"] = "loopback";
136
137 d38bd840 Phil Davis
$pgtitle = array(gettext("System"), gettext("High Availability Sync"));
138 345ce722 jim-p
$shortcut_section = "carp";
139 cb7b3761 sbeaver
140
// Build a list of available interfaces
141
$iflist = array();
142
foreach ($ifaces as $ifname => $iface) {
143
	$iflist[$ifname] = $iface;
144
}
145
146 f97a5b04 Darren Embry
include("head.inc");
147 cb7b3761 sbeaver
148 c8b10b4c Stephen Beaver
if ($input_errors) {
149
	print_input_errors($input_errors);
150
}
151
152 38e06c66 Sjon Hortensius
$form = new Form;
153 cb7b3761 sbeaver
154
$section = new Form_Section('State Synchronization Settings (pfsync)');
155
156
$section->addInput(new Form_Checkbox(
157
	'pfsyncenabled',
158
	'Synchronize states',
159
	'pfsync transfers state insertion, update, and deletion messages between firewalls.',
160
	($pconfig['pfsyncenabled'] === 'on'),
161
	'on'
162
))->setHelp('Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240).' .
163
			' It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.<br />' .
164
			'This setting should be enabled on all members of a failover group.<br />' .
165
			'Clicking "Save" will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)');
166
167
$section->addInput(new Form_Select(
168
	'pfsyncinterface',
169 11482216 Luiz Otavio O Souza
	'Synchronize Interface',
170 cb7b3761 sbeaver
	$pconfig['pfsyncinterface'],
171
	$iflist
172
))->setHelp('If Synchronize States is enabled this interface will be used for communication.<br />' .
173 e14a94af doktornotor
			'We recommend setting this to an interface other than LAN! A dedicated interface works the best.<br />' .
174
			'You must define an IP on each machine participating in this failover group.<br />' .
175 cb7b3761 sbeaver
			'You must have an IP assigned to the interface on any participating sync nodes.');
176
177
$section->addInput(new Form_Input(
178
	'pfsyncpeerip',
179
	'pfsync Synchronize Peer IP',
180
	'text',
181
	$pconfig['pfsyncpeerip'],
182
	['placeholder' => 'IP Address']
183 e14a94af doktornotor
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
184 cb7b3761 sbeaver
185
$form->add($section);
186
187
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
188
189
$section->addInput(new Form_Input(
190
	'synchronizetoip',
191
	'Synchronize Config to IP',
192
	'text',
193
	$pconfig['synchronizetoip'],
194
	['placeholder' => 'IP Address']
195
))->setHelp('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.<br /><br />' .
196
			'XMLRPC sync is currently only supported over connections using the same protocol and port as this system - make sure the remote system\'s port and protocol are set accordingly!<br />' .
197
			'Do not use the Synchronize Config to IP and password option on backup cluster members!');
198
199
$section->addInput(new Form_Input(
200
	'username',
201
	'Remote System Username',
202
	'text',
203
	$pconfig['username']
204
))->setHelp('Enter the webConfigurator username of the system entered above for synchronizing your configuration.<br />' .
205
			'Do not use the Synchronize Config to IP and username option on backup cluster members!');
206
207 c8b10b4c Stephen Beaver
$section->addPassword(new Form_Input(
208 cb7b3761 sbeaver
	'passwordfld',
209
	'Remote System Password',
210
	'password',
211
	$pconfig['passwordfld']
212
))->setHelp('Enter the webConfigurator password of the system entered above for synchronizing your configuration.<br />' .
213
			'Do not use the Synchronize Config to IP and password option on backup cluster members!');
214
215 52d7947c Sjon Hortensius
$group = new Form_MultiCheckboxGroup('Select options to sync');
216
217
$group->add(new Form_MultiCheckbox(
218 cb7b3761 sbeaver
	'synchronizeusers',
219
	'Synchronize Users and Groups',
220 3599c525 Chris Buechler
	'User manager users and groups',
221 cb7b3761 sbeaver
	($pconfig['synchronizeusers'] === 'on'),
222
	'on'
223
));
224
225 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
226 cb7b3761 sbeaver
	'synchronizeauthservers',
227
	'Synchronize Auth Servers',
228 3599c525 Chris Buechler
	'Authentication servers (e.g. LDAP, RADIUS)',
229 cb7b3761 sbeaver
	($pconfig['synchronizeauthservers'] === 'on'),
230
	'on'
231
));
232
233 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
234 cb7b3761 sbeaver
	'synchronizecerts',
235
	'Synchronize Certificates',
236 3599c525 Chris Buechler
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
237 cb7b3761 sbeaver
	($pconfig['synchronizecerts'] === 'on'),
238
	'on'
239
));
240
241 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
242 cb7b3761 sbeaver
	'synchronizerules',
243
	'Synchronize Rules',
244 3599c525 Chris Buechler
	'Firewall rules ',
245 cb7b3761 sbeaver
	($pconfig['synchronizerules'] === 'on'),
246
	'on'
247
));
248
249 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
250 cb7b3761 sbeaver
	'synchronizeschedules',
251
	'Synchronize Firewall schedules',
252 3599c525 Chris Buechler
	'Firewall schedules ',
253 cb7b3761 sbeaver
	($pconfig['synchronizeschedules'] === 'on'),
254
	'on'
255
));
256
257 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
258 cb7b3761 sbeaver
	'synchronizealiases',
259 3599c525 Chris Buechler
	'Synchronize Firewall aliases',
260
	'Firewall aliases ',
261
	($pconfig['synchronizealiases'] === 'on'),
262 cb7b3761 sbeaver
	'on'
263
));
264
265 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
266 cb7b3761 sbeaver
	'synchronizenat',
267
	'Synchronize NAT',
268 3599c525 Chris Buechler
	'NAT configuration ',
269 cb7b3761 sbeaver
	($pconfig['synchronizenat'] === 'on'),
270
	'on'
271
));
272
273 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
274 cb7b3761 sbeaver
	'synchronizeipsec',
275
	'Synchronize IPsec',
276 3599c525 Chris Buechler
	'IPsec configuration ',
277 cb7b3761 sbeaver
	($pconfig['synchronizeipsec'] === 'on'),
278
	'on'
279
));
280
281 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
282 cb7b3761 sbeaver
	'synchronizeopenvpn',
283
	'Synchronize OpenVPN',
284 3599c525 Chris Buechler
	'OpenVPN configuration ',
285 cb7b3761 sbeaver
	($pconfig['synchronizeopenvpn'] === 'on'),
286
	'on'
287
));
288
289 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
290 cb7b3761 sbeaver
	'synchronizedhcpd',
291
	'Synchronize DHCPD',
292 3599c525 Chris Buechler
	'DHCP Server settings ',
293 cb7b3761 sbeaver
	($pconfig['synchronizedhcpd'] === 'on'),
294
	'on'
295
));
296
297 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
298 cb7b3761 sbeaver
	'synchronizewol',
299 7ca42d47 k-paulius
	'Synchronize Wake-on-LAN',
300 3599c525 Chris Buechler
	'WoL Server settings ',
301 cb7b3761 sbeaver
	($pconfig['synchronizewol'] === 'on'),
302
	'on'
303
));
304
305 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
306 cb7b3761 sbeaver
	'synchronizestaticroutes',
307
	'Synchronize Static Routes',
308 3599c525 Chris Buechler
	'Static Route configuration ',
309 cb7b3761 sbeaver
	($pconfig['synchronizestaticroutes'] === 'on'),
310
	'on'
311
));
312
313 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
314 cb7b3761 sbeaver
	'synchronizelb',
315
	'Synchronize Load Balancer',
316 3599c525 Chris Buechler
	'Load Balancer configuration ',
317 cb7b3761 sbeaver
	($pconfig['synchronizelb'] === 'on'),
318
	'on'
319
));
320
321 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
322 cb7b3761 sbeaver
	'synchronizevirtualip',
323
	'Synchronize Virtual IPs',
324 3599c525 Chris Buechler
	'Virtual IPs ',
325 cb7b3761 sbeaver
	($pconfig['synchronizevirtualip'] === 'on'),
326
	'on'
327
));
328
329 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
330 cb7b3761 sbeaver
	'synchronizetrafficshaper',
331
	'Synchronize traffic shaper (queues)',
332 3599c525 Chris Buechler
	'Traffic Shaper configuration ',
333 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaper'] === 'on'),
334
	'on'
335
));
336
337 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
338 cb7b3761 sbeaver
	'synchronizetrafficshaperlimiter',
339
	'Synchronize traffic shaper (limiter)',
340 3599c525 Chris Buechler
	'Traffic Shaper Limiters configuration ',
341 cb7b3761 sbeaver
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
342
	'on'
343
));
344
345 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
346 cb7b3761 sbeaver
	'synchronizednsforwarder',
347 8e41aa41 Phil Davis
	'Synchronize DNS (Forwarder/Resolver)',
348 3599c525 Chris Buechler
	'DNS Forwarder and DNS Resolver configurations ',
349 cb7b3761 sbeaver
	($pconfig['synchronizednsforwarder'] === 'on'),
350
	'on'
351
));
352
353 52d7947c Sjon Hortensius
$group->add(new Form_MultiCheckbox(
354 cb7b3761 sbeaver
	'synchronizecaptiveportal',
355
	'Synchronize Captive Portal)',
356 3599c525 Chris Buechler
	'Captive Portal ',
357 cb7b3761 sbeaver
	($pconfig['synchronizecaptiveportal'] === 'on'),
358
	'on'
359
));
360
361 52d7947c Sjon Hortensius
$section->add($group);
362
363 cb7b3761 sbeaver
$form->add($section);
364
365
print($form);
366
367 e14a94af doktornotor
include("foot.inc");