aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/sarg/sarg.inc85
-rwxr-xr-xconfig/sarg/sarg_sync.xml26
2 files changed, 84 insertions, 27 deletions
diff --git a/config/sarg/sarg.inc b/config/sarg/sarg.inc
index 5d0a91a5..32cca7ed 100644
--- a/config/sarg/sarg.inc
+++ b/config/sarg/sarg.inc
@@ -434,31 +434,63 @@ function sarg_validate_input($post, &$input_errors) {
}
}
-
/* Uses XMLRPC to synchronize the changes to a remote node */
function sarg_sync_on_changes() {
global $config, $g;
-
- log_error("[sarg] sarg_xmlrpc_sync.php is starting.");
- $synconchanges = $config['installedpackages']['sargsync']['config'][0]['synconchanges'];
- if(!$synconchanges)
- return;
- foreach ($config['installedpackages']['sargsync']['config'] as $rs ){
- foreach($rs['row'] as $sh){
- $sync_to_ip = $sh['ipaddress'];
- $password = $sh['password'];
- if($sh['username'])
- $username = $sh['username'];
- else
- $username = 'admin';
- if($password && $sync_to_ip)
- sarg_do_xmlrpc_sync($sync_to_ip, $username, $password);
+ if (is_array($config['installedpackages']['sargsync']['config'])){
+ $sarg_sync=$config['installedpackages']['sargsync']['config'][0];
+ $synconchanges = $sarg_sync['synconchanges'];
+ $synctimeout = $sarg_sync['synctimeout'];
+ switch ($synconchanges){
+ case "manual":
+ if (is_array($sarg_sync[row])){
+ $rs=$sarg_sync[row];
+ }
+ else{
+ log_error("[sarg] xmlrpc sync is enabled but there is no hosts to push on sarg config.");
+ return;
+ }
+ break;
+ case "auto":
+ if (is_array($config['installedpackages']['carpsettings']) && is_array($config['installedpackages']['carpsettings']['config'])){
+ $system_carp=$config['installedpackages']['carpsettings']['config'][0];
+ $rs[0]['ipaddress']=$system_carp['synchronizetoip'];
+ $rs[0]['username']=$system_carp['username'];
+ $rs[0]['password']=$system_carp['password'];
+ if ($system_carp['synchronizetoip'] =="" || $system_carp['username']==""){
+ log_error("[sarg] xmlrpc sync is enabled but there is no system backup hosts to push sarg config.");
+ return;
+ }
+
+ }
+ else{
+ log_error("[sarg] xmlrpc sync is enabled but there is no system backup hosts to push sarg config.");
+ return;
+ }
+ break;
+ default:
+ return;
+ break;
+ }
+ if (is_array($rs)){
+ log_error("[sarg] xmlrpc sync is starting.");
+ foreach($rs as $sh){
+ $sync_to_ip = $sh['ipaddress'];
+ $password = $sh['password'];
+ if($sh['username'])
+ $username = $sh['username'];
+ else
+ $username = 'admin';
+ if($password && $sync_to_ip)
+ sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout);
+ }
+ log_error("[sarg] xmlrpc sync is ending.");
}
- }
- log_error("[sarg] sarg_xmlrpc_sync.php is ending.");
+ }
}
+
/* Do the actual XMLRPC sync */
-function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password) {
+function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password,$synctimeout) {
global $config, $g;
if(!$username)
@@ -469,7 +501,10 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password) {
if(!$sync_to_ip)
return;
-
+
+ if(!$synctimeout)
+ $synctimeout="150";
+
$xmlrpc_sync_neighbor = $sync_to_ip;
if($config['system']['webgui']['protocol'] != "") {
$synchronizetoip = $config['system']['webgui']['protocol'];
@@ -504,15 +539,15 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password) {
$cli->setCredentials($username, $password);
if($g['debug'])
$cli->setDebug(1);
- /* send our XMLRPC message and timeout after 250 seconds */
- $resp = $cli->send($msg, "250");
+ /* send our XMLRPC message and timeout after $synctimeout seconds */
+ $resp = $cli->send($msg, $synctimeout);
if(!$resp) {
$error = "A communications error occurred while attempting sarg XMLRPC sync with {$url}:{$port}.";
log_error($error);
file_notice("sync_settings", $error, "sarg Settings Sync", "");
} elseif($resp->faultCode()) {
$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
+ $resp = $cli->send($msg, $synctimeout);
$error = "An error code was received while attempting sarg XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
log_error($error);
file_notice("sync_settings", $error, "sarg Settings Sync", "");
@@ -534,14 +569,14 @@ function sarg_do_xmlrpc_sync($sync_to_ip, $username, $password) {
$msg = new XML_RPC_Message($method, $params);
$cli = new XML_RPC_Client('/xmlrpc.php', $url, $port);
$cli->setCredentials($username, $password);
- $resp = $cli->send($msg, "250");
+ $resp = $cli->send($msg, $synctimeout);
if(!$resp) {
$error = "A communications error occurred while attempting sarg XMLRPC sync with {$url}:{$port} (pfsense.exec_php).";
log_error($error);
file_notice("sync_settings", $error, "sarg Settings Sync", "");
} elseif($resp->faultCode()) {
$cli->setDebug(1);
- $resp = $cli->send($msg, "250");
+ $resp = $cli->send($msg, $synctimeout);
$error = "An error code was received while attempting sarg XMLRPC sync with {$url}:{$port} - Code " . $resp->faultCode() . ": " . $resp->faultString();
log_error($error);
file_notice("sync_settings", $error, "sarg Settings Sync", "");
diff --git a/config/sarg/sarg_sync.xml b/config/sarg/sarg_sync.xml
index 6c81b3f8..6cff7b6d 100755
--- a/config/sarg/sarg_sync.xml
+++ b/config/sarg/sarg_sync.xml
@@ -84,8 +84,30 @@
<field>
<fielddescr>Automatically sync sarg configuration changes</fielddescr>
<fieldname>synconchanges</fieldname>
- <description>pfSense will automatically sync changes to the hosts defined below.</description>
- <type>checkbox</type>
+ <description>Select a sync method for sarg.</description>
+ <type>select</type>
+ <required/>
+ <default_value>auto</default_value>
+ <options>
+ <option><name>Sync to configured system backup server</name><value>auto</value></option>
+ <option><name>Sync to host(s) defined below</name><value>manual</value></option>
+ <option><name>Do not sync this package configuration</name><value>disabled</value></option>
+ </options>
+ </field>
+ <field>
+ <fielddescr>Sync timeout</fielddescr>
+ <fieldname>synctimeout</fieldname>
+ <description>Select sync max wait time</description>
+ <type>select</type>
+ <required/>
+ <default_value>250</default_value>
+ <options>
+ <option><name>250 seconds(Default)</name><value>250</value></option>
+ <option><name>120 seconds</name><value>120</value></option>
+ <option><name>90 seconds</name><value>90</value></option>
+ <option><name>60 seconds</name><value>60</value></option>
+ <option><name>30 seconds</name><value>30</value></option>
+ </options>
</field>
<field>
<fielddescr>Remote Server</fielddescr>