From 3d3589663ac9069fd623105154751c732d628519 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Sat, 12 Mar 2005 20:23:49 +0000 Subject: Initial rule sync between two hosts code. --- packages/carp_settings.xml | 30 +++++++++++++++++++++++++++ packages/carp_sync_client.php | 48 +++++++++++++++++++++++++++++++++++++++++++ packages/carp_sync_server.php | 41 ++++++++++++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) create mode 100644 packages/carp_sync_client.php create mode 100644 packages/carp_sync_server.php diff --git a/packages/carp_settings.xml b/packages/carp_settings.xml index f18accb3..befd3049 100644 --- a/packages/carp_settings.xml +++ b/packages/carp_settings.xml @@ -80,6 +80,36 @@ When preemption is enabled, each CARP host will look at the advskew (Advertising Frequency) parameter in the advertisements it receives from the master, to try to determine whether it can advertise more frequently. If so, it will begin advertising, and the current master, seeing that there is another host with a lower advskew, will bow out. checkbox + + + Synchronize rules + synchronizerules + When this option is enabled, this system will automatically sync the firewalls rules over to the other carp host every 5 minutes. + checkbox + + + Synchronize to IP + synchronizetoip + Enter the IP address of the firewall you would like to synchornize your rules to. + input + + + Known Hosts + knownhosts + Paste in your authorized hosts file generated from OpenSSH. + 4 + 50 + textarea + + + Authorized Keys + authorizedkeys + Paste in your Authorized Keys file generated from OpenSSH. + 4 + 50 + textarea + + diff --git a/packages/carp_sync_client.php b/packages/carp_sync_client.php new file mode 100644 index 00000000..7f91efca --- /dev/null +++ b/packages/carp_sync_client.php @@ -0,0 +1,48 @@ +#!/usr/bin/php + "") { + /* lets sync! */ + $synchronizetoip = $carp['synchronizetoip']; + $current_rules_section = backup_config_section("rules"); + $fout = fopen("{$g['tmp_path']}/rules_section.txt","w"); + fwrite($fout, $current_rules_section); + fclose($fout); + /* copy configuration to remote host */ + mwexec("/usr/bin/scp {$g['tmp_path']}/rules_section.txt root@{$synchronizetoip}:/tmp/"); + mwexec("/usr/bin/ssh /usr/local/pkg/carp_sync_server.php"); + } + +?> diff --git a/packages/carp_sync_server.php b/packages/carp_sync_server.php new file mode 100644 index 00000000..02dbf483 --- /dev/null +++ b/packages/carp_sync_server.php @@ -0,0 +1,41 @@ +#!/usr/bin/php + "") { + $rules = return_filename_as_string("{$g['tmp_path']}/rules_section.txt"); + restore_config_section("rules", $rules); + } + +?> -- cgit v1.2.3