Project

General

Profile

Download (9.25 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-2019 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
	'synchronizeusers',
39
	'synchronizeauthservers',
40
	'synchronizecerts',
41
	'synchronizerules',
42
	'synchronizeschedules',
43
	'synchronizealiases',
44
	'synchronizenat',
45
	'synchronizeipsec',
46
	'synchronizeopenvpn',
47
	'synchronizedhcpd',
48
	'synchronizewol',
49
	'synchronizestaticroutes',
50
	'synchronizevirtualip',
51
	'synchronizetrafficshaper',
52
	'synchronizetrafficshaperlimiter',
53
	'synchronizednsforwarder',
54
	'synchronizecaptiveportal');
55

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

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

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

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

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

    
97
$ifaces = get_configured_interface_with_descr();
98
$ifaces["lo0"] = "loopback";
99

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

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

    
109
include("head.inc");
110

    
111
if ($input_errors) {
112
	print_input_errors($input_errors);
113
}
114

    
115
$form = new Form;
116

    
117
$section = new Form_Section('State Synchronization Settings (pfsync)');
118

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

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

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

    
148
$form->add($section);
149

    
150
$section = new Form_Section('Configuration Synchronization Settings (XMLRPC Sync)');
151

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

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

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

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

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

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

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

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

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

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

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

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

    
245
$group->add(new Form_MultiCheckbox(
246
	'synchronizeopenvpn',
247
	'Synchronize OpenVPN',
248
	'OpenVPN configuration (Implies CA/Cert/CRL Sync) ',
249
	($pconfig['synchronizeopenvpn'] === 'on'),
250
	'on'
251
));
252

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

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

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

    
277
$group->add(new Form_MultiCheckbox(
278
	'synchronizevirtualip',
279
	'Synchronize Virtual IPs',
280
	'Virtual IPs ',
281
	($pconfig['synchronizevirtualip'] === 'on'),
282
	'on'
283
));
284

    
285
$group->add(new Form_MultiCheckbox(
286
	'synchronizetrafficshaper',
287
	'Synchronize traffic shaper (queues)',
288
	'Traffic Shaper configuration ',
289
	($pconfig['synchronizetrafficshaper'] === 'on'),
290
	'on'
291
));
292

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

    
301
$group->add(new Form_MultiCheckbox(
302
	'synchronizednsforwarder',
303
	'Synchronize DNS (Forwarder/Resolver)',
304
	'DNS Forwarder and DNS Resolver configurations ',
305
	($pconfig['synchronizednsforwarder'] === 'on'),
306
	'on'
307
));
308

    
309
$group->add(new Form_MultiCheckbox(
310
	'synchronizecaptiveportal',
311
	'Synchronize Captive Portal)',
312
	'Captive Portal ',
313
	($pconfig['synchronizecaptiveportal'] === 'on'),
314
	'on'
315
));
316

    
317
$section->add($group);
318

    
319
$form->add($section);
320

    
321
print($form);
322

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