diff options
author | bmeeks8 <bmeeks8@bellsouth.net> | 2013-05-13 17:09:43 -0400 |
---|---|---|
committer | bmeeks8 <bmeeks8@bellsouth.net> | 2013-05-13 17:09:43 -0400 |
commit | 4a38b4b1a48b67baf997453227c9d4a1bb810523 (patch) | |
tree | 0321c07f5267806b55ad025df8c13968ac17ba94 /config/sarg/sarg.inc | |
parent | 080fb922c15c959be4f0bd101d0cf3f529f0e866 (diff) | |
parent | 3eddd42b1d0da5bdf5faec0e5036ef30347fa0a3 (diff) | |
download | pfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.tar.gz pfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.tar.bz2 pfsense-packages-4a38b4b1a48b67baf997453227c9d4a1bb810523.zip |
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'config/sarg/sarg.inc')
-rw-r--r-- | config/sarg/sarg.inc | 85 |
1 files changed, 60 insertions, 25 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", ""); |