Project

General

Profile

Download (9.87 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-2013 BSD Perimeter
7
 * Copyright (c) 2013-2016 Electric Sheep Fencing
8
 * Copyright (c) 2014-2021 Rubicon Communications, LLC (Netgate)
9
 * All rights reserved.
10
 *
11
 * Licensed under the Apache License, Version 2.0 (the "License");
12
 * you may not use this file except in compliance with the License.
13
 * You may obtain a copy of the License at
14
 *
15
 * http://www.apache.org/licenses/LICENSE-2.0
16
 *
17
 * Unless required by applicable law or agreed to in writing, software
18
 * distributed under the License is distributed on an "AS IS" BASIS,
19
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20
 * See the License for the specific language governing permissions and
21
 * limitations under the License.
22
 */
23

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

    
31
require_once("guiconfig.inc");
32

    
33
init_config_arr(array('hasync'));
34
$a_hasync = &$config['hasync'];
35

    
36
$checkbox_names = array(
37
	'pfsyncenabled',
38
	'adminsync',
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
	'synchronizevirtualip',
52
	'synchronizetrafficshaper',
53
	'synchronizetrafficshaperlimiter',
54
	'synchronizednsforwarder',
55
	'synchronizecaptiveportal');
56

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

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

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

    
79
	if (!empty($pconfig['synchronizetoip']) && !is_ipaddr($pconfig['synchronizetoip'])) {
80
		$input_errors[] = gettext("Synchronize Config to IP must be a valid IP address.");
81
	}
82

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

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

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

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

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

    
112
include("head.inc");
113

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

    
118
$form = new Form;
119

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

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

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

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

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

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

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

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

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

    
182
$section->addInput(new Form_Checkbox(
183
	'adminsync',
184
	'Synchronize admin',
185
	'synchronize admin accounts and autoupdate sync password.',
186
	($pconfig['adminsync'] === 'on'),
187
	'on'
188
))->setHelp('By default, the admin account does not synchronize, and each node may have a different admin password.%1$s' .
189
			'This option automatically updates XMLRPC Remote System Password when the password is changed on 
190
			the Remote System Username account.', '<br />');
191

    
192
$group = new Form_MultiCheckboxGroup('Select options to sync');
193

    
194
$group->add(new Form_MultiCheckbox(
195
	'synchronizeusers',
196
	'Synchronize Users and Groups',
197
	'User manager users and groups',
198
	($pconfig['synchronizeusers'] === 'on'),
199
	'on'
200
));
201

    
202
$group->add(new Form_MultiCheckbox(
203
	'synchronizeauthservers',
204
	'Synchronize Auth Servers',
205
	'Authentication servers (e.g. LDAP, RADIUS)',
206
	($pconfig['synchronizeauthservers'] === 'on'),
207
	'on'
208
));
209

    
210
$group->add(new Form_MultiCheckbox(
211
	'synchronizecerts',
212
	'Synchronize Certificates',
213
	'Certificate Authorities, Certificates, and Certificate Revocation Lists',
214
	($pconfig['synchronizecerts'] === 'on'),
215
	'on'
216
));
217

    
218
$group->add(new Form_MultiCheckbox(
219
	'synchronizerules',
220
	'Synchronize Rules',
221
	'Firewall rules ',
222
	($pconfig['synchronizerules'] === 'on'),
223
	'on'
224
));
225

    
226
$group->add(new Form_MultiCheckbox(
227
	'synchronizeschedules',
228
	'Synchronize Firewall schedules',
229
	'Firewall schedules ',
230
	($pconfig['synchronizeschedules'] === 'on'),
231
	'on'
232
));
233

    
234
$group->add(new Form_MultiCheckbox(
235
	'synchronizealiases',
236
	'Synchronize Firewall aliases',
237
	'Firewall aliases ',
238
	($pconfig['synchronizealiases'] === 'on'),
239
	'on'
240
));
241

    
242
$group->add(new Form_MultiCheckbox(
243
	'synchronizenat',
244
	'Synchronize NAT',
245
	'NAT configuration ',
246
	($pconfig['synchronizenat'] === 'on'),
247
	'on'
248
));
249

    
250
$group->add(new Form_MultiCheckbox(
251
	'synchronizeipsec',
252
	'Synchronize IPsec',
253
	'IPsec configuration ',
254
	($pconfig['synchronizeipsec'] === 'on'),
255
	'on'
256
));
257

    
258
$group->add(new Form_MultiCheckbox(
259
	'synchronizeopenvpn',
260
	'Synchronize OpenVPN',
261
	'OpenVPN configuration (Implies CA/Cert/CRL Sync) ',
262
	($pconfig['synchronizeopenvpn'] === 'on'),
263
	'on'
264
));
265

    
266
$group->add(new Form_MultiCheckbox(
267
	'synchronizedhcpd',
268
	'Synchronize DHCPD',
269
	'DHCP Server settings ',
270
	($pconfig['synchronizedhcpd'] === 'on'),
271
	'on'
272
));
273

    
274
$group->add(new Form_MultiCheckbox(
275
	'synchronizewol',
276
	'Synchronize Wake-on-LAN',
277
	'WoL Server settings ',
278
	($pconfig['synchronizewol'] === 'on'),
279
	'on'
280
));
281

    
282
$group->add(new Form_MultiCheckbox(
283
	'synchronizestaticroutes',
284
	'Synchronize Static Routes',
285
	'Static Route configuration ',
286
	($pconfig['synchronizestaticroutes'] === 'on'),
287
	'on'
288
));
289

    
290
$group->add(new Form_MultiCheckbox(
291
	'synchronizevirtualip',
292
	'Synchronize Virtual IPs',
293
	'Virtual IPs ',
294
	($pconfig['synchronizevirtualip'] === 'on'),
295
	'on'
296
));
297

    
298
$group->add(new Form_MultiCheckbox(
299
	'synchronizetrafficshaper',
300
	'Synchronize traffic shaper (queues)',
301
	'Traffic Shaper configuration ',
302
	($pconfig['synchronizetrafficshaper'] === 'on'),
303
	'on'
304
));
305

    
306
$group->add(new Form_MultiCheckbox(
307
	'synchronizetrafficshaperlimiter',
308
	'Synchronize traffic shaper (limiter)',
309
	'Traffic Shaper Limiters configuration ',
310
	($pconfig['synchronizetrafficshaperlimiter'] === 'on'),
311
	'on'
312
));
313

    
314
$group->add(new Form_MultiCheckbox(
315
	'synchronizednsforwarder',
316
	'Synchronize DNS (Forwarder/Resolver)',
317
	'DNS Forwarder and DNS Resolver configurations ',
318
	($pconfig['synchronizednsforwarder'] === 'on'),
319
	'on'
320
));
321

    
322
$group->add(new Form_MultiCheckbox(
323
	'synchronizecaptiveportal',
324
	'Synchronize Captive Portal)',
325
	'Captive Portal ',
326
	($pconfig['synchronizecaptiveportal'] === 'on'),
327
	'on'
328
));
329

    
330
$section->add($group);
331

    
332
$form->add($section);
333

    
334
print($form);
335

    
336
include("foot.inc");
(202-202/227)