Project

General

Profile

Download (9.28 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-2018 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
init_config_arr(array('hasync'));
32
$a_hasync = &$config['hasync'];
33

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

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

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

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

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

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

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

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

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

    
108
include("head.inc");
109

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

    
114
$form = new Form;
115

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

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

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

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

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

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

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

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

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

    
177
$group = new Form_MultiCheckboxGroup('Select options to sync');
178

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
323
$section->add($group);
324

    
325
$form->add($section);
326

    
327
print($form);
328

    
329
include("foot.inc");
(209-209/234)