aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorPiBa-NL <pba_2k3@yahoo.com>2015-10-24 20:45:43 +0200
committerPiBa-NL <pba_2k3@yahoo.com>2015-10-24 20:45:43 +0200
commite3d4b3b7f7ae0eeb936f734f696d3f5bbfe2c762 (patch)
treedf55e7629d63f7bd60594d72a8af44d59f8a3017 /config
parent0382b3aba6bef1d6f0c92109ca39a01dc2ca46a0 (diff)
downloadpfsense-packages-e3d4b3b7f7ae0eeb936f734f696d3f5bbfe2c762.tar.gz
pfsense-packages-e3d4b3b7f7ae0eeb936f734f696d3f5bbfe2c762.tar.bz2
pfsense-packages-e3d4b3b7f7ae0eeb936f734f696d3f5bbfe2c762.zip
haproxy-devel, avoid possible config upgrade error messages, add actually writhing the configured frontend errorfiles to the config
Diffstat (limited to 'config')
-rw-r--r--config/haproxy-devel/pkg/haproxy.inc24
-rw-r--r--config/haproxy-devel/pkg/haproxy_upgrade_config.inc146
-rw-r--r--config/haproxy-devel/www/haproxy_global.php6
-rw-r--r--config/haproxy-devel/www/haproxy_pools.php29
4 files changed, 119 insertions, 86 deletions
diff --git a/config/haproxy-devel/pkg/haproxy.inc b/config/haproxy-devel/pkg/haproxy.inc
index 7a07e9a7..afa10fb7 100644
--- a/config/haproxy-devel/pkg/haproxy.inc
+++ b/config/haproxy-devel/pkg/haproxy.inc
@@ -1295,7 +1295,7 @@ function haproxy_updateocsp($socketupdate = true) {
}
function haproxy_writeconf($configpath) {
- global $config;
+ global $config, $a_files_cache;
global $aliastable;
global $a_action;
if (!isset($aliastable)) {
@@ -1595,6 +1595,24 @@ function haproxy_writeconf($configpath) {
fwrite ($fd, "\ttimeout client\t\t{$bind['client_timeout']}\n");
+ if (is_arrayset($bind,'a_errorfiles','item')) {
+ foreach($bind['a_errorfiles']['item'] as $errorfile) {
+ if (!is_array($a_files_cache)) {// load only once
+ $a_files_cache = haproxy_get_fileslist();
+ }
+ $file = $errorfile['errorfile'];
+ $errorcodes = explode(",",$errorfile['errorcode']);
+ foreach($errorcodes as $errorcode) {
+ $filename = "$configpath/errorfile_{$name}_{$errorcode}_{$file}";
+ $content = base64_decode($a_files_cache[$file]['content']);
+ $content = str_replace('{errormsg}', $a_error[$errorcode]['descr'], $content);
+ $content = str_replace('{errorcode}', $errorcode, $content);
+ file_put_contents($filename, $content);
+ fwrite ($fd, "\terrorfile\t\t\t" . $errorcode ." " . $filename . "\n");
+ }
+ }
+ }
+
// Advanced pass thru
if ($bind['advanced']) {
$advanced = explode("\n", base64_decode($bind['advanced']));
@@ -1647,12 +1665,8 @@ function haproxy_writeconf($configpath) {
$item['use_backendbackend'] = $frontend['backend_serverpool'];
$a_actionitems[] = $item;
}
-
- //$backend = haproxy_find_backend($frontend['backend_serverpool']);
- //$transparent_clientip = $backend["transparent_clientip"] == 'yes';
$transparent_clientip = frontend_usetransparentbackend($frontend);
-
$allowfordefaultbackend = true;
$ipv = array();
if ($transparent_clientip) {
diff --git a/config/haproxy-devel/pkg/haproxy_upgrade_config.inc b/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
index 58e66852..052f7c77 100644
--- a/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
+++ b/config/haproxy-devel/pkg/haproxy_upgrade_config.inc
@@ -145,16 +145,18 @@ function haproxy_upgrade_config() {
}
if ($configversion < "00.13") {
// update config to "haproxy-devel 1.5-dev19 pkg v0.13"
- foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) {
- if (isset($bind['extaddr'])) {
- $new['extaddr'] = $bind['extaddr'];
- $new['extaddr_port'] = $bind['port'];
- $new['extaddr_ssl'] = $bind['ssloffload'];
- $bind['a_extaddr']['item'][] = $new;
+ if (is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) {
+ if (isset($bind['extaddr'])) {
+ $new['extaddr'] = $bind['extaddr'];
+ $new['extaddr_port'] = $bind['port'];
+ $new['extaddr_ssl'] = $bind['ssloffload'];
+ $bind['a_extaddr']['item'][] = $new;
+ }
+ unset($bind['extaddr']);
+ unset($bind['port']);
+ //unset($bind['ssloffload']);
}
- unset($bind['extaddr']);
- unset($bind['port']);
- //unset($bind['ssloffload']);
}
$configversion = "00.13";
}
@@ -169,15 +171,17 @@ function haproxy_upgrade_config() {
$static_output .= "HAProxy, 00.17\n";
update_output_window($static_output);
// remove 'none' ca-cert, and set checkbox to allow for no certificate instead.
- foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) {
- $list = array();
- foreach ($bind['clientcert_ca']['item'] as $ca){
- if (empty($ca['cert_ca']))
- $bind['sslclientcert-none'] = 'yes';
- else
- $list[] = $ca;
+ if (is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$bind) {
+ $list = array();
+ foreach ($bind['clientcert_ca']['item'] as $ca){
+ if (empty($ca['cert_ca']))
+ $bind['sslclientcert-none'] = 'yes';
+ else
+ $list[] = $ca;
+ }
+ $bind['clientcert_ca']['item'] = $list;
}
- $bind['clientcert_ca']['item'] = $list;
}
$configversion = "00.17";
}
@@ -197,69 +201,65 @@ function haproxy_upgrade_config() {
}
if ($configversion < "00.32") {
$frontends = array();
- foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$frontend) {
- $primaryfrontend = get_primaryfrontend($frontend);
- $fe_name = $primaryfrontend['name'];
- $frontends[$fe_name][] = &$frontend;
- }
-
- foreach ($frontends as $primary) {
- $acl_count = array();
- foreach ($primary as &$frontend){
- $acl_use = array();
- $a_actions = &$frontend['a_actionitems']['item'];
- if (!is_array($a_actions)) {
- $a_actions = array();
- }
-
+ if (is_array($config['installedpackages']['haproxy']['ha_backends']['item'])) {
+ foreach ($config['installedpackages']['haproxy']['ha_backends']['item'] as &$frontend) {
$primaryfrontend = get_primaryfrontend($frontend);
- $frontendtype = $primaryfrontend['type'];
- $is_default = true;
- if (is_array($frontend['ha_acls']['item'])) {
- $a_acl = &$frontend['ha_acls']['item'];
+ $fe_name = $primaryfrontend['name'];
+ $frontends[$fe_name][] = &$frontend;
+ }
+
+ foreach ($frontends as $primary) {
+ $acl_count = array();
+ foreach ($primary as &$frontend){
+ $acl_use = array();
+ $a_actions = &$frontend['a_actionitems']['item'];
+ if (!is_array($a_actions)) {
+ $a_actions = array();
+ }
+
+ $primaryfrontend = get_primaryfrontend($frontend);
+ $frontendtype = $primaryfrontend['type'];
+ $is_default = true;
+ if (is_array($frontend['ha_acls']['item'])) {
+ $a_acl = &$frontend['ha_acls']['item'];
- foreach ($a_acl as &$aclitem) {
- $aclname = $aclitem['name'];
- $acltype = haproxy_find_acl($aclitem['expression']);
- if ($aclitem['expression'] == "backendservercount") {
- $aclitem['backendservercountbackend'] = $frontend['backend_serverpool'];
+ foreach ($a_acl as &$aclitem) {
+ $aclname = $aclitem['name'];
+ $acltype = haproxy_find_acl($aclitem['expression']);
+ if ($aclitem['expression'] == "backendservercount") {
+ $aclitem['backendservercountbackend'] = $frontend['backend_serverpool'];
+ }
+ if (!isset($acl_count[$aclname])) {
+ $acl_count[$aclname] = 1;
+ } else {
+ $acl_count[$aclname] += 1;
+ $aclitem['name'] .= "_{$acl_count[$aclname]}";
+ }
+ if (!isset($acltype))
+ continue;
+ if ($acltype['mode'] != '' && $acltype['mode'] != strtolower($frontendtype)) {
+ continue;
+ }
+ $acl_use[$aclname][] = $aclitem['name'];
}
- if (!isset($acl_count[$aclname])) {
- $acl_count[$aclname] = 1;
- } else {
- $acl_count[$aclname] += 1;
- $aclitem['name'] .= "_{$acl_count[$aclname]}";
+ foreach ($acl_use as $key => $acl_x) {
+ $aclx = $acl_count[$key];
+ $aclnames = "";
+ foreach($acl_x as $aclname) {
+ $aclnames .= " $aclname";
+ }
+ $aclnames = trim($aclnames);
+ $action['action'] = 'use_backend';
+ $action['use_backendbackend'] = $frontend['backend_serverpool'];
+ $action['acl'] = $aclnames;
+ $a_actions[] = $action;
+ $is_default = false;
}
- if (!isset($acltype))
- continue;
- if ($acltype['mode'] != '' && $acltype['mode'] != strtolower($frontendtype)) {
- continue;
- }
- $acl_use[$aclname][] = $aclitem['name'];
}
- foreach ($acl_use as $key => $acl_x) {
- $aclx = $acl_count[$key];
- $aclnames = "";
- foreach($acl_x as $aclname) {
- $aclnames .= " $aclname";
- }
- $aclnames = trim($aclnames);
- $action['action'] = 'use_backend';
- $action['use_backendbackend'] = $frontend['backend_serverpool'];
- $action['acl'] = $aclnames;
- $a_actions[] = $action;
- $is_default = false;
+ if (!$is_default) {
+ $frontend['backend_serverpool'] = "";
}
}
- if (!$is_default) {
- /*
- // default backends still exist ;) no need to convert them to 'actions'.
- $action['action'] = 'use_backend';
- $action['use_backendbackend'] = $frontend['backend_serverpool'];
- $action['acl'] = ""; // default backend has no acl
- $a_actions[] = $action;*/
- $frontend['backend_serverpool'] = "";
- }
}
}
$configversion = "00.32";
diff --git a/config/haproxy-devel/www/haproxy_global.php b/config/haproxy-devel/www/haproxy_global.php
index ff021be0..4902b966 100644
--- a/config/haproxy-devel/www/haproxy_global.php
+++ b/config/haproxy-devel/www/haproxy_global.php
@@ -143,7 +143,13 @@ if ($_POST) {
}
$a_mailers = $config['installedpackages']['haproxy']['email_mailers']['item'];
+if (!is_array($a_mailers)) {
+ $a_mailers = array();
+}
$a_resolvers = $config['installedpackages']['haproxy']['dns_resolvers']['item'];
+if (!is_array($a_resolvers)) {
+ $a_resolvers = array();
+}
$pconfig['enable'] = isset($config['installedpackages']['haproxy']['enable']);
$pconfig['terminate_on_reload'] = isset($config['installedpackages']['haproxy']['terminate_on_reload']);
diff --git a/config/haproxy-devel/www/haproxy_pools.php b/config/haproxy-devel/www/haproxy_pools.php
index deaeb46e..d98c7f41 100644
--- a/config/haproxy-devel/www/haproxy_pools.php
+++ b/config/haproxy-devel/www/haproxy_pools.php
@@ -102,18 +102,31 @@ haproxy_css();
foreach ($a_pools as $pool){
$fe_list = "";
$sep = "";
- foreach ($a_backends as $backend) {
- if($backend['backend_serverpool'] == $pool['name']) {
- $fe_list .= $sep . $backend['name'];
- $sep = ", ";
- }
+ foreach ($a_backends as $frontend) {
+ $used = false;
+ if($frontend['backend_serverpool'] == $pool['name']) {
+ $used = true;
+ }
+ $actions = $frontend['a_actionitems']['item'];
+ if (is_array($actions)) {
+ foreach($actions as $action) {
+ if ($action["action"] == "use_backend" && $action['use_backendbackend'] == $pool['name']) {
+ $used = true;
+ }
+ }
+ }
+ if ($used) {
+ $fe_list .= $sep . $frontend['name'];
+ $sep = ", ";
+ }
}
$textgray = $fe_list == "" ? " gray" : "";
- if (is_array($pool['ha_servers']))
+ if (is_array($pool['ha_servers'])) {
$count = count($pool['ha_servers']['item']);
- else
- $count = 0;
+ } else {
+ $count = 0;
+ }
?>
<tr class="<?=$textgray?>">
<td class="listlr" ondblclick="document.location='haproxy_pool_edit.php?id=<?=$i;?>';">