From 94ac0ffc7d5cb760691bb9d720e3d0b233ff7591 Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Sat, 6 Aug 2005 18:46:23 +0000 Subject: Preview commit of load balancer pools - needs much loving by Hoba and Esotericisms :) --- usr/local/www/load_balancer_pool.php | 157 ++++++++++++++++++++++++++ usr/local/www/load_balancer_pool_edit.php | 179 ++++++++++++++++++++++++++++++ 2 files changed, 336 insertions(+) create mode 100755 usr/local/www/load_balancer_pool.php create mode 100755 usr/local/www/load_balancer_pool_edit.php (limited to 'usr') diff --git a/usr/local/www/load_balancer_pool.php b/usr/local/www/load_balancer_pool.php new file mode 100755 index 0000000..d99e638 --- /dev/null +++ b/usr/local/www/load_balancer_pool.php @@ -0,0 +1,157 @@ +#!/usr/local/bin/php +. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); + +if (!is_array($config['load_balancer']['pool'])) { + $config['load_balancer']['pool'] = array(); +} +$a_pool = &$config['load_balancer']['pool']; + +if ($_POST) { + $pconfig = $_POST; + + if ($_POST['apply']) { + $retval = 0; + if (!file_exists($d_sysrebootreqd_path)) { + config_lock(); + $retval |= filter_configure(); + config_unlock(); + } + $savemsg = get_std_save_message($retval); + //unlink_if_exists($d_poolconfdirty_path); + } +} + +if ($_GET['act'] == "del") { + if ($a_pool[$_GET['id']]) { + /* make sure no virtual servers reference this entry */ + if (is_array($config['load_balancer']['virtual_server'])) { + foreach ($config['load_balancer']['virtual_server'] as $vs) { + if ($vs['pool'] == $a_pool[$_GET['id']]['name']) { + $input_errors[] = "This entry cannot be deleted because it is still referenced by at least one virtual server."; + break; + } + } + } + + if (!$input_errors) { + unset($a_pool[$_GET['id']]); + write_config(); + touch($d_poolconfdirty_path); + header("Location: load_balancer_pool.php"); + exit; + } + } +} + +$pgtitle = "Load Balancer: Pool"; +include("head.inc"); + +?> + + +

+
+ + +

+You must apply the changes in order for them to take effect.");?>
+ + + + +
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + +
NameServersPortMonitorDescription
+ + + +
+ +
+ + + + + + + + + + + +
+
+ + + + +
+
+
+
+

+ + + diff --git a/usr/local/www/load_balancer_pool_edit.php b/usr/local/www/load_balancer_pool_edit.php new file mode 100755 index 0000000..89b5437 --- /dev/null +++ b/usr/local/www/load_balancer_pool_edit.php @@ -0,0 +1,179 @@ +#!/usr/local/bin/php +. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ + +require("guiconfig.inc"); +if (!is_array($config['load_balancer']['pool'])) { + $config['load_balancer']['pool'] = array(); +} +$a_pool = &$config['load_balancer']['pool']; + +if (isset($_POST['id'])) + $id = $_POST['id']; +else + $id = $_GET['id']; + +if (isset($id) && $a_pool[$id]) { + $pconfig['name'] = $a_pool[$id]['name']; + $pconfig['desc'] = $a_pool[$id]['desc']; + $pconfig['port'] = $a_pool[$id]['port']; + $pconfig['servers'] = $a_pool[$id]['servers']; + $pconfig['monitor'] = $a_pool[$id]['monitor']; +} + +if ($_POST) { +echo "
";
+print_r($_POST);
+echo "
"; + unset($input_errors); + $pconfig = $_POST; + + /* input validation */ +// $reqdfields = explode(" ", "name"); +// $reqdfieldsn = explode(",", "Name"); + +// do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors); + + if (($_POST['subnet'] && !is_ipaddr($_POST['subnet']))) { + $input_errors[] = "A valid IP address must be specified."; + } + + if ($_POST['ipaddr'] == $config['interfaces']['wan']['ipaddr']) + $input_errors[] = "The WAN IP address may not be used in a virtual entry."; + + if ($_POST['ipaddr'] == $config['interfaces']['lan']['ipaddr']) + $input_errors[] = "The LAN IP address may not be used in a virtual entry."; + + /* check for overlaps with other virtual IP */ + foreach ($a_pool as $poolent) { + if (isset($id) && ($a_pool[$id]) && ($a_pool[$id] === $poolent)) + continue; + + if (isset($_POST['subnet']) && $_POST['subnet'] == $poolent['subnet']) { + $input_errors[] = "There is already a virtual IP entry for the specified IP address."; + break; + } + } + + /* check for overlaps with 1:1 NAT */ + if (is_array($config['nat']['onetoone'])) { + foreach ($config['nat']['onetoone'] as $natent) { + if (check_subnets_overlap($_POST['ipaddr'], 32, $natent['external'], $natent['subnet'])) { + $input_errors[] = "A 1:1 NAT mapping overlaps with the specified IP address."; + break; + } + } + } + + if (!$input_errors) { + $poolent = array(); + + $poolent['name'] = $_POST['name']; + $poolent['desc'] = $_POST['desc']; + $poolent['port'] = $_POST['port']; + $poolent['servers'] = $_POST['servers']; + $poolent['monitor'] = $_POST['monitor']; + + if (isset($id) && $a_pool[$id]) { + /* modify all virtual IP rules with this name */ + for ($i = 0; isset($config['load_balancer']['virtual_server'][$i]); $i++) { + if ($config['load_balancer']['virtual_server'][$i]['pool'] == $a_pool[$id]['name']) + $config['load_balancer']['virtual_server'][$i]['pool'] = $poolent['name']; + } + $a_pool[$id] = $poolent; + } else + $a_pool[] = $poolent; + +echo "
";
+print_r($poolent);
+echo "
"; + touch($d_poolconfdirty_path); + + write_config(); + + header("Location: load_balancer_pool.php"); + exit; + } +} + +$pgtitle = "Load Balancer: Pool: Edit"; +include("head.inc"); + +?> + + + +

+ +
+ + + + + + + + + + + + + + + + +
+ Name: size="16" maxlength="16"> +
+ Description: size="64"> +
+ Port: size="16" maxlength="16"> +
+ IP + + + + + List: + +
+ +
+ + + -- cgit v1.1