Project

General

Profile

Download (9.29 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
 * system_hasync.php
4
 *
5
 * part of pfSense (https://www.pfsense.org)
6
 * Copyright (c) 2004-2016 Rubicon Communications, LLC (Netgate)
7
 * All rights reserved.
8
 *
9
 * Licensed under the Apache License, Version 2.0 (the "License");
10
 * you may not use this file except in compliance with the License.
11
 * You may obtain a copy of the License at
12
 *
13
 * http://www.apache.org/licenses/LICENSE-2.0
14
 *
15
 * Unless required by applicable law or agreed to in writing, software
16
 * distributed under the License is distributed on an "AS IS" BASIS,
17
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
 * See the License for the specific language governing permissions and
19
 * limitations under the License.
20
 */
21

    
22
##|+PRIV
23
##|*IDENT=page-system-hasync
24
##|*NAME=System: High Availability Sync
25
##|*DESCR=Allow access to the 'System: High Availability Sync' page.
26
##|*MATCH=system_hasync.php*
27
##|-PRIV
28

    
29
require_once("guiconfig.inc");
30

    
31
if (!is_array($config['hasync'])) {
32
	$config['hasync'] = array();
33
}
34

    
35
$a_hasync = &$config['hasync'];
36

    
37
$checkbox_names = array(
38
	'pfsyncenabled',
39
	'synchronizeusers',
40
	'synchronizeauthservers',
41
	'synchronizecerts',
42
	'synchronizerules',
43
	'synchronizeschedules',
44
	'synchronizealiases',
45
	'synchronizenat',
46
	'synchronizeipsec',
47
	'synchronizeopenvpn',
48
	'synchronizedhcpd',
49
	'synchronizewol',
50
	'synchronizestaticroutes',
51
	'synchronizelb',
52
	'synchronizevirtualip',
53
	'synchronizetrafficshaper',
54
	'synchronizetrafficshaperlimiter',
55
	'synchronizednsforwarder',
56
	'synchronizecaptiveportal');
57

    
58
if ($_POST) {
59
	$pconfig = $_POST;
60
	foreach ($checkbox_names as $name) {
61
		$a_hasync[$name] = $pconfig[$name] ? $pconfig[$name] : false;
62
	}
63
	$a_hasync['pfsyncpeerip'] = $pconfig['pfsyncpeerip'];
64
	$a_hasync['pfsyncinterface'] = $pconfig['pfsyncinterface'];
65
	$a_hasync['synchronizetoip'] = $pconfig['synchronizetoip'];
66
	$a_hasync['username'] = $pconfig['username'];
67

    
68
	if ($pconfig['passwordfld'] == $pconfig['passwordfld_confirm']) {
69
		if ($pconfig['passwordfld'] != DMYPWD) {
70
				$a_hasync['password'] = $pconfig['passwordfld'];
71
		}
72
	} else {
73
		$input_errors[] = gettext("Password and confirmation must match.");
74
	}
75

    
76
	if ($pconfig['pfsyncpeerip'] != "") {
77
		if (!is_ipaddrv4($pconfig['pfsyncpeerip'])) {
78
			$input_errors[] = gettext("pfsync Synchronize Peer IP must be an IPv4 IP.");
79
		}
80
	}
81

    
82
	if (!$input_errors) {
83
		write_config("Updated High Availability Sync configuration");
84
		interfaces_sync_setup();
85
		header("Location: system_hasync.php");
86
		exit();
87
	}
88
}
89

    
90
foreach ($checkbox_names as $name) {
91
	$pconfig[$name] = $a_hasync[$name];
92
}
93
$pconfig['pfsyncpeerip']	= $a_hasync['pfsyncpeerip'];
94
$pconfig['pfsyncinterface'] = $a_hasync['pfsyncinterface'];
95
$pconfig['synchronizetoip'] = $a_hasync['synchronizetoip'];
96
$pconfig['username']		= $a_hasync['username'];
97
$pconfig['passwordfld']	 = $a_hasync['password'];
98

    
99
$ifaces = get_configured_interface_with_descr();
100
$ifaces["lo0"] = "loopback";
101

    
102
$pgtitle = array(gettext("System"), gettext("High Availability Sync"));
103
$shortcut_section = "carp";
104

    
105
// Build a list of available interfaces
106
$iflist = array();
107
foreach ($ifaces as $ifname => $iface) {
108
	$iflist[$ifname] = $iface;
109
}
110

    
111
include("head.inc");
112

    
113
if ($input_errors) {
114
	print_input_errors($input_errors);
115
}
116

    
117
$form = new Form;
118

    
119
$section = new Form_Section('State Synchronization Settings (pfsync)');
120

    
121
$section->addInput(new Form_Checkbox(
122
	'pfsyncenabled',
123
	'Synchronize states',
124
	'pfsync transfers state insertion, update, and deletion messages between firewalls.',
125
	($pconfig['pfsyncenabled'] === 'on'),
126
	'on'
127
))->setHelp('Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (IP Protocol 240).' .
128
			' It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.<br />' .
129
			'This setting should be enabled on all members of a failover group.<br />' .
130
			'Clicking "Save" will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)');
131

    
132
$section->addInput(new Form_Select(
133
	'pfsyncinterface',
134
	'Synchronize Interface',
135
	$pconfig['pfsyncinterface'],
136
	$iflist
137
))->setHelp('If Synchronize States is enabled this interface will be used for communication.<br />' .
138
			'It is recommended to set this to an interface other than LAN! A dedicated interface works the best.<br />' .
139
			'An IP must be defined on each machine participating in this failover group.<br />' .
140
			'An IP must be assigned to the interface on any participating sync nodes.');
141

    
142
$section->addInput(new Form_Input(
143
	'pfsyncpeerip',
144
	'pfsync Synchronize Peer IP',
145
	'text',
146
	$pconfig['pfsyncpeerip'],
147
	['placeholder' => 'IP Address']
148
))->setHelp('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.');
149

    
150
$form->add($section);
151

    
152
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
153

    
154
$section->addInput(new Form_Input(
155
	'synchronizetoip',
156
	'Synchronize Config to IP',
157
	'text',
158
	$pconfig['synchronizetoip'],
159
	['placeholder' => 'IP Address']
160
))->setHelp('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.<br /><br />' .
161
			'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 />' .
162
			'Do not use the Synchronize Config to IP and password option on backup cluster members!');
163

    
164
$section->addInput(new Form_Input(
165
	'username',
166
	'Remote System Username',
167
	'text',
168
	$pconfig['username']
169
))->setHelp('Enter the webConfigurator username of the system entered above for synchronizing the configuration.<br />' .
170
			'Do not use the Synchronize Config to IP and username option on backup cluster members!');
171

    
172
$section->addPassword(new Form_Input(
173
	'passwordfld',
174
	'Remote System Password',
175
	'password',
176
	$pconfig['passwordfld']
177
))->setHelp('Enter the webConfigurator password of the system entered above for synchronizing the configuration.<br />' .
178
			'Do not use the Synchronize Config to IP and password option on backup cluster members!');
179

    
180
$group = new Form_MultiCheckboxGroup('Select options to sync');
181

    
182
$group->add(new Form_MultiCheckbox(
183
	'synchronizeusers',
184
	'Synchronize Users and Groups',
185
	'User manager users and groups',
186
	($pconfig['synchronizeusers'] === 'on'),
187
	'on'
188
));
189

    
190
$group->add(new Form_MultiCheckbox(
191
	'synchronizeauthservers',
192
	'Synchronize Auth Servers',
193
	'Authentication servers (e.g. LDAP, RADIUS)',
194
	($pconfig['synchronizeauthservers'] === 'on'),
195
	'on'
196
));
197

    
198
$group->add(new Form_MultiCheckbox(
199
	'synchronizecerts',
200
	'Synchronize Certificates',
201
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
202
	($pconfig['synchronizecerts'] === 'on'),
203
	'on'
204
));
205

    
206
$group->add(new Form_MultiCheckbox(
207
	'synchronizerules',
208
	'Synchronize Rules',
209
	'Firewall rules ',
210
	($pconfig['synchronizerules'] === 'on'),
211
	'on'
212
));
213

    
214
$group->add(new Form_MultiCheckbox(
215
	'synchronizeschedules',
216
	'Synchronize Firewall schedules',
217
	'Firewall schedules ',
218
	($pconfig['synchronizeschedules'] === 'on'),
219
	'on'
220
));
221

    
222
$group->add(new Form_MultiCheckbox(
223
	'synchronizealiases',
224
	'Synchronize Firewall aliases',
225
	'Firewall aliases ',
226
	($pconfig['synchronizealiases'] === 'on'),
227
	'on'
228
));
229

    
230
$group->add(new Form_MultiCheckbox(
231
	'synchronizenat',
232
	'Synchronize NAT',
233
	'NAT configuration ',
234
	($pconfig['synchronizenat'] === 'on'),
235
	'on'
236
));
237

    
238
$group->add(new Form_MultiCheckbox(
239
	'synchronizeipsec',
240
	'Synchronize IPsec',
241
	'IPsec configuration ',
242
	($pconfig['synchronizeipsec'] === 'on'),
243
	'on'
244
));
245

    
246
$group->add(new Form_MultiCheckbox(
247
	'synchronizeopenvpn',
248
	'Synchronize OpenVPN',
249
	'OpenVPN configuration ',
250
	($pconfig['synchronizeopenvpn'] === 'on'),
251
	'on'
252
));
253

    
254
$group->add(new Form_MultiCheckbox(
255
	'synchronizedhcpd',
256
	'Synchronize DHCPD',
257
	'DHCP Server settings ',
258
	($pconfig['synchronizedhcpd'] === 'on'),
259
	'on'
260
));
261

    
262
$group->add(new Form_MultiCheckbox(
263
	'synchronizewol',
264
	'Synchronize Wake-on-LAN',
265
	'WoL Server settings ',
266
	($pconfig['synchronizewol'] === 'on'),
267
	'on'
268
));
269

    
270
$group->add(new Form_MultiCheckbox(
271
	'synchronizestaticroutes',
272
	'Synchronize Static Routes',
273
	'Static Route configuration ',
274
	($pconfig['synchronizestaticroutes'] === 'on'),
275
	'on'
276
));
277

    
278
$group->add(new Form_MultiCheckbox(
279
	'synchronizelb',
280
	'Synchronize Load Balancer',
281
	'Load Balancer configuration ',
282
	($pconfig['synchronizelb'] === 'on'),
283
	'on'
284
));
285

    
286
$group->add(new Form_MultiCheckbox(
287
	'synchronizevirtualip',
288
	'Synchronize Virtual IPs',
289
	'Virtual IPs ',
290
	($pconfig['synchronizevirtualip'] === 'on'),
291
	'on'
292
));
293

    
294
$group->add(new Form_MultiCheckbox(
295
	'synchronizetrafficshaper',
296
	'Synchronize traffic shaper (queues)',
297
	'Traffic Shaper configuration ',
298
	($pconfig['synchronizetrafficshaper'] === 'on'),
299
	'on'
300
));
301

    
302
$group->add(new Form_MultiCheckbox(
303
	'synchronizetrafficshaperlimiter',
304
	'Synchronize traffic shaper (limiter)',
305
	'Traffic Shaper Limiters configuration ',
306
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
307
	'on'
308
));
309

    
310
$group->add(new Form_MultiCheckbox(
311
	'synchronizednsforwarder',
312
	'Synchronize DNS (Forwarder/Resolver)',
313
	'DNS Forwarder and DNS Resolver configurations ',
314
	($pconfig['synchronizednsforwarder'] === 'on'),
315
	'on'
316
));
317

    
318
$group->add(new Form_MultiCheckbox(
319
	'synchronizecaptiveportal',
320
	'Synchronize Captive Portal)',
321
	'Captive Portal ',
322
	($pconfig['synchronizecaptiveportal'] === 'on'),
323
	'on'
324
));
325

    
326
$section->add($group);
327

    
328
$form->add($section);
329

    
330
print($form);
331

    
332
include("foot.inc");
(201-201/225)