aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2009-11-17 18:55:45 -0500
committerScott Ullrich <sullrich@pfsense.org>2009-11-17 18:55:45 -0500
commitd0301611abd503ee932c83012594fccc974e8aab (patch)
tree4bad2ebdb3309d14908728f976594912a140c51d /config
parentc7c3dad7eafbeae9e6c1d1a26a71541876efaaf5 (diff)
downloadpfsense-packages-d0301611abd503ee932c83012594fccc974e8aab.tar.gz
pfsense-packages-d0301611abd503ee932c83012594fccc974e8aab.tar.bz2
pfsense-packages-d0301611abd503ee932c83012594fccc974e8aab.zip
Adding XML RPX Configuration synchronization capabilities
Diffstat (limited to 'config')
-rw-r--r--config/haproxy/haproxy.inc74
-rwxr-xr-xconfig/haproxy/haproxy_global.php69
2 files changed, 134 insertions, 9 deletions
diff --git a/config/haproxy/haproxy.inc b/config/haproxy/haproxy.inc
index e87e0817..6c226269 100644
--- a/config/haproxy/haproxy.inc
+++ b/config/haproxy/haproxy.inc
@@ -195,6 +195,20 @@ function haproxy_configure() {
}
fwrite ($fd, "\n");
}
+ if(isset($config['installedpackages']['haproxy']['enablesync'])) {
+ if($config['installedpackages']['haproxy']['synchost1']) {
+ haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost1'],
+ $config['installedpackages']['haproxy']['syncpassword']);
+ }
+ if($config['installedpackages']['haproxy']['synchost2']) {
+ haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost2'],
+ $config['installedpackages']['haproxy']['syncpassword']);
+ }
+ if($config['installedpackages']['haproxy']['synchost3']) {
+ haproxy_do_xmlrpc_sync($config['installedpackages']['haproxy']['synchost3'],
+ $config['installedpackages']['haproxy']['syncpassword']);
+ }
+ }
}
// create config file
@@ -213,4 +227,64 @@ function haproxy_configure() {
}
}
+function haproxy_do_xmlrpc_sync($sync_to_ip, $password) {
+ global $config, $g;
+
+ if(!$password)
+ return;
+
+ if(!$sync_to_ip)
+ return;
+
+ $xmlrpc_sync_neighbor = $sync_to_ip;
+ if($config['system']['webgui']['protocol'] != "") {
+ $synchronizetoip = $config['system']['webgui']['protocol'];
+ $synchronizetoip .= "://";
+ }
+ $port = $config['system']['webgui']['port'];
+ /* if port is empty lets rely on the protocol selection */
+ if($port == "") {
+ if($config['system']['webgui']['protocol'] == "http")
+ $port = "80";
+ else
+ $port = "443";
+ }
+ $synchronizetoip .= $sync_to_ip;
+
+ /* xml will hold the sections to sync */
+ $xml = array();
+ $xml['haproxy'] = $config['installedpackages']['haproxy'];
+
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($xml)
+ );
+
+ /* set a few variables needed for sync code borrowed from filter.inc */
+ $url = $synchronizetoip;
+ log_error("Beginning HAProxy XMLRPC sync to {$url}:{$port}.");
+ $method = 'pfsense.merge_installedpackages_section_xmlrpc';
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ if($g['debug'])
+ $cli->setDebug(1);
+ /* send our XMLRPC message and timeout after 250 seconds */
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting HAProxy XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "HAProxy Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting HAProxy XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "HAProxy Settings Sync", "");
+ } else {
+ log_error("HAProxy XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+}
+
?> \ No newline at end of file
diff --git a/config/haproxy/haproxy_global.php b/config/haproxy/haproxy_global.php
index 18a32954..af159f58 100755
--- a/config/haproxy/haproxy_global.php
+++ b/config/haproxy/haproxy_global.php
@@ -35,17 +35,20 @@ require_once("haproxy.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
-if (!is_array($config['installedpackages']['haproxy'])) {
+if (!is_array($config['installedpackages']['haproxy']))
$config['installedpackages']['haproxy'] = array();
-}
$pconfig['enable'] = isset($config['installedpackages']['haproxy']['enable']);
$pconfig['maxconn'] = $config['installedpackages']['haproxy']['maxconn'];
+$pconfig['enablesync'] = isset($config['installedpackages']['haproxy']['enablesync']);
+$pconfig['syncpassword'] = $config['installedpackages']['haproxy']['syncpassword'];
+$pconfig['synchost1'] = $config['installedpackages']['haproxy']['synchost1'];
+$pconfig['synchost2'] = $config['installedpackages']['haproxy']['synchost2'];
+$pconfig['synchost3'] = $config['installedpackages']['haproxy']['synchost3'];
if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
-
if ($_POST['apply']) {
$retval = 0;
@@ -58,19 +61,27 @@ if ($_POST) {
if ($_POST['enable']) {
$reqdfields = explode(" ", "maxconn");
$reqdfieldsn = explode(",", "Maximum connections");
- } else {
}
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
- if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn']))) {
+ if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn'])))
$input_errors[] = "The maximum number of connections should be numeric.";
- }
+
+ if($_POST['synchost1'] && !is_ipaddr($_POST['synchost1']))
+ $input_errors[] = "Synchost1 needs to be an IPAddress.";
+ if($_POST['synchost2'] && !is_ipaddr($_POST['synchost2']))
+ $input_errors[] = "Synchost2 needs to be an IPAddress.";
+ if($_POST['synchost3'] && !is_ipaddr($_POST['synchost3']))
+ $input_errors[] = "Synchost3 needs to be an IPAddress.";
if (!$input_errors) {
$config['installedpackages']['haproxy']['enable'] = $_POST['enable'] ? true : false;
$config['installedpackages']['haproxy']['maxconn'] = $_POST['maxconn'] ? $_POST['maxconn'] : false;
-
+ $config['installedpackages']['haproxy']['enablesync'] = $_POST['enablesync'] ? true : false;
+ $config['installedpackages']['haproxy']['synchost1'] = $_POST['synchost1'] ? $_POST['synchost1'] : false;
+ $config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost2'] ? $_POST['synchost2'] : false;
+ $config['installedpackages']['haproxy']['synchost2'] = $_POST['synchost3'] ? $_POST['synchost3'] : false;
touch($d_haproxyconfdirty_path);
write_config();
}
@@ -142,11 +153,12 @@ function enable_change(enable_change) {
</table>
Sets the maximum per-process number of concurrent connections to X.<br/>
<strong>NOTE:</strong> setting this value too high will result in haproxy not being able to allocate enough memory.<br/>
-<?php
+ <?php
$hapcpu = `top | grep haproxy | awk '{ print $6 }'`;
if($hapcpu)
echo "<p>Current memory usage {$hascpu}.</p>";
-?> </td><td>
+ ?>
+ </td><td>
<table style="border: 1px solid #000;">
<tr>
<td><font size=-1>Connections</td>
@@ -183,6 +195,45 @@ function enable_change(enable_change) {
</td>
</tr>
<tr>
+ <td width="22%" valign="top" class="vtable">&nbsp;</td>
+ <td width="78%" class="vtable">
+ <input name="enablesync" type="checkbox" value="yes" <?php if ($pconfig['enablesync']) echo "checked"; ?>>
+ <strong>Sync XMLRPC configuration to backup CARP members</strong></td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">Synchronization password</td>
+ <td width="78%" class="vtable">
+ <input name="syncpassword" type="password" value="<?=$pconfig['syncpassword'];?>">
+ <strong>Enter the password that will be used during configuration synchronization. This is generally the remote webConfigurator password.</strong>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">Sync host #1</td>
+ <td width="78%" class="vtable">
+ <input name="enablesync" value="<?=$pconfig['synchost1'];?>">
+ <strong>Synchronize settings to this hosts IP address.</strong>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">Sync host #2</td>
+ <td width="78%" class="vtable">
+ <input name="enablesync" value="<?=$pconfig['synchost2'];?>">
+ <strong>Synchronize settings to this hosts IP address.</strong>
+ </td>
+ </tr>
+ <tr>
+ <td width="22%" valign="top" class="vtable">Sync host #3</td>
+ <td width="78%" class="vtable">
+ <input name="enablesync" value="<?=$pconfig['synchost3'];?>">
+ <strong>Synchronize settings to this hosts IP address.</strong>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ &nbsp;
+ </td>
+ </tr>
+ <tr>
<td width="22%" valign="top">&nbsp;</td>
<td width="78%">
<input name="Submit" type="submit" class="formbtn" value="Save" onClick="enable_change(true)">