aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Smith <colin@pfsense.org>2005-03-31 01:52:18 +0000
committerColin Smith <colin@pfsense.org>2005-03-31 01:52:18 +0000
commitdd5f6c0187b0c91ff7b09c48d55a8c19720af344 (patch)
tree143913d0ba8978feb656d523ce569516735c5599
parent3cee841b6a9ac0c25a597d496d9d6c18735bd5cc (diff)
downloadpfsense-packages-dd5f6c0187b0c91ff7b09c48d55a8c19720af344.tar.gz
pfsense-packages-dd5f6c0187b0c91ff7b09c48d55a8c19720af344.tar.bz2
pfsense-packages-dd5f6c0187b0c91ff7b09c48d55a8c19720af344.zip
Use new XMLRPC code for CARP sync - honest!
-rw-r--r--packages/carp_sync_client.php54
1 files 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
+<?php
/*
carp_sync.php
part of pfSense (www.pfSense.com)
@@ -36,8 +37,16 @@ require_once("xmlparse_pkg.inc"); // Include pfSense helper functions.
require_once("config.inc");
require_once("functions.inc");
-function carp_sync_xml($url, $password, $section, $section_xml) {
- $params = array(new XML_R
+function carp_sync_xml($url, $password, $section, $section_xml, $method = 'pfsense.restore_config_section') {
+ $params = array(new XML_RPC_Value($password, 'string'),
+ new XML_RPC_Value($section, 'string'),
+ new XML_RPC_Value($section_xml, 'string'));
+ $msg = new XML_RPC_Message($method, $params);
+ $cli = new XML_RPC_Client($url, '/xmlrpc.php');
+ $cli->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("<?xml version=\"1.0\"?>", "", $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("<?xml version=\"1.0\"?>", "", $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("<?xml version=\"1.0\"?>", "", $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("<?xml version=\"1.0\"?>", "", $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);
}
}
}
-
+?>