summaryrefslogtreecommitdiffstats
path: root/etc/inc/vslb.inc
diff options
context:
space:
mode:
authorDarren Embry <dse@webonastick.com>2012-04-05 14:35:54 -0400
committerDarren Embry <dse@webonastick.com>2012-04-05 14:36:50 -0400
commit01ed452e3253f2883aed00b710d6c5e7c5420305 (patch)
treebd8f60638ea5ca4587d59787069c56eaed06ddd5 /etc/inc/vslb.inc
parent99f6b2a9a2e003304f5d197652ca0f1fe48de0f3 (diff)
downloadpfsense-01ed452e3253f2883aed00b710d6c5e7c5420305.zip
pfsense-01ed452e3253f2883aed00b710d6c5e7c5420305.tar.gz
Load Balancer: allow port aliases in Pools and Virtual Servers. (PEV-394754)
Diffstat (limited to 'etc/inc/vslb.inc')
-rw-r--r--etc/inc/vslb.inc86
1 files changed, 58 insertions, 28 deletions
diff --git a/etc/inc/vslb.inc b/etc/inc/vslb.inc
index d6d9931..7d3cf05 100644
--- a/etc/inc/vslb.inc
+++ b/etc/inc/vslb.inc
@@ -259,49 +259,79 @@ function relayd_configure($kill_first=false) {
if(is_array($vs_a)) {
for ($i = 0; isset($vs_a[$i]); $i++) {
+
+ $append_port_to_name = false;
+ if (is_alias($vs_a[$i]['port'])) {
+ $src_port_array = alias_expand_array($vs_a[$i]['port']);
+ $append_port_to_name = true;
+ }
+ else {
+ $src_port_array = array($vs_a[$i]['port']);
+ }
+ if (is_alias($pools[$vs_a[$i]['pool']]['port'])) {
+ $dest_port_array = alias_expand_array($pools[$vs_a[$i]['pool']]['port']);
+ $append_port_to_name = true;
+ }
+ else {
+ $dest_port_array = array($pools[$vs_a[$i]['pool']]['port']);
+ }
+
+ $append_ip_to_name = false;
if (is_subnetv4($vs_a[$i]['ipaddr'])) {
$ip_list = subnetv4_expand($vs_a[$i]['ipaddr']);
- $name_format = "%s_%d";
+ $append_ip_to_name = true;
}
else {
$ip_list = array($vs_a[$i]['ipaddr']);
- $name_format = "%s"; /* in which case the second arg of the sprintf call below will be silently ignored */
}
+
for ($j = 0; $j < count($ip_list); $j += 1) {
$ip = $ip_list[$j];
- $name = sprintf($name_format, $vs_a[$i]['name'], $j);
- if (($vs_a[$i]['mode'] == 'relay') || ($vs_a[$i]['relay_protocol'] == 'dns')) {
- $conf .= "relay \"{$name}\" {\n";
- $conf .= " listen on {$ip} port {$vs_a[$i]['port']}\n";
-
- if ($vs_a[$i]['relay_protocol'] == "dns") {
- $conf .= " protocol \"dnsproto\"\n";
- } else {
- $conf .= " protocol \"{$vs_a[$i]['relay_protocol']}\"\n";
+ for ($k = 0; $k < count($src_port_array) && $k < count($dest_port_array); $k += 1) {
+ $src_port = $src_port_array[$k];
+ $dest_port = $dest_port_array[$k];
+
+ $name = $vs_a[$i]['name'];
+ if ($append_ip_to_name) {
+ $name .= "_" . $j;
}
- $lbmode = "";
- if ( $pools[$vs_a[$i]['pool']]['mode'] == "loadbalance" ) {
- $lbmode = "mode loadbalance";
+ if ($append_port_to_name) {
+ $name .= "_" . $src_port;
}
- $conf .= " forward to <{$vs_a[$i]['pool']}> port {$pools[$vs_a[$i]['pool']]['port']} {$lbmode} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
+ if (($vs_a[$i]['mode'] == 'relay') || ($vs_a[$i]['relay_protocol'] == 'dns')) {
+ $conf .= "relay \"{$name}\" {\n";
+ $conf .= " listen on {$ip} port {$src_port}\n";
- if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0)
- $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$pools[$vs_a[$i]['pool']]['port']} {$lbmode} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
- $conf .= "}\n";
- } else {
- $conf .= "redirect \"{$name}\" {\n";
- $conf .= " listen on {$ip} port {$vs_a[$i]['port']}\n";
- $conf .= " forward to <{$vs_a[$i]['pool']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
+ if ($vs_a[$i]['relay_protocol'] == "dns") {
+ $conf .= " protocol \"dnsproto\"\n";
+ } else {
+ $conf .= " protocol \"{$vs_a[$i]['relay_protocol']}\"\n";
+ }
+ $lbmode = "";
+ if ( $pools[$vs_a[$i]['pool']]['mode'] == "loadbalance" ) {
+ $lbmode = "mode loadbalance";
+ }
- if (isset($config['system']['lb_use_sticky']))
- $conf .= " sticky-address\n";
+ $conf .= " forward to <{$vs_a[$i]['pool']}> port {$dest_port} {$lbmode} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
- /* sitedown MUST use the same port as the primary pool - sucks, but it's a relayd thing */
- if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0)
- $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$pools[$vs_a[$i]['pool']]['port']} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
+ if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0)
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$dest_port} {$lbmode} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
+ $conf .= "}\n";
+ } else {
+ $conf .= "redirect \"{$name}\" {\n";
+ $conf .= " listen on {$ip} port {$src_port}\n";
+ $conf .= " forward to <{$vs_a[$i]['pool']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
- $conf .= "}\n";
+ if (isset($config['system']['lb_use_sticky']))
+ $conf .= " sticky-address\n";
+
+ /* sitedown MUST use the same port as the primary pool - sucks, but it's a relayd thing */
+ if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0)
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['pool']]['monitor']]} \n";
+
+ $conf .= "}\n";
+ }
}
}
}
OpenPOWER on IntegriCloud