aboutsummaryrefslogtreecommitdiffstats
path: root/config/haproxy-devel
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2013-09-29 22:34:42 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2013-09-29 22:34:42 +0200
commit3325861b6692036da5818ba19bf4741b0d0319a9 (patch)
tree7db81dfbaf377e0817f42a3c32c51264a294d9b0 /config/haproxy-devel
parent91ef9bdac859373696eba991d708fd55cf344b03 (diff)
downloadpfsense-packages-3325861b6692036da5818ba19bf4741b0d0319a9.tar.gz
pfsense-packages-3325861b6692036da5818ba19bf4741b0d0319a9.tar.bz2
pfsense-packages-3325861b6692036da5818ba19bf4741b0d0319a9.zip
haproxy-devel, XMLRPC-Sync redesigned, using the pfSense HASync settings for host/user/pass, with support for chaining multiple boxes.
Diffstat (limited to 'config/haproxy-devel')
-rw-r--r--config/haproxy-devel/haproxy.inc201
-rw-r--r--config/haproxy-devel/haproxy.xml5
-rwxr-xr-xconfig/haproxy-devel/haproxy_global.php28
-rw-r--r--config/haproxy-devel/haproxy_xmlrpcsyncclient.inc148
4 files changed, 213 insertions, 169 deletions
diff --git a/config/haproxy-devel/haproxy.inc b/config/haproxy-devel/haproxy.inc
index ed5c2939..2a24a518 100644
--- a/config/haproxy-devel/haproxy.inc
+++ b/config/haproxy-devel/haproxy.inc
@@ -31,9 +31,7 @@
require_once("functions.inc");
require_once("pkg-utils.inc");
require_once("notices.inc");
-
-global $haproxy_sni_ssloffloading;
-$haproxy_sni_ssloffloading=true;// can only be used with recent 1.5-dev17 builds.
+require_once("haproxy_xmlrpcsyncclient.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
@@ -62,10 +60,9 @@ $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP',
'mode' => '', 'syntax' => 'src %1$s');
$a_acltypes[] = array('name' => 'backendservercount', 'descr' => 'Minimum count usable servers',
'mode' => '', 'syntax' => 'nbsrv(%2$s) ge %1$d', 'parameters' => 'value,backendname');
-if ($haproxy_sni_ssloffloading) {
- $a_acltypes[] = array('name' => 'ssl_sni_matches', 'descr' => 'Server Name Indication TLS extension matches',
- 'mode' => 'https', 'syntax' => 'req_ssl_sni -i %1$s', 'advancedoptions' => "tcp-request inspect-delay 5s\n\ttcp-request content accept if { req_ssl_hello_type 1 }");
-}
+// 'ssl_sni_matches' was added in HAProxy1.5dev17
+$a_acltypes[] = array('name' => 'ssl_sni_matches', 'descr' => 'Server Name Indication TLS extension matches',
+ 'mode' => 'https', 'syntax' => 'req_ssl_sni -i %1$s', 'advancedoptions' => "tcp-request inspect-delay 5s\n\ttcp-request content accept if { req_ssl_hello_type 1 }");
$a_checktypes['none'] = array('name' => 'none', 'syntax' => '',
'descr' => 'No health checks will be performed.');
@@ -73,7 +70,7 @@ $a_checktypes['Basic'] = array('name' => 'Basic', 'syntax' => '',
'descr' => 'Basic socket connection check');
$a_checktypes['HTTP'] = array('name' => 'HTTP', 'syntax' => 'httpchk',
'descr' => 'HTTP protocol to check on the servers health, can also be used for HTTPS servers(requirs checking the SSL box for the servers).', 'parameters' => "uri,method,version");
-/* 'Agent' was added in HAProxy1.5dev18 */
+// 'Agent' was added in HAProxy1.5dev18
$a_checktypes['Agent'] = array('name' => 'Agent', 'syntax' => 'lb-agent-chk', 'usedifferenport' => 'yes',
'descr' => 'Use a TCP connection to read an ASCII string of the form 100%,75%,drain,down (others in haproxy manual)');
$a_checktypes['LDAP'] = array('name' => 'LDAP', 'syntax' => 'ldap-check',
@@ -318,34 +315,6 @@ function haproxy_install_cron($should_install) {
function haproxy_find_acl($name) {
global $a_acltypes;
-
- /* XXX why is this broken from xmlsync? */
- if (!$a_acltypes) {
- $a_acltypes = array();
- $a_acltypes[] = array('name' => 'host_starts_with', 'descr' => 'Host starts with',
- 'mode' => 'http', 'syntax' => 'hdr_beg(host) -i');
- $a_acltypes[] = array('name' => 'host_ends_with', 'descr' => 'Host ends with',
- 'mode' =>'http', 'syntax' => 'hdr_end(host) -i');
- $a_acltypes[] = array('name' => 'host_matches', 'descr' => 'Host matches',
- 'mode' =>'http', 'syntax' => 'hdr(host) -i');
- $a_acltypes[] = array('name' => 'host_regex', 'descr' => 'Host regex',
- 'mode' =>'http', 'syntax' => 'hdr_reg(host) -i');
- $a_acltypes[] = array('name' => 'host_contains', 'descr' => 'Host contains',
- 'mode' => 'http', 'syntax' => 'hdr_dir(host) -i');
- $a_acltypes[] = array('name' => 'path_starts_with', 'descr' => 'Path starts with',
- 'mode' => 'http', 'syntax' => 'path_beg -i');
- $a_acltypes[] = array('name' => 'path_ends_with', 'descr' => 'Path ends with',
- 'mode' => 'http', 'syntax' => 'path_end -i');
- $a_acltypes[] = array('name' => 'path_matches', 'descr' => 'Path matches',
- 'mode' => 'http', 'syntax' => 'path -i');
- $a_acltypes[] = array('name' => 'path_regex', 'descr' => 'Path regex',
- 'mode' => 'http', 'syntax' => 'path_reg -i');
- $a_acltypes[] = array('name' => 'path_contains', 'descr' => 'Path contains',
- 'mode' => 'http', 'syntax' => 'path_dir -i');
- $a_acltypes[] = array('name' => 'source_ip', 'descr' => 'Source IP',
- 'mode' => '', 'syntax' => 'src');
- }
-
if($a_acltypes) {
foreach ($a_acltypes as $acl) {
if ($acl['name'] == $name)
@@ -804,29 +773,18 @@ function haproxy_writeconf($configfile) {
}
fwrite ($fd, "\n");
- // Sync HAProxy configuration (if enabled)
- 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
+ // close config file
fclose($fd);
if ($input_errors)
{
require_once("guiconfig.inc");
print_input_errors($input_errors);
+ } else {
+ // Only sync to xmlrpc backup machine if no errors are found in config
+ if(isset($config['installedpackages']['haproxy']['enablesync'])) {
+ haproxy_do_xmlrpc_sync();
+ }
}
if (isset($a_global['carpdev']))
@@ -992,117 +950,46 @@ function killprocesses($processname, $pidfile, $signal = "KILL") {
exec("kill -$signal `pgrep -x $processname | grep -w -f $pidfile`");
}
-function haproxy_do_xmlrpc_sync($sync_to_ip, $password) {
- global $config, $g;
-
- if(!$password)
- return;
-
- if(!$sync_to_ip)
- return;
+function haproxy_sync_xmlrpc_settings() {
+ global $config;
+ // preserve 'old' sync settings, that should not be overwritten by xmlrpc-sync.
+ $enable = isset($config['installedpackages']['haproxy']['enablesync']);
- // Do not allow syncing to self.
- $donotsync = false;
- $lanip = find_interface_ip($config['interfaces']['lan']['if']);
- if($lanip == $sync_to_ip)
- $donotsync = true;
- $wanip = find_interface_ip($config['interfaces']['wan']['if']);
- if($wanip == $sync_to_ip)
- $donotsync = true;
- for ($j = 1; isset($config['interfaces']['opt' . $j]); $j++) {
- $optip = find_interface_ip($config['interfaces']['opt' . $j]['if']);
- if($optip == $sync_to_ip)
- $donotsync = true;
- }
- if($donotsync) {
- log_error("Disallowing sync loop for HAProxy sync.");
- return;
- }
+ $config['installedpackages']['haproxy'] = $config['installedpackages']['haproxysyncpkg'];
+ unset($config['installedpackages']['haproxysyncpkg']);
+
+ // restore 'old' settings.
+ $config['installedpackages']['haproxy']['enablesync'] = $enable ? true : false;
+
+ write_config("HAPROXY xmlrpc config synced"); // Write new 'merged' configuration
+}
- $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;
+function haproxy_do_xmlrpc_sync() {
+ $syncinfo = array();
+ $syncinfo['sync_logname'] = "HAProxy";
+ $syncinfo['data'] = haproxy_xmlrpc_sync_prepare_config();
+ $syncinfo['sync_include'] = "/usr/local/pkg/haproxy.inc";
+ $syncinfo['sync_done_execute'] = "haproxy_xmlrpc_sync_configure";
+ xmlrpc_sync_execute($syncinfo);
+}
+function haproxy_xmlrpc_sync_prepare_config() {
/* xml will hold the sections to sync */
+ global $config;
$xml = array();
- $xml['haproxy'] = $config['installedpackages']['haproxy'];
-
- // Prevent sync loops
- unset($xml['synchost1']);
- unset($xml['synchost2']);
- unset($xml['synchost3']);
- unset($xml['syncpassword']);
-
- /* 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}.");
- }
+ $xml['haproxysyncpkg'] = $config['installedpackages']['haproxy'];
+ return $xml;
+}
- /* tell haproxy to reload our settings on the destionation sync host. */
- $method = 'pfsense.exec_php';
- $execcmd = "require_once('/usr/local/pkg/haproxy.inc');\n";
- $execcmd .= "haproxy_configure();\n";
+function haproxy_xmlrpc_sync_configure() {
+ // this function is called by xmlrpc after config has been synced.
- /* assemble xmlrpc payload */
- $params = array(
- XML_RPC_encode($password),
- XML_RPC_encode($execcmd)
- );
-
- log_error("HAProxy XMLRPC reload data {$url}:{$port}.");
- $msg = new XML_RPC_Message($method, $params);
- $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
- $cli->setCredentials('admin', $password);
- $resp = $cli->send($msg, "250");
- if(!$resp) {
- $error = "A communications error occurred while attempting HAProxy XMLRPC sync with {$url}:{$port} (exec_php).";
- log_error($error);
- file_notice("sync_settings", $error, "HAProxy Settings Reload", "");
- } 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 reload data success with {$url}:{$port} (exec_php).");
+ haproxy_sync_xmlrpc_settings();
+ haproxy_configure(); // Configure HAProxy config files to use the new configuration.
+
+ // sync 2nd and further nodes in the chain if applicable.
+ if(isset($config['installedpackages']['haproxy']['enablesync'])) {
+ haproxy_do_xmlrpc_sync();
}
}
diff --git a/config/haproxy-devel/haproxy.xml b/config/haproxy-devel/haproxy.xml
index 4511bde4..bfd7f437 100644
--- a/config/haproxy-devel/haproxy.xml
+++ b/config/haproxy-devel/haproxy.xml
@@ -95,6 +95,11 @@
<item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy_socketinfo.inc</item>
</additional_files_needed>
<additional_files_needed>
+ <prefix>/usr/local/pkg/</prefix>
+ <chmod>077</chmod>
+ <item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy_xmlrpcsyncclient.inc</item>
+ </additional_files_needed>
+ <additional_files_needed>
<prefix>/usr/local/www/widgets/widgets/</prefix>
<chmod>077</chmod>
<item>http://www.pfsense.com/packages/config/haproxy-devel/haproxy.widget.php</item>
diff --git a/config/haproxy-devel/haproxy_global.php b/config/haproxy-devel/haproxy_global.php
index dbc55847..018a67ef 100755
--- a/config/haproxy-devel/haproxy_global.php
+++ b/config/haproxy-devel/haproxy_global.php
@@ -59,26 +59,26 @@ if ($_POST) {
if ($_POST['maxconn'] && (!is_numeric($_POST['maxconn'])))
$input_errors[] = "The maximum number of connections should be numeric.";
- if($_POST['synchost1'] && !is_ipaddr($_POST['synchost1']))
+ /*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.";
+ $input_errors[] = "Synchost3 needs to be an IPAddress.";*/
if (!$input_errors) {
$config['installedpackages']['haproxy']['enable'] = $_POST['enable'] ? true : false;
$config['installedpackages']['haproxy']['terminate_on_reload'] = $_POST['terminate_on_reload'] ? 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;
+ //$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;
$config['installedpackages']['haproxy']['remotesyslog'] = $_POST['remotesyslog'] ? $_POST['remotesyslog'] : false;
$config['installedpackages']['haproxy']['logfacility'] = $_POST['logfacility'] ? $_POST['logfacility'] : false;
$config['installedpackages']['haproxy']['loglevel'] = $_POST['loglevel'] ? $_POST['loglevel'] : false;
$config['installedpackages']['haproxy']['carpdev'] = $_POST['carpdev'] ? $_POST['carpdev'] : false;
- $config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false;
+ //$config['installedpackages']['haproxy']['syncpassword'] = $_POST['syncpassword'] ? $_POST['syncpassword'] : false;
$config['installedpackages']['haproxy']['advanced'] = $_POST['advanced'] ? base64_encode($_POST['advanced']) : false;
$config['installedpackages']['haproxy']['nbproc'] = $_POST['nbproc'] ? $_POST['nbproc'] : false;
touch($d_haproxyconfdirty_path);
@@ -91,10 +91,10 @@ $pconfig['enable'] = isset($config['installedpackages']['haproxy']['enable']);
$pconfig['terminate_on_reload'] = isset($config['installedpackages']['haproxy']['terminate_on_reload']);
$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'];
+//$pconfig['syncpassword'] = $config['installedpackages']['haproxy']['syncpassword'];
+//$pconfig['synchost1'] = $config['installedpackages']['haproxy']['synchost1'];
+//$pconfig['synchost2'] = $config['installedpackages']['haproxy']['synchost2'];
+//$pconfig['synchost3'] = $config['installedpackages']['haproxy']['synchost3'];
$pconfig['remotesyslog'] = $config['installedpackages']['haproxy']['remotesyslog'];
$pconfig['logfacility'] = $config['installedpackages']['haproxy']['logfacility'];
$pconfig['loglevel'] = $config['installedpackages']['haproxy']['loglevel'];
@@ -337,12 +337,15 @@ function enable_change(enable_change) {
<td colspan="2" valign="top" class="listtopic">Configuration synchronization</td>
</tr>
<tr>
- <td width="22%" valign="top" class="vncell">&nbsp;</td>
+ <td width="22%" valign="top" class="vncell">HAProxy Sync</td>
<td width="78%" class="vtable">
<input name="enablesync" type="checkbox" value="yes" <?php if ($pconfig['enablesync']) echo "checked"; ?>>
- <strong>Sync HAProxy configuration to backup CARP members via XMLRPC.</strong>
+ <strong>Sync HAProxy configuration to backup CARP members via XMLRPC.</strong><br/>
+ Note: remeber to also turn on HAProxy Sync on the backup nodes.<br/>
+ The synchronisation host and password are those configured in pfSense main <a href="/system_hasync.php">"System: High Availability Sync"</a> settings.
</td>
</tr>
+<!--
<tr>
<td width="22%" valign="top" class="vncell">Synchronization password</td>
<td width="78%" class="vtable">
@@ -375,6 +378,7 @@ function enable_change(enable_change) {
<strong>Synchronize settings to this hosts IP address.</strong>
</td>
</tr>
+-->
<tr>
<td>
&nbsp;
diff --git a/config/haproxy-devel/haproxy_xmlrpcsyncclient.inc b/config/haproxy-devel/haproxy_xmlrpcsyncclient.inc
new file mode 100644
index 00000000..5c4a373b
--- /dev/null
+++ b/config/haproxy-devel/haproxy_xmlrpcsyncclient.inc
@@ -0,0 +1,148 @@
+<?php
+/*
+ haproxy_xmlrpcsyncclient.inc
+ Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.com>
+ Copyright (C) 2008 Remco Hoef
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
+ INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
+ AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+*/
+
+/* include all configuration functions */
+require_once("functions.inc");
+require_once("pkg-utils.inc");
+require_once("notices.inc");
+
+function xmlrpc_sync_execute($syncinfo) {
+ // name that is logged if something fails during syncing
+ $sync_logname = $syncinfo['sync_logname'];
+ // configuration data to sync
+ $xml = $syncinfo['data'];
+ // include file in which the "function sync_done_execute(){xxx}" must be pressent
+ $sync_include = $syncinfo['sync_include'];
+ // executes to apply the changed configuration on the target system
+ $sync_function = $syncinfo['sync_done_execute'];
+
+ global $config, $g;
+ //if(!$password)
+ $password = $config['hasync']['password'];
+ if(!$password)
+ return;
+
+ //if(!$sync_to_ip)
+ $sync_to_ip = $config['hasync']['synchronizetoip'];
+ if(!$sync_to_ip)
+ return;
+
+ // Do not allow syncing to self.
+ $donotsync = false;
+ $localips = get_configured_ip_addresses();
+ if (in_array($sync_to_ip, $localips , true))
+ $donotsync = true;
+
+ if($donotsync) {
+ log_error("Disallowing sync loop for HAProxy sync.");
+ 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 = prepare_xmlrpc_sync_config();
+
+
+ /* 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 {$sync_logname} 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 {$sync_logname} XMLRPC sync with {$url}:{$port}.";
+ log_error($error);
+ file_notice("sync_settings", $error, "{$sync_logname} Settings Sync", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting {$sync_logname} XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "{$sync_logname} Settings Sync", "");
+ } else {
+ log_error("{$sync_logname} XMLRPC sync successfully completed with {$url}:{$port}.");
+ }
+
+ /* tell haproxy to reload our settings on the destionation sync host. */
+ $method = 'pfsense.exec_php';
+ $execcmd = "require_once('{$sync_include}');\n";
+ $execcmd .= "{$sync_function}();\n";
+
+ /* assemble xmlrpc payload */
+ $params = array(
+ XML_RPC_encode($password),
+ XML_RPC_encode($execcmd)
+ );
+
+ log_error("HAProxy XMLRPC reload data {$url}:{$port}.");
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
+ $cli->setCredentials('admin', $password);
+ $resp = $cli->send($msg, "250");
+ if(!$resp) {
+ $error = "A communications error occurred while attempting {$sync_logname} XMLRPC sync with {$url}:{$port} (exec_php).";
+ log_error($error);
+ file_notice("sync_settings", $error, "{$sync_logname} Settings Reload", "");
+ } elseif($resp->faultCode()) {
+ $cli->setDebug(1);
+ $resp = $cli->send($msg, "250");
+ $error = "An error code was received while attempting {$sync_logname} XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
+ log_error($error);
+ file_notice("sync_settings", $error, "{$sync_logname} Settings Sync", "");
+ } else {
+ log_error("{$sync_logname} XMLRPC reload data success with {$url}:{$port} (exec_php).");
+ }
+}
+
+?>