summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/util.inc11
-rw-r--r--etc/inc/vslb.inc86
-rwxr-xr-xusr/local/www/load_balancer_pool_edit.php9
-rwxr-xr-xusr/local/www/load_balancer_virtual_server_edit.php5
4 files changed, 78 insertions, 33 deletions
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 3660572..3761a40 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -1030,6 +1030,17 @@ function alias_expand($name) {
return null;
}
+function alias_expand_array($name) {
+ global $aliastable;
+ $result = array();
+ if (isset($aliastable[$name])) {
+ return explode(" ", $aliastable[$name]);
+ }
+ else {
+ return null;
+ }
+}
+
function alias_expand_urltable($name) {
global $config;
$urltable_prefix = "/var/db/aliastables/";
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";
+ }
}
}
}
diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php
index 81a548c..078b61a 100755
--- a/usr/local/www/load_balancer_pool_edit.php
+++ b/usr/local/www/load_balancer_pool_edit.php
@@ -85,8 +85,8 @@ if ($_POST) {
if (strpos($_POST['name'], " ") !== false)
$input_errors[] = gettext("You cannot use spaces in the 'name' field.");
- if (!is_port($_POST['port']))
- $input_errors[] = gettext("The port must be an integer between 1 and 65535.");
+ if (!is_portoralias($_POST['port']))
+ $input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");
// May as well use is_port as we want a positive integer and such.
if (!empty($_POST['retry']) && !is_port($_POST['retry']))
@@ -209,7 +209,10 @@ function clearcombo(){
<td width="22%" valign="top" id="monitorport_text" class="vncellreq"><?=gettext("Port"); ?></td>
<td width="78%" class="vtable" colspan="2">
<input name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="16" maxlength="16"><br>
- <div id="monitorport_desc"><?=gettext("This is the port your servers are listening on."); ?></div>
+ <div id="monitorport_desc">
+ <?=gettext("This is the port your servers are listening on."); ?><br />
+ <?=gettext("You may also specify a port alias listed in Firewall -&gt; Interfaces here."); ?>
+ </div>
</td>
</tr>
<tr align="left">
diff --git a/usr/local/www/load_balancer_virtual_server_edit.php b/usr/local/www/load_balancer_virtual_server_edit.php
index ff59fd9..046e18c 100755
--- a/usr/local/www/load_balancer_virtual_server_edit.php
+++ b/usr/local/www/load_balancer_virtual_server_edit.php
@@ -88,8 +88,8 @@ if ($_POST) {
if (strpos($_POST['name'], " ") !== false)
$input_errors[] = gettext("You cannot use spaces in the 'name' field.");
- if (!is_port($_POST['port']))
- $input_errors[] = gettext("The port must be an integer between 1 and 65535.");
+ if (!is_portoralias($_POST['port']))
+ $input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");
if (!is_ipaddr($_POST['ipaddr']) && !is_subnetv4($_POST['ipaddr']))
$input_errors[] = sprintf(gettext("%s is not a valid IP address or IPv4 subnet."), $_POST['ipaddr']);
@@ -205,6 +205,7 @@ jQuery(document).ready( function() {
<td width="78%" class="vtable" colspan="2">
<input name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="16" maxlength="16">
<br><?=gettext("This is the port that the clients will connect to. All connections to this port will be forwarded to the pool cluster."); ?>
+ <br><?=gettext("You may also specify a port alias listed in Firewall -&gt; Interfaces here."); ?>
</td>
</tr>
<tr align="left">
OpenPOWER on IntegriCloud