From dd5f6c0187b0c91ff7b09c48d55a8c19720af344 Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Thu, 31 Mar 2005 01:52:18 +0000 Subject: Use new XMLRPC code for CARP sync - honest! --- packages/carp_sync_client.php | 54 +++++++++++++++++-------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) diff --git a/packages/carp_sync_client.php b/packages/carp_sync_client.php index b2da24ba..d5c084f6 100644 --- a/packages/carp_sync_client.php +++ b/packages/carp_sync_client.php @@ -1,4 +1,5 @@ #!/usr/bin/php +setCredentials('admin', $password); + $resp = $cli->send($msg); + return true; +} if($already_processed != 1) if($config['installedpackages']['carpsettings']['config'] <> "" and @@ -48,46 +57,25 @@ if($already_processed != 1) $synchronizetoip = $carp['synchronizetoip']; if($carp['synchronizerules'] <> "" and is_array($config['filter'])) { $current_rules_section = backup_config_section("filter"); - //$current_rules_section = str_replace("", "", $current_rules_section); + carp_sync_xml($carp['synchronizetoip'], $carp['password'], 'filter', $current_rules_section); } if($carp['synchronizenat'] <> "" and is_array($config['nat'])) { $current_nat_section = backup_config_section("nat"); - $current_nat_section = str_replace("", "", $current_nat_section); - /* generate nat rules xml */ - $fout = fopen("{$g['tmp_path']}/nat_section.txt","w"); - fwrite($fout, $current_nat_section); - fclose($fout); - $files_to_copy .= " {$g['tmp_path']}/nat_section.txt"; + carp_sync_xml($carp['synchronizetoip'], $carp['password'], 'nat', $current_nat_section); } if($carp['synchronizealiases'] <> "" and is_array($config['aliases'])) { $current_aliases_section = backup_config_section("aliases"); - $current_aliases_section = str_replace("", "", $current_aliases_section); - /* generate aliases xml */ - $fout = fopen("{$g['tmp_path']}/aliases_section.txt","w"); - fwrite($fout, $current_aliases_section); - fclose($fout); - $files_to_copy .= " {$g['tmp_path']}/aliases_section.txt"; + carp_sync_xml($carp['synchronizetoip'], $carp['password'], 'alias', $current_aliases_section); } if($carp['synchronizetrafficshaper'] <> "" and is_array($config['shaper'])) { - $current_trafficshaper_section = backup_config_section("shaper"); - $current_trafficshaper_section = str_replace("", "", $current_trafficshaper_section); - /* generate aliases xml */ - $fout = fopen("{$g['tmp_path']}/shaper_section.txt","w"); - fwrite($fout, $current_trafficshaper_section); - fclose($fout); - $files_to_copy .= " {$g['tmp_path']}/shaper_section.txt"; + $current_shaper_section = backup_config_section("shaper"); + carp_sync_xml($carp['synchronizetoip'], $carp['password'], 'shaper', $current_shaper_section); } - /* copy configuration to remote host */ - /* - mwexec("/usr/bin/scp {$files_to_copy} root@{$synchronizetoip}:/tmp/"); - unlink_if_exists("{$g['tmp_path']}/filter_section.txt"); - unlink_if_exists("{$g['tmp_path']}/nat_section.txt"); - unlink_if_exists("{$g['tmp_path']}/aliases_section.txt"); - unlink_if_exists("{$g['tmp_path']}/shaper_section.txt"); - */ - /* execute configuration on remote host */ - mwexec("/usr/bin/scp {$files_to_copy} root@{$synchronizetoip}:/tmp/ && /usr/bin/ssh {$synchronizetoip} /usr/local/pkg/carp_sync_server.php &"); + $msg = new XML_RPC_Message('pfsense.filter_configure', array(new XML_RPC_Value($password, 'string'))); + $cli = new XML_RPC_Client($url, '/xmlrpc.php'); + $cli->setCredentials('admin', $carp['password']); + $cli->send($msg); } } } - +?> -- cgit v1.2.3