diff options
author | Scott Ullrich <sullrich@pfsense.org> | 2005-08-24 20:31:49 +0000 |
---|---|---|
committer | Scott Ullrich <sullrich@pfsense.org> | 2005-08-24 20:31:49 +0000 |
commit | ef217c697e030c484baad455f84f21913d9831e5 (patch) | |
tree | b4b1e67783fb30253110f6e53be2853b96ea396b | |
parent | 37c0c49b4a7335e5dc601e12bd442ee990df595b (diff) | |
download | pfsense-ef217c697e030c484baad455f84f21913d9831e5.zip pfsense-ef217c697e030c484baad455f84f21913d9831e5.tar.gz |
Sync Load Balancer configurations
-rw-r--r-- | etc/inc/filter.inc | 4 | ||||
-rw-r--r-- | etc/inc/system.inc | 118 | ||||
-rw-r--r-- | usr/local/pkg/carp_settings.xml | 6 |
3 files changed, 53 insertions, 75 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index dbff678..c411aea 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -2363,6 +2363,10 @@ function carp_sync_client() { $sections_xml[] = new XML_RPC_Value(backup_vip_config_section(), 'string'); $sections[] = new XML_RPC_Value('virtualip', 'string'); } + if($carp['synchronizelb'] != "" and is_array($config['load_balancer'])) { + $sections_xml[] = new XML_RPC_Value(backup_config_section("load_balancer"), 'string'); + $sections[] = new XML_RPC_Value('load_balancer', 'string'); + } if(count($sections) > 0) { carp_sync_xml($synchronizetoip, $carp['password'], $sections, $sections_xml); $cli = new XML_RPC_Client('/xmlrpc.php', $synchronizetoip); diff --git a/etc/inc/system.inc b/etc/inc/system.inc index a8c4473..e0d6dfb 100644 --- a/etc/inc/system.inc +++ b/etc/inc/system.inc @@ -33,85 +33,53 @@ require_once("functions.inc"); function system_resolvconf_generate($dynupdate = false) { - global $config, $g; - - $syscfg = $config['system']; - - $fd = fopen("{$g['varetc_path']}/resolv.conf.new", "w"); - if (!$fd) { - printf("Error: cannot open resolv.conf.new in system_resolvconf_generate().\n"); - return 1; - } - - $dhfd = @fopen("{$g['etc_path']}/dhclient-enter-hooks", "w"); - if (!$dhfd) { - printf("Error: cannot open dhclient-enter-hooks in system_resolvconf_generate().\n"); - return 1; - } - - - $resolvconf = "domain {$syscfg['domain']}\n"; - - $havedns = false; - - if (isset($syscfg['dnsallowoverride'])) { - /* get dynamically assigned DNS servers for ppp (if any) */ - $nfd = @fopen("{$g['varetc_path']}/nameservers.conf", "r"); - if ($nfd) { - while (!feof($nfd)) { - $dnss = trim(fgets($nfd)); - if ( preg_match('/^(nameserver )(.*)/',$dnss, $catch) ) - $dnss = $catch[2]; - if (is_ipaddr($dnss)) { - $resolvconf .= "nameserver $dnss\n"; - $havedns = true; - } + global $config, $g; + + $syscfg = $config['system']; + + $fd = fopen("{$g['varetc_path']}/resolv.conf", "w"); + if (!$fd) { + printf("Error: cannot open resolv.conf in system_resolvconf_generate().\n"); + return 1; + } + + $resolvconf = "domain {$syscfg['domain']}\n"; + + $havedns = false; + + if (isset($syscfg['dnsallowoverride'])) { + /* get dynamically assigned DNS servers (if any) */ + $nfd = @fopen("{$g['varetc_path']}/nameservers.conf", "r"); + if ($nfd) { + while (!feof($nfd)) { + $dnss = trim(fgets($nfd)); + if ($dnss) { + $resolvconf .= "nameserver $dnss\n"; + $havedns = true; + } + } + fclose($nfd); + } + } + if (!$havedns && is_array($syscfg['dnsserver'])) { + foreach ($syscfg['dnsserver'] as $ns) { + if ($ns) { + $resolvconf .= "nameserver $ns\n"; + $havedns = true; } - fclose($nfd); - } - } - - /* if we didn't get assigned DNS servers and have some set add 'em */ - if (!$havedns && is_array($syscfg['dnsserver'])) { - foreach ($syscfg['dnsserver'] as $ns) { - if ($ns) - $resolvconf .= "nameserver $ns\n"; - $havedns = true; - } - - /* create a dhclient-enter-hooks, so resolv.conf stays intact */ - $dhcliententerhooks = "add_new_resolv_conf() {\n"; - $dhcliententerhooks .= "\techo search {$syscfg['domain']} > \$RESOLV\n"; - foreach ($syscfg['dnsserver'] as $ns) { - if ($ns) - $dhcliententerhooks .= "\techo nameserver $ns > \$RESOLV\n"; - } - $dhcliententerhooks .= "}\n"; - } - - fwrite($dhfd, $dhcliententerhooks); - fclose($dhfd); - - fwrite($fd, $resolvconf); - fclose($fd); - - /* If we now have DNS servers, overwrite resolv.conf */ - if ($havedns) { - if (file_exists("{$g['varetc_path']}/resolv.conf")) - unlink("{$g['varetc_path']}/resolv.conf"); - rename("{$g['varetc_path']}/resolv.conf.new", "{$g['varetc_path']}/resolv.conf"); - } else { - unlink("{$g['varetc_path']}/resolv.conf.new"); - } + } + } + fwrite($fd, $resolvconf); + fclose($fd); - if (!$g['booting']) { - /* restart dhcpd (nameservers may have changed) */ - if (!$dynupdate) - services_dhcpd_configure(); - } + if (!$g['booting']) { + /* restart dhcpd (nameservers may have changed) */ + if (!$dynupdate) + services_dhcpd_configure(); + } - return 0; + return 0; } function system_hosts_generate() { diff --git a/usr/local/pkg/carp_settings.xml b/usr/local/pkg/carp_settings.xml index 134aaf6..325ada8 100644 --- a/usr/local/pkg/carp_settings.xml +++ b/usr/local/pkg/carp_settings.xml @@ -130,6 +130,12 @@ <type>checkbox</type> </field> <field> + <fielddescr>Synchronize Load Balancer</fielddescr> + <fieldname>synchronizelb</fieldname> + <description>When this option is enabled, this system will automatically sync the Load Balancer settings over to the other carp host when changes are made.</description> + <type>checkbox</type> + </field> + <field> <fielddescr>Synchronize Virtual IPs</fielddescr> <fieldname>synchronizevirtualip</fieldname> <description>When this option is enabled, this system will automatically sync the Virtual IP (minus proxyarp) settings over to the other carp host when changes are made.</description> |