Commit 85669dbd authored by Ad Schellevis's avatar Ad Schellevis

(legacy) refactor system_hasync.php

parent 86d50f87
......@@ -30,34 +30,38 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
$referer = (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_hasync.php');
if (!isset($config['hasync']) || !is_array($config['hasync'])) {
$config['hasync'] = array();
}
$a_hasync = &$config['hasync'];
$checkbox_names = array(
'pfsyncenabled',
'synchronizeusers',
'synchronizeauthservers',
'synchronizecerts',
'synchronizerules',
'synchronizeschedules',
'synchronizealiases',
'synchronizenat',
'synchronizeipsec',
'synchronizeopenvpn',
'synchronizedhcpd',
'synchronizewol',
'synchronizestaticroutes',
'synchronizelb',
'synchronizevirtualip',
$checkbox_names = array('pfsyncenabled', 'synchronizeusers', 'synchronizeauthservers', 'synchronizecerts',
'synchronizerules', 'synchronizeschedules', 'synchronizealiases', 'synchronizenat',
'synchronizeipsec', 'synchronizeopenvpn', 'synchronizedhcpd', 'synchronizewol',
'synchronizestaticroutes', 'synchronizelb', 'synchronizevirtualip',
'synchronizednsforwarder',
);
if ($_POST) {
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array();
foreach ($checkbox_names as $name) {
if (isset($a_hasync[$name])) {
$pconfig[$name] = $a_hasync[$name];
} else {
$pconfig[$name] = null;
}
}
foreach (array('pfsyncpeerip','pfsyncinterface','synchronizetoip','username','password') as $tag) {
if (isset($a_hasync[$tag])) {
$pconfig[$tag] = $a_hasync[$tag];
} else {
$pconfig[$tag] = null;
}
}
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
foreach ($checkbox_names as $name) {
if (isset($pconfig[$name])) {
......@@ -77,77 +81,56 @@ if ($_POST) {
exit();
}
foreach ($checkbox_names as $name) {
if (isset($a_hasync[$name])) {
$pconfig[$name] = $a_hasync[$name];
} else {
$pconfig[$name] = null;
}
}
foreach (array('pfsyncpeerip','pfsyncinterface','synchronizetoip','username','password') as $tag) {
if (isset($a_hasync[$tag])) {
$pconfig[$tag] = $a_hasync[$tag];
} else {
$pconfig[$tag] = null;
}
}
$ifaces = get_configured_interface_with_descr();
$ifaces["lo0"] = "loopback";
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<!-- row -->
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<section class="col-xs-12">
<div class="content-box">
<div class="table-responsive">
<form action="system_hasync.php" method="post" name="iform" id="iform">
<table class="table table-primary table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
<thead>
<form action="system_hasync.php" method="post">
<table class="table table-striped">
<tr>
<th colspan="2" class="listtopic"><?=gettext('State Synchronization Settings (pfsync)') ?></th>
<td width="22%"><strong><?=gettext('State Synchronization') ?></strong></td>
<td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i></a>
</td>
</tr>
</thead>
<tbody>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize States') ?></td>
<td class="vtable">
<input id='pfsyncenabled' type='checkbox' name='pfsyncenabled' value='on' <?php if ($pconfig['pfsyncenabled'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_pfsyncenabled" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Synchronize States') ?></td>
<td>
<input type="checkbox" name="pfsyncenabled" value="on" <?= !empty($pconfig['pfsyncenabled']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_pfsyncenabled">
<?= sprintf(gettext('pfsync transfers state insertion, update, and deletion messages between firewalls.%s' .
'Each firewall sends these messages out via multicast on a specified interface, using the PFSYNC protocol (%sIP Protocol 240%s).%s' .
'It also listens on that interface for similar messages from other firewalls, and imports them into the local state table.%s' .
'This setting should be enabled on all members of a failover group.'), '<br/>','<a href="http://www.openbsd.org/faq/pf/carp.html" target="_blank">','</a>','<br/>','<br/>') ?>
<div class="well well-sm" ><b><?=gettext('Clicking save will force a configuration sync if it is enabled! (see Configuration Synchronization Settings below)') ?></b></div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Interface') ?></td>
<td class="vtable">
<select id='pfsyncinterface' name="pfsyncinterface" class="selectpicker" data-style="btn-default" data-live-search="true" data-width="auto">
<?php foreach ($ifaces as $ifname => $iface) {
<tr>
<td><a id="help_for_pfsyncinterface" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Synchronize Interface') ?></td>
<td>
<select name="pfsyncinterface" class="selectpicker" data-style="btn-default" data-live-search="true" data-width="auto">
<?php
$ifaces = get_configured_interface_with_descr();
$ifaces["lo0"] = gettext("loopback");
foreach ($ifaces as $ifname => $iface):
?>
<?php $selected = ($pconfig['pfsyncinterface'] === $ifname) ? 'selected="selected"' : ''; ?>
<option value="<?= htmlentities($ifname);
?>" <?= $selected ?>><?= htmlentities($iface); ?></option>
<?php
} ?>
<option value="<?=htmlentities($ifname);?>" <?= ($pconfig['pfsyncinterface'] === $ifname) ? 'selected="selected"' : ''; ?>>
<?= htmlentities($iface); ?>
</option>
<?php
endforeach; ?>
</select>
<div class="hidden" for="help_for_pfsyncinterface">
<?=gettext('If Synchronize States is enabled, it will utilize this interface for communication.') ?><br/><br/>
<div class="well">
<lu>
......@@ -156,33 +139,26 @@ include("head.inc");
<li><?=gettext('You must have an IP assigned to the interface on any participating sync nodes.') ?></li>
</lu>
</div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('pfsync Synchronize Peer IP') ?></td>
<td class="vtable">
<input id='pfsyncpeerip' name='pfsyncpeerip' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['pfsyncpeerip']); ?>' />
<tr>
<td><a id="help_for_pfsyncpeerip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Synchronize Peer IP') ?></td>
<td>
<input name="pfsyncpeerip" type="text" value="<?=$pconfig['pfsyncpeerip']; ?>" />
<div class="hidden" for="help_for_pfsyncpeerip">
<?=gettext('Setting this option will force pfsync to synchronize its state table to this IP address. The default is directed multicast.') ?>
</div>
</td>
</tr>
<tr>
<td></td>
<td>&nbsp;</td>
</tr>
</tbody>
</table>
<table class="table table-primary table-striped" width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
<thead>
<tr>
<th colspan="2" class="listtopic"><?=gettext('Configuration Synchronization Settings (XMLRPC Sync)') ?></th>
</tr>
</thead>
<tbody>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Config to IP') ?></td>
<td class="vtable">
<input id='synchronizetoip' name='synchronizetoip' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['synchronizetoip']); ?>' />
<tr>
<td><a id="help_for_synchronizetoip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Synchronize Config to IP') ?></td>
<td>
<input name="synchronizetoip" type="text" value="<?=$pconfig['synchronizetoip']; ?>" />
<div class="hidden" for="help_for_synchronizetoip">
<?=gettext('Enter the IP address of the firewall to which the selected configuration sections should be synchronized.') ?><br />
<div class="well">
<lu>
......@@ -190,186 +166,182 @@ include("head.inc");
<li><b><?=gettext('Do not use the Synchronize Config to IP and password option on backup cluster members!') ?></b></li>
</lu>
</div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Remote System Username') ?></td>
<td class="vtable">
<input id='username' name='username' type='text' class='formfld unknown' value='<?= htmlentities($pconfig['username']); ?>' />
<br />
<tr>
<td><a id="help_for_username" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Remote System Username') ?></td>
<td>
<input name="username" type="text" value="<?=$pconfig['username'];?>" />
<div class="hidden" for="help_for_username">
<?=gettext('Enter the webConfigurator username of the system entered above for synchronizing your configuration.') ?><br />
<div class="well well-sm">
<b><?=gettext('Do not use the Synchronize Config to IP and username option on backup cluster members!') ?></b>
</div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Remote System Password') ?></td>
<td class="vtable">
<input id='password' type='password' name='password' class='formfld pwd' value='<?= htmlentities($pconfig['password']); ?>' />
<br />
<tr>
<td><a id="help_for_password" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Remote System Password') ?></td>
<td>
<input type="password" name="password" value="<?=$pconfig['password']; ?>" />
<div class="hidden" for="help_for_password">
<?=gettext('Enter the webConfigurator password of the system entered above for synchronizing your configuration.') ?><br />
<div class="well well-sm">
<b><?=gettext('Do not use the Synchronize Config to IP and password option on backup cluster members!') ?></b>
</div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Users and Groups') ?></td>
<td class="vtable">
<input id='synchronizeusers' type='checkbox' name='synchronizeusers' value='on' <?php if ($pconfig['synchronizeusers'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizeusers" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Users and Groups') ?></td>
<td>
<input type="checkbox" name="synchronizeusers" value="on" <?=!empty($pconfig['synchronizeusers']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizeusers">
<?=gettext('Automatically sync the users and groups over to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Auth Servers') ?></td>
<td class="vtable">
<input id='synchronizeauthservers' type='checkbox' name='synchronizeauthservers' value='on' <?php if ($pconfig['synchronizeauthservers'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizeauthservers" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Auth Servers') ?></td>
<td>
<input type="checkbox" name='synchronizeauthservers' value="on" <?=!empty($pconfig['synchronizeauthservers']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizeauthservers">
<?=gettext('Automatically sync the authentication servers (e.g. LDAP, RADIUS) over to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Certificates') ?></td>
<td class="vtable">
<input id='synchronizecerts' type='checkbox' name='synchronizecerts' value='on' <?php if ($pconfig['synchronizecerts'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizecerts" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Certificates') ?></td>
<td>
<input type="checkbox" name="synchronizecerts" value="on" <?=!empty($pconfig['synchronizecerts']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizecerts">
<?=gettext('Automatically sync the Certificate Authorities, Certificates, and Certificate Revocation Lists over to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize rules') ?></td>
<td class="vtable">
<input id='synchronizerules' type='checkbox' name='synchronizerules' value='on' <?php if ($pconfig['synchronizerules'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizerules" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Firewall Rules') ?></td>
<td>
<input type="checkbox" name="synchronizerules" value="on" <?=!empty($pconfig['synchronizerules']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizerules">
<?=gettext('Automatically sync the firewall rules to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Firewall Schedules') ?></td>
<td class="vtable">
<input id='synchronizeschedules' type='checkbox' name='synchronizeschedules' value='on' <?php if ($pconfig['synchronizeschedules'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizeschedules" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Firewall Schedules') ?></td>
<td>
<input type="checkbox" name="synchronizeschedules" value="on" <?=!empty($pconfig['synchronizeschedules']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizeschedules">
<?=gettext('Automatically sync the firewall schedules to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize aliases') ?></td>
<td class="vtable">
<input id='synchronizealiases' type='checkbox' name='synchronizealiases' value='on' <?php if ($pconfig['synchronizealiases'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizealiases" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Aliases') ?></td>
<td>
<input type="checkbox" name="synchronizealiases" value="on" <?=!empty($pconfig['synchronizealiases']) ? "checked=\"checked\"" : "";?>/>
<div class="hidden" for="help_for_synchronizealiases">
<?=gettext('Automatically sync the aliases over to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize NAT') ?></td>
<td class="vtable">
<input id='synchronizenat' type='checkbox' name='synchronizenat' value='on' <?php if ($pconfig['synchronizenat'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizenat" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('NAT') ?></td>
<td>
<input type="checkbox" name="synchronizenat" value="on" <?=!empty($pconfig['synchronizenat']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizenat">
<?=gettext('Automatically sync the NAT rules over to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize IPsec') ?></td>
<td class="vtable">
<input id='synchronizeipsec' type='checkbox' name='synchronizeipsec' value='on' <?php if ($pconfig['synchronizeipsec'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizeipsec" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('IPsec') ?></td>
<td>
<input type="checkbox" name="synchronizeipsec" value="on" <?=!empty($pconfig['synchronizeipsec']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizeipsec">
<?=gettext('Automatically sync the IPsec configuration to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize OpenVPN') ?></td>
<td class="vtable">
<input id='synchronizeopenvpn' type='checkbox' name='synchronizeopenvpn' value='on' <?php if ($pconfig['synchronizeopenvpn'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizeopenvpn" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('OpenVPN') ?></td>
<td>
<input type="checkbox" name="synchronizeopenvpn" value="on" <?=!empty($pconfig['synchronizeopenvpn']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizeopenvpn">
<?=gettext('Automatically sync the OpenVPN configuration to the other HA host when changes are made.') ?>
<div class="well well-sm"><b><?=gettext('Using this option implies "Synchronize Certificates" as they are required for OpenVPN.') ?></b></div>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize DHCPD') ?></td>
<td class="vtable">
<input id='synchronizedhcpd' type='checkbox' name='synchronizedhcpd' value='on' <?php if ($pconfig['synchronizedhcpd'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizedhcpd" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('DHCPD') ?></td>
<td>
<input type="checkbox" name="synchronizedhcpd" value="on" <?=!empty($pconfig['synchronizedhcpd']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizedhcpd">
<?=gettext('Automatically sync the DHCP Server settings over to the other HA host when changes are made. This only applies to DHCP for IPv4.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Wake on LAN') ?></td>
<td class="vtable">
<input id='synchronizewol' type='checkbox' name='synchronizewol' value='on' <?php if ($pconfig['synchronizewol'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizewol" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Wake on LAN') ?></td>
<td>
<input type="checkbox" name="synchronizewol" value="on" <?=!empty($pconfig['synchronizewol']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizewol">
<?=gettext('Automatically sync the WoL configuration to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Static Routes') ?></td>
<td class="vtable">
<input id='synchronizestaticroutes' type='checkbox' name='synchronizestaticroutes' value='on' <?php if ($pconfig['synchronizestaticroutes'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizestaticroutes" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Static Routes') ?></td>
<td>
<input type="checkbox" name="synchronizestaticroutes" value="on" <?=!empty($pconfig['synchronizestaticroutes']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizestaticroutes">
<?=gettext('Automatically sync the Static Route configuration to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Load Balancer') ?></td>
<td class="vtable">
<input id='synchronizelb' type='checkbox' name='synchronizelb' value='on' <?php if ($pconfig['synchronizelb'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizelb" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Load Balancer') ?></td>
<td>
<input type="checkbox" name="synchronizelb" value="on" <?=!empty($pconfig['synchronizelb']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizelb">
<?=gettext('Automatically sync the Load Balancer configuration to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize Virtual IPs') ?></td>
<td class="vtable">
<input id='synchronizevirtualip' type='checkbox' name='synchronizevirtualip' value='on' <?php if ($pconfig['synchronizevirtualip'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizevirtualip" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('Virtual IPs') ?></td>
<td>
<input type="checkbox" name="synchronizevirtualip" value="on" <?=!empty($pconfig['synchronizevirtualip']) ? "checked=\"checked\"" : "";?> />
<div class="hidden" for="help_for_synchronizevirtualip">
<?=gettext('Automatically sync the CARP Virtual IPs to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr valign="top">
<td width="22%" class="vncell"><?=gettext('Synchronize DNS Forwarder') ?></td>
<td class="vtable">
<input id='synchronizednsforwarder' type='checkbox' name='synchronizednsforwarder' value='on' <?php if ($pconfig['synchronizednsforwarder'] === "on") {
echo "checked='checked'";
} ?> />
<tr>
<td><a id="help_for_synchronizednsforwarder" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext('DNS Forwarder') ?></td>
<td>
<input type="checkbox" name="synchronizednsforwarder" value="on" <?=!empty($pconfig['synchronizednsforwarder']) ? "checked=\"checked\"" :"";?> />
<div class="hidden" for="help_for_synchronizednsforwarder">
<?=gettext('Automatically sync the DNS Forwarder configuration to the other HA host when changes are made.') ?>
</div>
</td>
</tr>
<tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="id" type="hidden" value="0" />
<td></td>
<td>
<input name="Submit" type="submit" class="btn btn-primary" value="Save" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");
?>" onclick="window.location.href='<?=$referer;?>'" />
<input type="button" class="btn btn-default" value="<?=gettext("Cancel");?>" onclick="window.location.href='<?=(isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/system_hasync.php');?>'" />
</td>
</tr>
</tbody>
</table>
</form>
</div>
</div>
</section>
</div>
</div>
</section>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment