aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorthompsa <andy@fud.org.nz>2010-02-07 23:41:35 +1300
committerthompsa <andy@fud.org.nz>2010-02-08 00:21:14 +1300
commit51f497343aaff857e82115a27db9010435a43105 (patch)
tree9bf0d8d6e842c1f0a06b5335353fa3dcc1dcbfa7
parent0540ee6a327744a417c5be282885093576fdd720 (diff)
downloadpfsense-packages-51f497343aaff857e82115a27db9010435a43105.tar.gz
pfsense-packages-51f497343aaff857e82115a27db9010435a43105.tar.bz2
pfsense-packages-51f497343aaff857e82115a27db9010435a43105.zip
Add server pools which encapsulate the backends.
-rw-r--r--config/haproxy-dev/haproxy.inc72
-rw-r--r--config/haproxy-dev/haproxy.xml12
-rwxr-xr-xconfig/haproxy-dev/haproxy_global.php4
-rwxr-xr-xconfig/haproxy-dev/haproxy_listeners.php28
-rwxr-xr-xconfig/haproxy-dev/haproxy_listeners_edit.php28
-rwxr-xr-xconfig/haproxy-dev/haproxy_pool_edit.php270
-rwxr-xr-xconfig/haproxy-dev/haproxy_pools.php92
-rwxr-xr-xconfig/haproxy-dev/haproxy_servers_edit.php431
8 files changed, 226 insertions, 711 deletions
diff --git a/config/haproxy-dev/haproxy.inc b/config/haproxy-dev/haproxy.inc
index 2d7b671f..4ab000da 100644
--- a/config/haproxy-dev/haproxy.inc
+++ b/config/haproxy-dev/haproxy.inc
@@ -101,8 +101,7 @@ function haproxy_configure() {
$a_global = &$config['installedpackages']['haproxy'];
$a_backends = &$config['installedpackages']['haproxy']['ha_backends']['item'];
- $a_frontends = &$config['installedpackages']['haproxy']['ha_frontends']['item'];
- $a_servers = &$config['installedpackages']['haproxy']['ha_servers']['item'];
+ $a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item'];
$fd = fopen("{$g['varetc_path']}/haproxy.cfg", "w");
@@ -170,7 +169,7 @@ function haproxy_configure() {
$httpchk = "httpchk";
}
- fwrite ($fd, "\tmode\t\t\t" . $backend_type . "\n");
+ fwrite ($fd, "\tmode\t\t\t" . $backend_type . "\n");
fwrite ($fd, "\tlog\t\t\tglobal\n");
fwrite ($fd, "\toption\t\t\tdontlognull\n");
@@ -198,11 +197,6 @@ function haproxy_configure() {
if($backend['retries'])
fwrite ($fd, "\tretries\t\t\t" . $backend['retries'] . "\n");
- if($backend['cookie_name'])
- fwrite ($fd, "\tcookie\t\t\t" . $backend['cookie_name'] . " insert indirect\n");
-
- fwrite ($fd, "\toption\t\t\t{$httpchk} HEAD " . $backend['monitor_uri'] . " HTTP/1.0\n");
-
if($backend['stats_enabled']=='yes') {
fwrite ($fd, "\tstats\t\t\tenable\n");
if($backend['stats_uri'])
@@ -245,40 +239,34 @@ function haproxy_configure() {
fwrite ($fd, "\tacl\t\t\t".$acl['name']."\t".$expr."\n");
}
- $server['backend'] .= " ";
- if(is_array($a_servers)) {
- foreach ($a_servers as $server) {
- $backends_to_process = split(" ", $server['backend']);
- foreach($backends_to_process as $backends) {
- if($backends == "")
- continue;
- if($backends == $backend['name']) {
- $server_ports = array();
- if($server['status']=='active') {
- if($server['cookie'])
- $cookie = " cookie {$server['cookie']} ";
- else
- $cookie = "";
- if(!$server['port']) {
- foreach($ports as $port) {
- if($port)
- $server_ports[] = $port;
- }
- } else {
- $server_ports[] = $server['port'];
- }
- if($server['advanced']) {
- $advanced = base64_decode($server['advanced']);
- $advanced_txt = " " . $advanced;
- } else {
- $advanced_txt = "";
- }
- if($server['checkinter'])
- $checkinter = "check inter {$server['checkinter']}";
- else
- $checkinter = "check inter 1000";
- foreach($server_ports as $pport)
- fwrite ($fd, "\tserver\t\t\t" . $server['name'] . " " . $server['address'].":" . $pport . " $cookie " . " $checkinter weight " . $server['weight'] . "{$advanced_txt}\n");
+ if (is_array($a_pools)) {
+ foreach ($a_pools as $pool) {
+ if ($backend['pool'] == $pool['name'] && is_array($pool['ha_servers']['item'])) {
+ if($pool['status']=='active') {
+ if($pool['cookie_name'])
+ fwrite ($fd, "\tcookie\t\t\t" . $pool['cookie_name'] . " insert indirect\n");
+
+ fwrite ($fd, "\toption\t\t\t{$httpchk} HEAD " . $pool['monitor_uri'] . " HTTP/1.0\n");
+
+ if($pool['cookie'])
+ $cookie = " cookie {$pool['cookie']} ";
+ else
+ $cookie = "";
+ if($pool['advanced']) {
+ $advanced = base64_decode($pool['advanced']);
+ $advanced_txt = " " . $advanced;
+ } else {
+ $advanced_txt = "";
+ }
+ if($pool['checkinter'])
+ $checkinter = "check inter {$pool['checkinter']}";
+ else
+ $checkinter = "check inter 1000";
+ $a_servers = &$pool['ha_servers']['item'];
+ foreach($a_servers as $be) {
+ if(!$be['port'])
+ $be['port'] = $backend['port'];
+ fwrite ($fd, "\tserver\t\t\t" . $be['address'] . " " . $be['address'].":" . $be['port'] . " $cookie " . " $checkinter weight " . $be['weight'] . "{$advanced_txt}\n");
}
}
}
diff --git a/config/haproxy-dev/haproxy.xml b/config/haproxy-dev/haproxy.xml
index f0e13a27..04c1c0bc 100644
--- a/config/haproxy-dev/haproxy.xml
+++ b/config/haproxy-dev/haproxy.xml
@@ -44,13 +44,13 @@
<name>haproxy</name>
<version>1.0</version>
<title>HAProxy</title>
- <aftersaveredirect>/pkg_ediwt.php?xml=haproxy_servers.php</aftersaveredirect>
+ <aftersaveredirect>/pkg_ediwt.php?xml=haproxy_pools.php</aftersaveredirect>
<include_file>/usr/local/pkg/haproxy.inc</include_file>
<menu>
<name>HAProxy</name>
<tooltiptext></tooltiptext>
<section>Services</section>
- <url>/haproxy_frontends.php</url>
+ <url>/haproxy_listeners.php</url>
</menu>
<service>
<name>HAProxy</name>
@@ -67,12 +67,12 @@
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_frontends.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_listeners.php</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_frontends_edit.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_listeners_edit.php</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
@@ -82,12 +82,12 @@
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_servers.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_pools.php</item>
</additional_files_needed>
<additional_files_needed>
<prefix>/usr/local/www/</prefix>
<chmod>077</chmod>
- <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_servers_edit.php</item>
+ <item>http://www.pfsense.com/packages/config/haproxy-dev/haproxy_pool_edit.php</item>
</additional_files_needed>
<custom_delete_php_command>
</custom_delete_php_command>
diff --git a/config/haproxy-dev/haproxy_global.php b/config/haproxy-dev/haproxy_global.php
index dddb0413..9de45fdb 100755
--- a/config/haproxy-dev/haproxy_global.php
+++ b/config/haproxy-dev/haproxy_global.php
@@ -133,8 +133,8 @@ function enable_change(enable_change) {
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", true, "haproxy_global.php");
- $tab_array[] = array("Listener", false, "haproxy_frontends.php");
- $tab_array[] = array("Server Pool", false, "haproxy_servers.php");
+ $tab_array[] = array("Listener", false, "haproxy_listeners.php");
+ $tab_array[] = array("Server Pool", false, "haproxy_pools.php");
display_top_tabs($tab_array);
?>
</td></tr>
diff --git a/config/haproxy-dev/haproxy_listeners.php b/config/haproxy-dev/haproxy_listeners.php
index 87efb87f..3a8d6701 100755
--- a/config/haproxy-dev/haproxy_listeners.php
+++ b/config/haproxy-dev/haproxy_listeners.php
@@ -54,14 +54,14 @@ if ($_POST) {
}
if ($_GET['act'] == "del") {
- if ($a_backend[$_GET['id']]) {
+ if (isset($a_backend[$_GET['id']])) {
if (!$input_errors) {
unset($a_backend[$_GET['id']]);
write_config();
touch($d_haproxyconfdirty_path);
- header("Location: haproxy_frontends.php");
- exit;
}
+ header("Location: haproxy_listeners.php");
+ exit;
}
}
@@ -75,7 +75,7 @@ include("head.inc");
?>
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
<?php include("fbegin.inc"); ?>
-<form action="haproxy_frontends.php" method="post">
+<form action="haproxy_listeners.php" method="post">
<?php if($one_two): ?>
<p class="pgtitle"><?=$pgtitle?></p>
<?php endif; ?>
@@ -90,8 +90,8 @@ include("head.inc");
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Listener", true, "haproxy_frontends.php");
- $tab_array[] = array("Server Pool", false, "haproxy_servers.php");
+ $tab_array[] = array("Listener", true, "haproxy_listeners.php");
+ $tab_array[] = array("Server Pool", false, "haproxy_pools.php");
display_top_tabs($tab_array);
?>
</td></tr>
@@ -103,24 +103,28 @@ include("head.inc");
<td width="30%" class="listhdrr">Name</td>
<td width="40%" class="listhdrr">Description</td>
<td width="10%" class="listhdrr">Type</td>
+ <td width="10%" class="listhdrr">Server pool</td>
<td width="10%" class="list"></td>
</tr>
<?php $i = 0; foreach ($a_backend as $backend): ?>
<tr>
- <td class="listlr" ondblclick="document.location='haproxy_frontends_edit.php?id=<?=$i;?>';">
+ <td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$i;?>';">
<?=$backend['name'];?>
</td>
- <td class="listlr" ondblclick="document.location='haproxy_frontends_edit.php?id=<?=$i;?>';">
+ <td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$i;?>';">
<?=$backend['desc'];?>
</td>
- <td class="listlr" ondblclick="document.location='haproxy_frontends_edit.php?id=<?=$i;?>';">
+ <td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$i;?>';">
<?=$backend['type'];?>
</td>
+ <td class="listlr" ondblclick="document.location='haproxy_listeners_edit.php?id=<?=$i;?>';">
+ <?=$backend['pool'];?>
+ </td>
<td class="list" nowrap>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="haproxy_frontends_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="haproxy_frontends.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_listeners_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_listeners.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
</td>
@@ -131,7 +135,7 @@ include("head.inc");
<td class="list">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="haproxy_frontends_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_listeners_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
</td>
diff --git a/config/haproxy-dev/haproxy_listeners_edit.php b/config/haproxy-dev/haproxy_listeners_edit.php
index c60415e3..91635260 100755
--- a/config/haproxy-dev/haproxy_listeners_edit.php
+++ b/config/haproxy-dev/haproxy_listeners_edit.php
@@ -1,7 +1,7 @@
<?php
/* $Id: load_balancer_pool_edit.php,v 1.24.2.23 2007/03/03 00:07:09 smos Exp $ */
/*
- haproxy_frontends_edit.php
+ haproxy_listeners_edit.php
part of pfSense (http://www.pfsense.com/)
Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.com>
Copyright (C) 2008 Remco Hoef <remcoverhoef@pfsense.com>
@@ -38,6 +38,7 @@ if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
}
$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
+$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item'];
$a_expr = array();
$a_expr[] = array("host_starts_with", "Host starts with:", "HTTP");
@@ -79,6 +80,7 @@ if (isset($id) && $a_backend[$id]) {
$pconfig['type'] = $a_backend[$id]['type'];
$pconfig['extaddr'] = $a_backend[$id]['extaddr'];
+ $pconfig['pool'] = $a_backend[$id]['pool'];
$pconfig['max_connections'] = $a_backend[$id]['max_connections'];
$pconfig['client_timeout'] = $a_backend[$id]['client_timeout'];
$pconfig['port'] = $a_backend[$id]['port'];
@@ -245,6 +247,7 @@ if ($_POST) {
update_if_changed("type", $backend['type'], $_POST['type']);
update_if_changed("port", $backend['port'], $_POST['port']);
update_if_changed("extaddr", $backend['extaddr'], $_POST['extaddr']);
+ update_if_changed("pool", $backend['pool'], $_POST['pool']);
update_if_changed("max_connections", $backend['max_connections'], $_POST['max_connections']);
update_if_changed("client_timeout", $backend['client_timeout'], $_POST['client_timeout']);
update_if_changed("advanced", $backend['advanced'], base64_encode($_POST['advanced']));
@@ -262,7 +265,7 @@ if ($_POST) {
write_config($changedesc);
}
- header("Location: haproxy_frontends.php");
+ header("Location: haproxy_listeners.php");
exit;
}
}
@@ -384,7 +387,7 @@ include("head.inc");
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if($one_two): ?>
<p class="pgtitle"><?=$pgtitle?></p>
-<form action="haproxy_frontends_edit.php" method="post" name="iform" id="iform">
+<form action="haproxy_listeners_edit.php" method="post" name="iform" id="iform">
<?php endif; ?>
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
@@ -449,8 +452,8 @@ include("head.inc");
<td width="78%" class="vtable">
<select name="pool" class="formfld">
<?php
- if (is_array($pconfig['ha_pools']['item'])) {
- foreach ($config['ha_pools']['item'] as $p):
+ if (is_array($a_pools)) {
+ foreach ($a_pools as $p):
?>
<option value="<?=$p['name'];?>" <?php if ($p['name'] == $pconfig['pool']) echo "selected"; ?>>
<?=htmlspecialchars("{$p['name']}");?>
@@ -499,24 +502,24 @@ include("head.inc");
$a_acl=array();
}
- $i=0;
+ $counter=0;
foreach ($a_acl as $acl) {
?>
<tr>
- <td><input name="acl_name<?=$i;?>" type="text" value="<?=$acl['name']; ?>" size="20"/></td>
+ <td><input name="acl_name<?=$counter;?>" type="text" value="<?=$acl['name']; ?>" size="20"/></td>
<td>
- <select name="acl_expression<?=$i;?>" id="acl_expression<?=$i;?>">
+ <select name="acl_expression<?=$counter;?>" id="acl_expression<?=$counter;?>">
<?php
foreach ($a_expr as $expr) { ?>
<option value="<?=$expr[0];?>"<?php if($acl['expression'] == $expr[0]) echo " SELECTED"; ?>><?=$expr[1];?></option>
<?php } ?>
</select>
</td>
- <td><input name="acl_value<?=$i;?>" type="text" value="<?=$acl['value']; ?>" size="35"/></td>
+ <td><input name="acl_value<?=$counter;?>" type="text" value="<?=$acl['value']; ?>" size="35"/></td>
<td class="list"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" onclick="removeRow(this); return false;"></td>
</tr>
<?php
- $i++;
+ $counter++;
}
?>
</table>
@@ -689,9 +692,8 @@ set by the 'retries' parameter (2).</div>
<script type="text/javascript">
field_counter_js = 3;
rows = 1;
- <?php $counter=0; ?>
- totalrows = <?php echo $counter; ?>;;
- loaded = <?php echo $counter; ?>;;
+ totalrows = <?php echo $counter; ?>;
+ loaded = <?php echo $counter; ?>;
</script>
<?php include("fend.inc"); ?>
</body>
diff --git a/config/haproxy-dev/haproxy_pool_edit.php b/config/haproxy-dev/haproxy_pool_edit.php
index 63f15741..9044e930 100755
--- a/config/haproxy-dev/haproxy_pool_edit.php
+++ b/config/haproxy-dev/haproxy_pool_edit.php
@@ -1,7 +1,7 @@
<?php
/* $Id: load_balancer_pool_edit.php,v 1.24.2.23 2007/03/03 00:07:09 smos Exp $ */
/*
- haproxy_servers_edit.php
+ haproxy_pool_edit.php
part of pfSense (http://www.pfsense.com/)
Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.com>
Copyright (C) 2008 Remco Hoef <remcoverhoef@pfsense.com>
@@ -34,30 +34,28 @@ require("guiconfig.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
-if (!is_array($config['installedpackages']['haproxy']['ha_servers']['item'])) {
- $config['installedpackages']['haproxy']['ha_servers']['item'] = array();
+if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) {
+ $config['installedpackages']['haproxy']['ha_pools']['item'] = array();
}
-$a_server = &$config['installedpackages']['haproxy']['ha_servers']['item'];
+$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item'];
if (isset($_POST['id']))
$id = $_POST['id'];
else
$id = $_GET['id'];
-if (isset($id) && $a_server[$id]) {
- $pconfig['name'] = $a_server[$id]['name'];
- $pconfig['address'] = $a_server[$id]['address'];
- $pconfig['port'] = $a_server[$id]['port'];
- $pconfig['backend'] = $a_server[$id]['backend'];
- $pconfig['weight'] = $a_server[$id]['weight'];
- $pconfig['checkinter'] = $a_server[$id]['checkinter'];
- $pconfig['cookie'] = $a_server[$id]['cookie'];
- $pconfig['status'] = $a_server[$id]['status'];
- $pconfig['advanced'] = base64_decode($a_server[$id]['advanced']);
+if (isset($id) && $a_pools[$id]) {
+ $pconfig['name'] = $a_pools[$id]['name'];
+ $pconfig['checkinter'] = $a_pools[$id]['checkinter'];
+ $pconfig['monitor_uri'] = $a_pools[$id]['monitor_uri'];
+ $pconfig['cookie'] = $a_pools[$id]['cookie'];
+ $pconfig['status'] = $a_pools[$id]['status'];
+ $pconfig['advanced'] = base64_decode($a_pools[$id]['advanced']);
+ $pconfig['a_servers']=&$a_pools[$id]['ha_servers']['item'];
}
-$changedesc = "Services: HAProxy: Servers: ";
+$changedesc = "Services: HAProxy: pools: ";
$changecount = 0;
if ($_POST) {
@@ -66,71 +64,62 @@ if ($_POST) {
unset($input_errors);
$pconfig = $_POST;
- $reqdfields = explode(" ", "name address weight");
- $reqdfieldsn = explode(",", "Name,Address,Weight");
+ $reqdfields = explode(" ", "name");
+ $reqdfieldsn = explode(",", "Name");
do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['name']))
$input_errors[] = "The field 'Name' contains invalid characters.";
- if (preg_match("/[^a-zA-Z0-9\.]/", $_POST['address']))
- $input_errors[] = "The field 'Address' contains invalid characters.";
+ /* Ensure that our pool names are unique */
+ for ($i=0; isset($config['installedpackages']['haproxy']['ha_pools']['item'][$i]); $i++)
+ if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_pools']['item'][$i]['name']) && ($i != $id))
+ $input_errors[] = "This pool name has already been used. Pool names must be unique.";
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['cookie']))
- $input_errors[] = "The field 'Cookie' contains invalid characters.";
+ $a_servers=array();
+ for($x=0; $x<99; $x++) {
+ $server_address=$_POST['server_address'.$x];
+ $server_port=$_POST['server_port'.$x];
+ $server_weight=$_POST['server_weight'.$x];
- if ($_POST['port'] && !is_numeric($_POST['port']))
- $input_errors[] = "The field 'Port' value is not a number.";
- else {
- if ($_POST['port'])
- if (!($_POST['port']>=1 && $_POST['port']<=65535))
- $input_errors[] = "The field 'Port' value must be between 1 and 65535.";
- }
-
- if (!is_numeric($_POST['weight']))
- $input_errors[] = "The field 'Weight' value is not a number.";
- else {
- if (!($_POST['weight']>=1 && $_POST['weight']<=256))
- $input_errors[] = "The field 'Weight' value must be between 1 and 256.";
- }
-
- /* Ensure that our pool names are unique */
- for ($i=0; isset($config['installedpackages']['haproxy']['ha_servers']['item'][$i]); $i++)
- if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_servers']['item'][$i]['name']) && ($i != $id))
- $input_errors[] = "This server name has already been used. Server names must be unique.";
-
- $backend = "";
- for($x=0; $x<299; $x++) {
- $comd = "\$backends = \$_POST['backend" . $x . "'];";
- eval($comd);
- if($backends)
- $backend .= "$backends ";
+ if ($server_address) {
+
+ $server=array();
+ $server['address']=$server_address;
+ $server['port']=$server_port;
+ $server['weight']=$server_weight;
+ $a_servers[]=$server;
+
+ if (preg_match("/[^a-zA-Z0-9\.\-_]/", $server_address))
+ $input_errors[] = "The field 'Address' contains invalid characters.";
+
+ if (!preg_match("/.{2,}/", $server_weight))
+ $input_errors[] = "The field 'Weight' is required.";
+
+ }
}
- $backend = trim($backend);
if (!$input_errors) {
- $server = array();
- if(isset($id) && $a_server[$id])
- $server = $a_server[$id];
+ $pool = array();
+ if(isset($id) && $a_pools[$id])
+ $pool = $a_pools[$id];
- if($server['name'] != "")
- $changedesc .= " modified '{$server['name']}' pool:";
-
- update_if_changed("name", $server['name'], $_POST['name']);
- update_if_changed("port", $server['port'], $_POST['port']);
- update_if_changed("backend", $server['backend'], $backend);
- update_if_changed("cookie", $server['cookie'], $_POST['cookie']);
- update_if_changed("weight", $server['weight'], $_POST['weight']);
- update_if_changed("status", $server['status'], $_POST['status']);
- update_if_changed("address", $server['address'], $_POST['address']);
- update_if_changed("advanced", $server['advanced'], base64_encode($_POST['advanced']));
- update_if_changed("checkinter", $server['checkinter'], $_POST['checkinter']);
-
- if (isset($id) && $a_server[$id]) {
- $a_server[$id] = $server;
+ if($pool['name'] != "")
+ $changedesc .= " modified '{$pool['name']}' pool:";
+
+ $pool['ha_servers']['item']=$a_servers;
+
+ update_if_changed("name", $pool['name'], $_POST['name']);
+ update_if_changed("status", $pool['status'], $_POST['status']);
+ update_if_changed("advanced", $pool['advanced'], base64_encode($_POST['advanced']));
+ update_if_changed("checkinter", $pool['checkinter'], $_POST['checkinter']);
+ update_if_changed("monitor_uri", $pool['monitor_uri'], $_POST['monitor_uri']);
+
+ if (isset($id) && $a_pools[$id]) {
+ $a_pools[$id] = $pool;
} else {
- $a_server[] = $server;
+ $a_pools[] = $pool;
}
if ($changecount > 0) {
@@ -152,7 +141,7 @@ $pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
-$pgtitle = "HAProxy: Server: Edit";
+$pgtitle = "HAProxy: pool: Edit";
include("head.inc");
row_helper();
@@ -173,19 +162,25 @@ function clearcombo(){
}
</script>
<script type="text/javascript">
- rowname[0] = "backend";
- rowtype[0] = "select";
- rowsize[0] = "1";
+ rowname[0] = "server_address";
+ rowtype[0] = "textbox";
+ rowsize[0] = "30";
+ rowname[1] = "server_port";
+ rowtype[1] = "textbox";
+ rowsize[1] = "12";
+ rowname[2] = "server_weight";
+ rowtype[2] = "textbox";
+ rowsize[2] = "12";
</script>
<?php include("fbegin.inc"); ?>
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if($one_two): ?>
<p class="pgtitle"><?=$pgtitle?></p>
<?php endif; ?>
- <form action="haproxy_servers_edit.php" method="post" name="iform" id="iform">
+ <form action="haproxy_pool_edit.php" method="post" name="iform" id="iform">
<table width="100%" border="0" cellpadding="6" cellspacing="0">
<tr>
- <td colspan="2" valign="top" class="listtopic">Edit HAProxy server</td>
+ <td colspan="2" valign="top" class="listtopic">Edit HAProxy pool</td>
</tr>
<tr align="left">
<td width="22%" valign="top" class="vncellreq">Name</td>
@@ -194,78 +189,6 @@ function clearcombo(){
</td>
</tr>
<tr align="left">
- <td width="22%" valign="top" class="vncellreq">Frontend(s)</td>
- <td width="78%" class="vtable">
- <table id="frontendtable">
- <tbody>
- <tr>
- <td><div id="onecolumn"></div></td>
- </tr>
- <?php
- $counter = 0;
- $tracker = 0;
- $backend = $pconfig['backend'];
- $item = explode(" ", $backend);
- foreach($item as $ww) {
- $address = $ww;
- if($counter > 0)
- $tracker = $counter + 1;
- ?>
- <tr>
- <td>
- <select name="backend<?php echo $tracker; ?>">
- <?php
- $i = 0;
- if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item']))
- $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
- $backends = split(" ", $pconfig['backend']);
- foreach ($a_backend as $backend) {
- ?>
- <option value="<?=$backend['name'];?>" <?php if($backend['name'] == $ww) echo "SELECTED";?>>
- <?=$backend['name'];?>
- </option>
- <?php } ?>
- </select>
- </td>
- <td>
- <?php
- if($counter > 0)
- echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
- ?>
- </td>
- </tr>
- <?php
- $counter++;
- } // end foreach
- ?>
- </tbody>
- <tfoot>
- </tfoot>
- </table>
- <a onclick="javascript:addRowTo('frontendtable'); return false;" href="#">
- <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
- </a>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">
- <div id="addressnetworkport">
- IP Address
- </div>
- </td>
- <td width="78%" class="vtable">
- <input name="address" type="text" id="address" size="30" value="<?=htmlspecialchars($pconfig['address']);?>" />
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Port</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="5">
- <br/>
- NOTE: Leave blank to use Frontend port selection.
- </td>
- </tr>
- <tr align="left">
<td width="22%" valign="top" class="vncellreq">Status</td>
<td width="78%" class="vtable" colspan="2">
<select name="status">
@@ -279,7 +202,7 @@ function clearcombo(){
<td width="78%" class="vtable" colspan="2">
<input name="cookie" type="text" <?if(isset($pconfig['cookie'])) echo "value=\"{$pconfig['cookie']}\"";?>size="64"><br/>
This value will be checked in incoming requests, and the first
- operational server possessing the same value will be selected. In return, in
+ operational pool possessing the same value will be selected. In return, in
cookie insertion or rewrite modes, this value will be assigned to the cookie
sent to the client. There is nothing wrong in having several servers sharing
the same cookie value, and it is in fact somewhat common between normal and
@@ -287,23 +210,52 @@ function clearcombo(){
</td>
</tr>
+ <tr>
+ <td width="78%" class="vtable" colspan="2" valign="top">
+ <table class="" width="100%" cellpadding="0" cellspacing="0" id='servertable'>
+ <tr>
+ <td width="35%" class="">Address</td>
+ <td width="40%" class="">Port</td>
+ <td width="20%" class="">Weight</td>
+ <td width="5%" class=""></td>
+ </tr>
+ <?php
+ $a_servers=$pconfig['a_servers'];
+
+ if (!is_array($a_servers)) {
+ $a_servers=array();
+ }
+
+ $counter=0;
+ foreach ($a_servers as $server) {
+ ?>
+ <tr>
+ <td><input name="server_address<?=$counter;?>" type="text" value="<?=$server['address']; ?>" size="30"/></td>
+ <td><input name="server_port<?=$counter;?>" type="text" value="<?=$server['port']; ?>" size="12"/></td>
+ <td><input name="server_weight<?=$counter;?>" type="text" value="<?=$server['weight']; ?>" size="12"/></td>
+ <td class="list"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0" onclick="removeRow(this); return false;"></td>
+ </tr>
+ <?php
+ $counter++;
+ }
+ ?>
+ </table>
+ <a onclick="javascript:addRowTo('servertable'); return false;" href="#">
+ <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
+ </a>
+ </td>
+ </tr>
<tr align="left">
- <td width="22%" valign="top" class="vncell">Check inter</td>
+ <td width="22%" valign="top" class="vncell">Check freq</td>
<td width="78%" class="vtable" colspan="2">
<input name="checkinter" type="text" <?if(isset($pconfig['checkinter'])) echo "value=\"{$pconfig['checkinter']}\"";?>size="64">
<br/>Defaults to 1000 if left blank.
</td>
</tr>
<tr align="left">
- <td width="22%" valign="top" class="vncell">Weight</td>
+ <td width="22%" valign="top" class="vncell">Health check URI</td>
<td width="78%" class="vtable" colspan="2">
- <input name="weight" type="text" <?if(isset($pconfig['weight'])) echo "value=\"{$pconfig['weight']}\"";?>size="64"><br/>
- The default weight is 1, and the maximal value is 255.<br/>
- NOTE: If this
- parameter is used to distribute the load according to server's capacity, it
- is recommended to start with values which can both grow and shrink, for
- instance between 10 and 100 to leave enough room above and below for later
- adjustments.
+ <input name="monitor_uri" type="text" <?if(isset($pconfig['monitor_uri'])) echo "value=\"{$pconfig['monitor_uri']}\"";?>size="64"><br/>
</td>
</tr>
<tr align="left">
@@ -319,7 +271,7 @@ function clearcombo(){
<td width="78%">
<input name="Submit" type="submit" class="formbtn" value="Save">
<input type="button" class="formbtn" value="Cancel" onclick="history.back()">
- <?php if (isset($id) && $a_server[$id]): ?>
+ <?php if (isset($id) && $a_pools[$id]): ?>
<input name="id" type="hidden" value="<?=$id;?>">
<?php endif; ?>
</td>
@@ -329,10 +281,10 @@ function clearcombo(){
<br>
<?php include("fend.inc"); ?>
<script type="text/javascript">
- field_counter_js = 1;
+ field_counter_js = 3;
rows = 1;
- totalrows = <?php echo $counter; ?>;
- loaded = <?php echo $counter; ?>;
+ totalrows = <?php echo $counter; ?>;
+ loaded = <?php echo $counter; ?>;
</script>
</body>
</html>
diff --git a/config/haproxy-dev/haproxy_pools.php b/config/haproxy-dev/haproxy_pools.php
index 4a0b08c9..5b9942b3 100755
--- a/config/haproxy-dev/haproxy_pools.php
+++ b/config/haproxy-dev/haproxy_pools.php
@@ -1,7 +1,7 @@
<?php
/* $Id: load_balancer_virtual_server.php,v 1.6.2.1 2006/01/02 23:46:24 sullrich Exp $ */
/*
- haproxy_servers.php
+ haproxy_pools.php
part of pfSense (http://www.pfsense.com/)
Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.com>
Copyright (C) 2008 Remco Hoef <remcoverhoef@pfsense.com>
@@ -34,11 +34,11 @@ require_once("haproxy.inc");
$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
-if (!is_array($config['installedpackages']['haproxy']['ha_servers']['item'])) {
- $config['installedpackages']['haproxy']['ha_servers']['item'] = array();
+if (!is_array($config['installedpackages']['haproxy']['ha_pools']['item'])) {
+ $config['installedpackages']['haproxy']['ha_pools']['item'] = array();
}
-$a_server = &$config['installedpackages']['haproxy']['ha_servers']['item'];
+$a_pools = &$config['installedpackages']['haproxy']['ha_pools']['item'];
$a_backends = &$config['installedpackages']['haproxy']['ha_backends']['item'];
if ($_POST) {
@@ -55,22 +55,20 @@ if ($_POST) {
}
if ($_GET['act'] == "del") {
- if ($a_server[$_GET['id']]) {
- if (!$input_errors) {
- unset($a_server[$_GET['id']]);
- write_config();
- touch($d_haproxyconfdirty_path);
- header("Location: haproxy_servers.php");
- exit;
- }
+ if (isset($a_pools[$_GET['id']])) {
+ unset($a_pools[$_GET['id']]);
+ write_config();
+ touch($d_haproxyconfdirty_path);
}
+ header("Location: haproxy_pools.php");
+ exit;
}
$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
if(strstr($pfSversion, "1.2"))
$one_two = true;
-$pgtitle = "Services: HAProxy: Servers";
+$pgtitle = "Services: HAProxy: Server pools";
include("head.inc");
?>
@@ -79,11 +77,11 @@ include("head.inc");
<?php if($one_two): ?>
<p class="pgtitle"><?=$pgtitle?></p>
<?php endif; ?>
-<form action="haproxy_servers.php" method="post">
+<form action="haproxy_pools.php" method="post">
<?php if ($input_errors) print_input_errors($input_errors); ?>
<?php if ($savemsg) print_info_box($savemsg); ?>
<?php if (file_exists($d_haproxyconfdirty_path)): ?><p>
-<?php print_info_box_np("The virtual server configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
+<?php print_info_box_np("The virtual pool configuration has been changed.<br>You must apply the changes in order for them to take effect.");?><br>
<?php endif; ?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr><td class="tabnavtbl">
@@ -91,8 +89,8 @@ include("head.inc");
/* active tabs */
$tab_array = array();
$tab_array[] = array("Settings", false, "haproxy_global.php");
- $tab_array[] = array("Listener", false, "haproxy_frontends.php");
- $tab_array[] = array("Server Pool", true, "haproxy_servers.php");
+ $tab_array[] = array("Listener", false, "haproxy_listeners.php");
+ $tab_array[] = array("Server Pool", true, "haproxy_pools.php");
display_top_tabs($tab_array);
?>
</td></tr>
@@ -104,47 +102,49 @@ include("head.inc");
<td width="30%" class="listhdrr">Name</td>
<td width="30%" class="listhdrr">Server</td>
<td width="20%" class="listhdrr">Status</td>
- <td width="30%" class="listhdrr">Frontend</td>
- <td width="10%" class="listhdrr">Cookie</td>
- <td width="10%" class="listhdrr">Weight</td>
+ <td width="30%" class="listhdrr">Listener</td>
<td width="10%" class="list"></td>
</tr>
- <?php $i = 0; foreach ($a_server as $server): ?>
+ <?php $i = 0; foreach ($a_pools as $pool): ?>
<tr>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['name'];?>
+ <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';">
+ <?=$pool['name'];?>
</td>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['address'] . ":"?>
+ <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';">
<?php
- if($server['port']) {
- echo $server['port'];
- } else {
- foreach ($a_backends as $backend) {
- if($backend['name'] == $server['backend']) {
- echo $backend['port'];
- }
- }
+ foreach ($a_backends as $backend) {
+ if($backend['pool'] == $pool['name']) {
+ $listener = $backend;
}
+ }
+
+ if (is_array($listener)) {
+ if ($listener['extaddr'])
+ echo $listener['extaddr'];
+ else
+ echo "any";
+ if ($listener['port'])
+ echo ":" . $listener['port'];
+ } else
+ echo '-';
?>
+
</td>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['status'];?>
- </td>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['backend'];?>
- </td>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['cookie'];?>
+ <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';">
+ <?=$pool['status'];?>
</td>
- <td class="listlr" ondblclick="document.location='haproxy_servers_edit.php?id=<?=$i;?>';">
- <?=$server['weight'];?>
+ <td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';">
+<?php
+ if (is_array($listener)) {
+ echo $listener['name'];
+ }
+?>
</td>
<td class="list" nowrap>
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="haproxy_servers_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
- <td valign="middle"><a href="haproxy_servers.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_pool_edit.php?id=<?=$i;?>"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_e.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_pools.php?act=del&id=<?=$i;?>" onclick="return confirm('Do you really want to delete this entry?')"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_x.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
</td>
@@ -155,7 +155,7 @@ include("head.inc");
<td class="list">
<table border="0" cellspacing="0" cellpadding="1">
<tr>
- <td valign="middle"><a href="haproxy_servers_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
+ <td valign="middle"><a href="haproxy_pool_edit.php"><img src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" width="17" height="17" border="0"></a></td>
</tr>
</table>
</td>
diff --git a/config/haproxy-dev/haproxy_servers_edit.php b/config/haproxy-dev/haproxy_servers_edit.php
deleted file mode 100755
index 5a37e7a2..00000000
--- a/config/haproxy-dev/haproxy_servers_edit.php
+++ /dev/null
@@ -1,431 +0,0 @@
-<?php
-/* $Id: load_balancer_pool_edit.php,v 1.24.2.23 2007/03/03 00:07:09 smos Exp $ */
-/*
- haproxy_servers_edit.php
- part of pfSense (http://www.pfsense.com/)
- Copyright (C) 2009 Scott Ullrich <sullrich@pfsense.com>
- Copyright (C) 2008 Remco Hoef <remcoverhoef@pfsense.com>
- 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, 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");
-
-$d_haproxyconfdirty_path = $g['varrun_path'] . "/haproxy.conf.dirty";
-$a_backend = &$config['installedpackages']['haproxy']['ha_backends']['item'];
-
-if (!is_array($config['installedpackages']['haproxy']['ha_servers']['item'])) {
- $config['installedpackages']['haproxy']['ha_servers']['item'] = array();
-}
-
-$a_server = &$config['installedpackages']['haproxy']['ha_servers']['item'];
-
-if (isset($_POST['id']))
- $id = $_POST['id'];
-else
- $id = $_GET['id'];
-
-if (isset($id) && $a_server[$id]) {
- $pconfig['name'] = $a_server[$id]['name'];
- $pconfig['address'] = $a_server[$id]['address'];
- $pconfig['port'] = $a_server[$id]['port'];
- $pconfig['backend'] = $a_server[$id]['backend'];
- $pconfig['weight'] = $a_server[$id]['weight'];
- $pconfig['checkinter'] = $a_server[$id]['checkinter'];
- $pconfig['cookie'] = $a_server[$id]['cookie'];
- $pconfig['status'] = $a_server[$id]['status'];
- $pconfig['advanced'] = base64_decode($a_server[$id]['advanced']);
-}
-
-$changedesc = "Services: HAProxy: Servers: ";
-$changecount = 0;
-
-if ($_POST) {
- $changecount++;
-
- unset($input_errors);
- $pconfig = $_POST;
-
- $reqdfields = explode(" ", "name address weight");
- $reqdfieldsn = explode(",", "Name,Address,Weight");
-
- do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
-
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['name']))
- $input_errors[] = "The field 'Name' contains invalid characters.";
-
- if (preg_match("/[^a-zA-Z0-9\.]/", $_POST['address']))
- $input_errors[] = "The field 'Address' contains invalid characters.";
-
- if (preg_match("/[^a-zA-Z0-9\.\-_]/", $_POST['cookie']))
- $input_errors[] = "The field 'Cookie' contains invalid characters.";
-
- if ($_POST['port'] && !is_numeric($_POST['port']))
- $input_errors[] = "The field 'Port' value is not a number.";
- else {
- if ($_POST['port'])
- if (!($_POST['port']>=1 && $_POST['port']<=65535))
- $input_errors[] = "The field 'Port' value must be between 1 and 65535.";
- }
-
- if (!is_numeric($_POST['weight']))
- $input_errors[] = "The field 'Weight' value is not a number.";
- else {
- if (!($_POST['weight']>=1 && $_POST['weight']<=256))
- $input_errors[] = "The field 'Weight' value must be between 1 and 256.";
- }
-
- /* Ensure that our pool names are unique */
- for ($i=0; isset($config['installedpackages']['haproxy']['ha_servers']['item'][$i]); $i++)
- if (($_POST['name'] == $config['installedpackages']['haproxy']['ha_servers']['item'][$i]['name']) && ($i != $id))
- $input_errors[] = "This server name has already been used. Server names must be unique.";
-
- $backend = "";
- for($x=0; $x<299; $x++) {
- $comd = "\$backends = \$_POST['backend" . $x . "'];";
- eval($comd);
- if($backends)
- $backend .= "$backends ";
- }
- $backend = trim($backend);
-
- if (!$input_errors) {
- $server = array();
- if(isset($id) && $a_server[$id])
- $server = $a_server[$id];
-
- if($server['name'] != "")
- $changedesc .= " modified '{$server['name']}' pool:";
-
- update_if_changed("name", $server['name'], $_POST['name']);
- update_if_changed("port", $server['port'], $_POST['port']);
- update_if_changed("backend", $server['backend'], $backend);
- update_if_changed("cookie", $server['cookie'], $_POST['cookie']);
- update_if_changed("weight", $server['weight'], $_POST['weight']);
- update_if_changed("status", $server['status'], $_POST['status']);
- update_if_changed("address", $server['address'], $_POST['address']);
- update_if_changed("advanced", $server['advanced'], base64_encode($_POST['advanced']));
- update_if_changed("checkinter", $server['checkinter'], $_POST['checkinter']);
-
- if (isset($id) && $a_server[$id]) {
- $a_server[$id] = $server;
- } else {
- $a_server[] = $server;
- }
-
- if ($changecount > 0) {
- touch($d_haproxyconfdirty_path);
- write_config($changedesc);
- /*
- echo "<PRE>";
- print_r($config);
- echo "</PRE>";
- */
- }
-
- header("Location: haproxy_servers.php");
- exit;
- }
-}
-
-$pfSversion = str_replace("\n", "", file_get_contents("/etc/version"));
-if(strstr($pfSversion, "1.2"))
- $one_two = true;
-
-$pgtitle = "HAProxy: Server: Edit";
-include("head.inc");
-
-row_helper();
-
-?>
-
-<input type='hidden' name='address_type' value='textbox' />
-
-<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
-<script type="text/javascript" language="javascript" src="pool.js"></script>
-
-<script language="javascript">
-function clearcombo(){
- for (var i=document.iform.serversSelect.options.length-1; i>=0; i--){
- document.iform.serversSelect.options[i] = null;
- }
- document.iform.serversSelect.selectedIndex = -1;
-}
-</script>
-<script type="text/javascript">
- rowname[0] = "backend";
- rowtype[0] = "select";
- rowsize[0] = "1";
-</script>
-<?php include("fbegin.inc"); ?>
-<?php if ($input_errors) print_input_errors($input_errors); ?>
-<?php if($one_two): ?>
-<p class="pgtitle"><?=$pgtitle?></p>
-<?php endif; ?>
- <form action="haproxy_servers_edit.php" method="post" name="iform" id="iform">
- <table width="100%" border="0" cellpadding="6" cellspacing="0">
- <tr>
- <td colspan="2" valign="top" class="listtopic">Edit HAProxy server</td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncellreq">Name</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="name" type="text" <?if(isset($pconfig['name'])) echo "value=\"{$pconfig['name']}\"";?> size="16" maxlength="16">
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncellreq">Frontend(s)</td>
- <td width="78%" class="vtable">
- <table id="frontendtable">
- <tbody>
- <tr>
- <td><div id="onecolumn"></div></td>
- </tr>
- <?php
- $counter = 0;
- $tracker = 0;
- $backend = $pconfig['backend'];
- $item = explode(" ", $backend);
- foreach($item as $ww) {
- $address = $ww;
- if($counter > 0)
- $tracker = $counter + 1;
- ?>
- <tr>
- <td>
- <select name="backend<?php echo $tracker; ?>">
- <?php
- $i = 0;
- if (!is_array($config['installedpackages']['haproxy']['ha_backends']['item']))
- $config['installedpackages']['haproxy']['ha_backends']['item'] = array();
- $backends = split(" ", $pconfig['backend']);
- foreach ($a_backend as $backend) {
- ?>
- <option value="<?=$backend['name'];?>" <?php if($backend['name'] == $ww) echo "SELECTED";?>>
- <?=$backend['name'];?>
- </option>
- <?php } ?>
- </select>
- </td>
- <td>
- <?php
- if($counter > 0)
- echo "<input type=\"image\" src=\"/themes/".$g['theme']."/images/icons/icon_x.gif\" onclick=\"removeRow(this); return false;\" value=\"Delete\" />";
- ?>
- </td>
- </tr>
- <?php
- $counter++;
- } // end foreach
- ?>
- </tbody>
- <tfoot>
- </tfoot>
- </table>
- <a onclick="javascript:addRowTo('frontendtable'); return false;" href="#">
- <img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="add another entry" />
- </a>
- </td>
- </tr>
- <tr>
- <td width="22%" valign="top" class="vncellreq">
- <div id="addressnetworkport">
- IP Address
- </div>
- </td>
- <td width="78%" class="vtable">
- <input name="address" type="text" id="address" size="30" value="<?=htmlspecialchars($pconfig['address']);?>" />
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Port</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="port" type="text" <?if(isset($pconfig['port'])) echo "value=\"{$pconfig['port']}\"";?> size="5">
- <br/>
- NOTE: Leave blank to use Frontend port selection.
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncellreq">Status</td>
- <td width="78%" class="vtable" colspan="2">
- <select name="status">
- <option value="active" <?php if($pconfig['status']=='active') echo "SELECTED";?>>active</option>
- <option value="inactive" <?php if($pconfig['status']=='inactive') echo "SELECTED";?>>inactive</option>
- </select>
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Cookie</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="cookie" type="text" <?if(isset($pconfig['cookie'])) echo "value=\"{$pconfig['cookie']}\"";?>size="64"><br/>
- This value will be checked in incoming requests, and the first
- operational server possessing the same value will be selected. In return, in
- cookie insertion or rewrite modes, this value will be assigned to the cookie
- sent to the client. There is nothing wrong in having several servers sharing
- the same cookie value, and it is in fact somewhat common between normal and
- backup servers. See also the "cookie" keyword in backend section.
-
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Check inter</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="checkinter" type="text" <?if(isset($pconfig['checkinter'])) echo "value=\"{$pconfig['checkinter']}\"";?>size="64">
- <br/>Defaults to 1000 if left blank.
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Weight</td>
- <td width="78%" class="vtable" colspan="2">
- <input name="weight" type="text" <?if(isset($pconfig['weight'])) echo "value=\"{$pconfig['weight']}\"";?>size="64"><br/>
- The default weight is 1, and the maximal value is 255.<br/>
- NOTE: If this
- parameter is used to distribute the load according to server's capacity, it
- is recommended to start with values which can both grow and shrink, for
- instance between 10 and 100 to leave enough room above and below for later
- adjustments.
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top" class="vncell">Advanced pass thru</td>
- <td width="78%" class="vtable" colspan="2">
- <textarea name='advanced' rows="4" cols="70" id='advanced'><?php echo $pconfig['advanced']; ?></textarea>
- <br/>
- NOTE: paste text into this box that you would like to pass thru.
- </td>
- </tr>
- <tr align="left">
- <td width="22%" valign="top">&nbsp;</td>
- <td width="78%">
- <input name="Submit" type="submit" class="formbtn" value="Save">
- <input type="button" class="formbtn" value="Cancel" onclick="history.back()">
- <?php if (isset($id) && $a_server[$id]): ?>
- <input name="id" type="hidden" value="<?=$id;?>">
- <?php endif; ?>
- </td>
- </tr>
- </table>
- </form>
-<br>
-<?php include("fend.inc"); ?>
-<script type="text/javascript">
- field_counter_js = 1;
- rows = 1;
- totalrows = <?php echo $counter; ?>;
- loaded = <?php echo $counter; ?>;
-</script>
-</body>
-</html>
-
-<?php
-
-function row_helper() {
- global $pconfig, $a_backend;
- $options = "";
- foreach ($a_backend as $backend) {
- $options .= "<option value='{$backend['name']}'";
- if($backend['name'] == $pconfig['backend'])
- $options .= "SELECTED";
- $options .= ">";
- $options .= $backend['name'];
- $options .= "</option>";
- }
-
- echo <<<EOF
-<script type="text/javascript">
-// Global Variables
-var rowname = new Array(99);
-var rowtype = new Array(99);
-var newrow = new Array(99);
-var rowsize = new Array(99);
-
-for (i = 0; i < 99; i++) {
- rowname[i] = '';
- rowtype[i] = '';
- newrow[i] = '';
- rowsize[i] = '25';
-}
-
-var field_counter_js = 0;
-var loaded = 0;
-var is_streaming_progress_bar = 0;
-var temp_streaming_text = "";
-
-var addRowTo = (function() {
- return (function (tableId) {
- var d, tbody, tr, td, bgc, i, ii, j;
- d = document;
- tbody = d.getElementById(tableId).getElementsByTagName("tbody").item(0);
- tr = d.createElement("tr");
- totalrows++;
- for (i = 0; i < field_counter_js; i++) {
- td = d.createElement("td");
- if(rowtype[i] == 'textbox') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'></input> ";
- } else if(rowtype[i] == 'select') {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><select size='" + rowsize[i] + "' name='" + rowname[i] + totalrows + "'>$options</select> ";
- } else {
- td.innerHTML="<INPUT type='hidden' value='" + totalrows +"' name='" + rowname[i] + "_row-" + totalrows + "'></input><input type='checkbox' name='" + rowname[i] + totalrows + "'></input> ";
- }
- tr.appendChild(td);
- }
- td = d.createElement("td");
- td.rowSpan = "1";
-
- td.innerHTML = '<input type="image" src="/themes/' + theme + '/images/icons/icon_x.gif" onclick="removeRow(this); return false;" value="Delete">';
- tr.appendChild(td);
- tbody.appendChild(tr);
- });
-})();
-
-function removeRow(el) {
- var cel;
- while (el && el.nodeName.toLowerCase() != "tr")
- el = el.parentNode;
-
- if (el && el.parentNode) {
- cel = el.getElementsByTagName("td").item(0);
- el.parentNode.removeChild(el);
- }
-}
-
-function find_unique_field_name(field_name) {
- // loop through field_name and strip off -NUMBER
- var last_found_dash = 0;
- for (var i = 0; i < field_name.length; i++) {
- // is this a dash, if so, update
- // last_found_dash
- if (field_name.substr(i,1) == "-" )
- last_found_dash = i;
- }
- if (last_found_dash < 1)
- return field_name;
- return(field_name.substr(0,last_found_dash));
-}
-</script>
-
-EOF;
-
-}
-
-?> \ No newline at end of file