From 443e1a9103f1114a9de9bee1f434c4f5f3e9ba86 Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Sat, 2 Apr 2005 06:25:03 +0000 Subject: Bundle all configuration sync requests into a single XMLRPC call. --- packages/carp_sync_client.php | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'packages') diff --git a/packages/carp_sync_client.php b/packages/carp_sync_client.php index a3fdf656..5bbf3c16 100644 --- a/packages/carp_sync_client.php +++ b/packages/carp_sync_client.php @@ -1,3 +1,5 @@ +#!/usr/local/bin/php +setCredentials('admin', $password); @@ -56,24 +58,27 @@ if($already_processed != 1) { foreach($config['installedpackages']['carpsettings']['config'] as $carp) { if($carp['synchronizetoip'] != "" ) { $synchronizetoip = $carp['synchronizetoip']; + $sections = array(); + $sections_xml = array(); if($carp['synchronizerules'] != "" and is_array($config['filter'])) { - $current_rules_section = backup_config_section("filter"); - carp_sync_xml($synchronizetoip, $carp['password'], 'filter', $current_rules_section); + $sections_xml[] = new XML_RPC_Value(backup_config_section("filter"), 'string'); + $sections[] = new XML_RPC_Value('filter', 'string'); } if($carp['synchronizenat'] != "" and is_array($config['nat'])) { - $current_nat_section = backup_config_section("nat"); - carp_sync_xml($synchronizetoip, $carp['password'], 'nat', $current_nat_section); + $sections_xml[] = new XML_RPC_Value(backup_config_section("nat"), 'string'); + $sections[] = new XML_RPC_Value('nat', 'string'); } if($carp['synchronizealiases'] != "" and is_array($config['aliases'])) { - $current_aliases_section = backup_config_section("aliases"); - carp_sync_xml($synchronizetoip, $carp['password'], 'alias', $current_aliases_section); + $sections_xml[] = new XML_RPC_Value(backup_config_section("aliases"), 'string'); + $sections[] = new XML_RPC_Value('aliases', 'string'); } if($carp['synchronizetrafficshaper'] != "" and is_array($config['shaper'])) { - $current_shaper_section = backup_config_section("shaper"); - carp_sync_xml($synchronizetoip, $carp['password'], 'shaper', $current_shaper_section); + $sections_xml[] = new XML_RPC_Value(backup_config_section("shaper"), 'string'); + $sections[] = new XML_RPC_Value('shaper', 'string'); } + carp_sync_xml($synchronizetoip, $carp['password'], $sections, $sections_xml); + $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip); $msg = new XML_RPC_Message('pfsense.filter_configure', array(new XML_RPC_Value($carp['password'], 'string'))); - $cli = new XML_RPC_Client('/xmlrpc.php', $url); $cli->setCredentials('admin', $carp['password']); $cli->send($msg); } -- cgit v1.2.3