Project

General

Profile

Download (11.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	system_hasync.php
4
*/
5
/* ====================================================================
6
 *	Copyright (c)  2004-2015  Electric Sheep Fencing, LLC. All rights reserved.
7
 *	Copyright (c)  2012 Darren Embry <dse@webonastick.com>.
8
 *
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

    
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
if (!is_array($config['hasync'])) {
67
	$config['hasync'] = array();
68
}
69

    
70
$a_hasync = &$config['hasync'];
71

    
72
$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

    
93
if ($_POST) {
94
	$pconfig = $_POST;
95
	foreach ($checkbox_names as $name) {
96
		$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
97
	}
98
	$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
99
	$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
100
	$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
101
	$a_hasync['username'] = $pconfig['username'];
102

    
103
	if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
104
		if ($pconfig['passwordfld'] != DMYPWD) {
105
				$a_hasync['password'] = $pconfig['passwordfld'];
106
		}
107
	} else {
108
		$input_errors[] = gettext("Password and confirmation must match.");
109
	}
110

    
111
	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
	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
}
124

    
125
foreach ($checkbox_names as $name) {
126
	$pconfig[$name] = $a_hasync[$name];
127
}
128
$pconfig['pfsyncpeerip']	= $a_hasync['pfsyncpeerip'];
129
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
130
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
131
$pconfig['username']		= $a_hasync['username'];
132
$pconfig['passwordfld']	 = $a_hasync['password'];
133

    
134
$ifaces = get_configured_interface_with_descr();
135
$ifaces["lo0"] = "loopback";
136

    
137
$pgtitle = array(gettext("System"), gettext("High Availability Sync"));
138
$shortcut_section = "carp";
139

    
140
// Build a list of available interfaces
141
$iflist = array();
142
foreach ($ifaces as $ifname => $iface) {
143
	$iflist[$ifname] = $iface;
144
}
145

    
146
include("head.inc");
147

    
148
if ($input_errors) {
149
	print_input_errors($input_errors);
150
}
151

    
152
$form = new Form;
153

    
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
	'Synchronize Interface',
170
	$pconfig['pfsyncinterface'],
171
	$iflist
172
))->setHelp('If Synchronize States is enabled this interface will be used for communication.<br />' .
173
			'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
			'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
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
184

    
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
$section->addPassword(new Form_Input(
208
	'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
$group = new Form_MultiCheckboxGroup('Select options to sync');
216

    
217
$group->add(new Form_MultiCheckbox(
218
	'synchronizeusers',
219
	'Synchronize Users and Groups',
220
	'User manager users and groups',
221
	($pconfig['synchronizeusers'] === 'on'),
222
	'on'
223
));
224

    
225
$group->add(new Form_MultiCheckbox(
226
	'synchronizeauthservers',
227
	'Synchronize Auth Servers',
228
	'Authentication servers (e.g. LDAP, RADIUS)',
229
	($pconfig['synchronizeauthservers'] === 'on'),
230
	'on'
231
));
232

    
233
$group->add(new Form_MultiCheckbox(
234
	'synchronizecerts',
235
	'Synchronize Certificates',
236
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
237
	($pconfig['synchronizecerts'] === 'on'),
238
	'on'
239
));
240

    
241
$group->add(new Form_MultiCheckbox(
242
	'synchronizerules',
243
	'Synchronize Rules',
244
	'Firewall rules ',
245
	($pconfig['synchronizerules'] === 'on'),
246
	'on'
247
));
248

    
249
$group->add(new Form_MultiCheckbox(
250
	'synchronizeschedules',
251
	'Synchronize Firewall schedules',
252
	'Firewall schedules ',
253
	($pconfig['synchronizeschedules'] === 'on'),
254
	'on'
255
));
256

    
257
$group->add(new Form_MultiCheckbox(
258
	'synchronizealiases',
259
	'Synchronize Firewall aliases',
260
	'Firewall aliases ',
261
	($pconfig['synchronizealiases'] === 'on'),
262
	'on'
263
));
264

    
265
$group->add(new Form_MultiCheckbox(
266
	'synchronizenat',
267
	'Synchronize NAT',
268
	'NAT configuration ',
269
	($pconfig['synchronizenat'] === 'on'),
270
	'on'
271
));
272

    
273
$group->add(new Form_MultiCheckbox(
274
	'synchronizeipsec',
275
	'Synchronize IPsec',
276
	'IPsec configuration ',
277
	($pconfig['synchronizeipsec'] === 'on'),
278
	'on'
279
));
280

    
281
$group->add(new Form_MultiCheckbox(
282
	'synchronizeopenvpn',
283
	'Synchronize OpenVPN',
284
	'OpenVPN configuration ',
285
	($pconfig['synchronizeopenvpn'] === 'on'),
286
	'on'
287
));
288

    
289
$group->add(new Form_MultiCheckbox(
290
	'synchronizedhcpd',
291
	'Synchronize DHCPD',
292
	'DHCP Server settings ',
293
	($pconfig['synchronizedhcpd'] === 'on'),
294
	'on'
295
));
296

    
297
$group->add(new Form_MultiCheckbox(
298
	'synchronizewol',
299
	'Synchronize Wake-on-LAN',
300
	'WoL Server settings ',
301
	($pconfig['synchronizewol'] === 'on'),
302
	'on'
303
));
304

    
305
$group->add(new Form_MultiCheckbox(
306
	'synchronizestaticroutes',
307
	'Synchronize Static Routes',
308
	'Static Route configuration ',
309
	($pconfig['synchronizestaticroutes'] === 'on'),
310
	'on'
311
));
312

    
313
$group->add(new Form_MultiCheckbox(
314
	'synchronizelb',
315
	'Synchronize Load Balancer',
316
	'Load Balancer configuration ',
317
	($pconfig['synchronizelb'] === 'on'),
318
	'on'
319
));
320

    
321
$group->add(new Form_MultiCheckbox(
322
	'synchronizevirtualip',
323
	'Synchronize Virtual IPs',
324
	'Virtual IPs ',
325
	($pconfig['synchronizevirtualip'] === 'on'),
326
	'on'
327
));
328

    
329
$group->add(new Form_MultiCheckbox(
330
	'synchronizetrafficshaper',
331
	'Synchronize traffic shaper (queues)',
332
	'Traffic Shaper configuration ',
333
	($pconfig['synchronizetrafficshaper'] === 'on'),
334
	'on'
335
));
336

    
337
$group->add(new Form_MultiCheckbox(
338
	'synchronizetrafficshaperlimiter',
339
	'Synchronize traffic shaper (limiter)',
340
	'Traffic Shaper Limiters configuration ',
341
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
342
	'on'
343
));
344

    
345
$group->add(new Form_MultiCheckbox(
346
	'synchronizednsforwarder',
347
	'Synchronize DNS (Forwarder/Resolver)',
348
	'DNS Forwarder and DNS Resolver configurations ',
349
	($pconfig['synchronizednsforwarder'] === 'on'),
350
	'on'
351
));
352

    
353
$group->add(new Form_MultiCheckbox(
354
	'synchronizecaptiveportal',
355
	'Synchronize Captive Portal)',
356
	'Captive Portal ',
357
	($pconfig['synchronizecaptiveportal'] === 'on'),
358
	'on'
359
));
360

    
361
$section->add($group);
362

    
363
$form->add($section);
364

    
365
print($form);
366

    
367
include("foot.inc");
(204-204/229)