Merge pull request #2625 from fraenki/haproxy_370

net/haproxy: release 3.7
This commit is contained in:
Frank Wall 2021-11-03 12:49:57 +01:00 committed by GitHub
commit fb9d4aec99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 268 additions and 204 deletions

View file

@ -1,6 +1,5 @@
PLUGIN_NAME= haproxy
PLUGIN_VERSION= 3.6
PLUGIN_REVISION= 1
PLUGIN_VERSION= 3.7
PLUGIN_COMMENT= Reliable, high performance TCP/HTTP load balancer
PLUGIN_DEPENDS= haproxy22
PLUGIN_MAINTAINER= opnsense@moov.de

View file

@ -6,6 +6,23 @@ very high loads while needing persistence or Layer7 processing.
Plugin Changelog
================
3.7
Added:
* add options "preload" and "filename scheme" to Lua scripts (#2265)
* add syslog-ng socket for logging (#2620)
* show hint to apply changes after every config change (#2590)
* show warning for pending configuration changes (#2590)
Fixed:
* unable to use the "require" function in Lua scripts (#2265)
* request logging not working (#2587)
* fix syntax error in template (#2619)
Changed:
* set "lua-prepend-path" so that Lua scripts can be found (#2265)
* show "apply" and "test syntax" buttons on introduction pages
3.6
Added:

View file

@ -17,6 +17,18 @@
<type>text</type>
<help>Description for this Lua script.</help>
</field>
<field>
<id>lua.preload</id>
<label>Preload on startup</label>
<type>checkbox</type>
<help>Whether HAProxy should load and execute this Lua script on startup. This is the default behaviour. However, if this Lua script is included by other Lua scripts using the "require" function, then preloading should be disabled to avoid HAProxy errors.</help>
</field>
<field>
<id>lua.filename_scheme</id>
<label>Filename Scheme</label>
<type>dropdown</type>
<help><![CDATA[Specify the filename scheme for this Lua script. Usually using the ID is sufficient and the most fail-safe apparoach. However, when using Lua's "require" function this apparoach will not work and it becomes necessary to use the specified name as filename. In this case all non-alphanumeric characters are removed from the filename. Note that this may cause issues when creating multiple Lua scripts with the same name.]]></help>
</field>
<field>
<id>lua.content</id>
<label>Content</label>

View file

@ -1,6 +1,6 @@
<model>
<mount>//OPNsense/HAProxy</mount>
<version>3.2.0</version>
<version>3.3.0</version>
<description>the HAProxy load balancer</description>
<items>
<general>
@ -2364,6 +2364,18 @@
<ValidationMessage>Should be a string between 1 and 255 characters.</ValidationMessage>
<Required>N</Required>
</description>
<preload type="BooleanField">
<default>1</default>
<Required>Y</Required>
</preload>
<filename_scheme type="OptionField">
<Required>Y</Required>
<default>id</default>
<OptionValues>
<id>Use a random ID for the filename [default]</id>
<name>Use the specified name as filename</name>
</OptionValues>
</filename_scheme>
<content type="TextField">
<Required>Y</Required>
</content>

View file

@ -0,0 +1,45 @@
<?php
/**
* Copyright (C) 2021 Frank Wall
*
* 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.
*
*/
namespace OPNsense\HAProxy\Migrations;
use OPNsense\Base\BaseModelMigration;
class M3_3_0 extends BaseModelMigration
{
public function run($model)
{
// Lua scripts have a 'filename_scheme' and 'preload' field now
foreach ($model->getNodeByReference('luas.lua')->iterateItems() as $lua) {
$lua->filename_scheme = 'id';
$lua->preload = '1';
}
}
}

View file

@ -300,7 +300,6 @@ POSSIBILITY OF SUCH DAMAGE.
$("#healthcheck\\.type").change(function(){
var service_id = 'table_' + $(this).val();
$(".type_table").hide();
// $(".table_"+$(this).val()).show();
$("."+service_id).show();
});
$("#healthcheck\\.type").change();
@ -323,89 +322,92 @@ POSSIBILITY OF SUCH DAMAGE.
// reconfigure haproxy to activate changes
$('[id*="reconfigureAct"]').each(function(){
$(this).click(function(){
// set progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).addClass("fa fa-spinner fa-pulse");
});
// first run syntax check to catch critical errors
ajaxCall(url="/api/haproxy/service/configtest", sendData={}, callback=function(data,status) {
// show warning in case of critical errors
if (data['result'].indexOf('ALERT') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: "{{ lang._('HAProxy configtest found critical errors') }}",
message: "{{ lang._('The HAProxy service may not be able to start due to critical errors. Run syntax check for further details or review the changes in the %sConfiguration Diff%s.')|format('<a href=\"/ui/haproxy/export#diff\">','</a>') }}",
buttons: [{
icon: 'fa fa-trash-o',
label: '{{ lang._('Abort') }}',
action: function(dlg){
// when done, disable progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
});
dlg.close();
}
}]
});
} else {
ajaxCall(url="/api/haproxy/service/reconfigure", sendData={}, callback=function(data,status) {
if (status != "success" || data['status'] != 'ok') {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('Error reconfiguring HAProxy') }}",
message: data['status'],
draggable: true
});
}
// when done, disable progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
// set progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).addClass("fa fa-spinner fa-pulse");
});
// first run syntax check to catch critical errors
ajaxCall(url="/api/haproxy/service/configtest", sendData={}, callback=function(data,status) {
// show warning in case of critical errors
if (data['result'].indexOf('ALERT') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: "{{ lang._('HAProxy configtest found critical errors') }}",
message: "{{ lang._('The HAProxy service may not be able to start due to critical errors. Run syntax check for further details or review the changes in the %sConfiguration Diff%s.')|format('<a href=\"/ui/haproxy/export#diff\">','</a>') }}",
buttons: [{
icon: 'fa fa-trash-o',
label: '{{ lang._('Abort') }}',
action: function(dlg){
// when done, disable progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
});
dlg.close();
}
}]
});
});
}
});
} else {
ajaxCall(url="/api/haproxy/service/reconfigure", sendData={}, callback=function(data,status) {
if (status != "success" || data['status'] != 'ok') {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('Error reconfiguring HAProxy') }}",
message: data['status'],
draggable: true
});
} else {
// reload page to hide pending changes reminder
setTimeout(function () {
window.location.reload(true)
}, 300);
}
// when done, disable progress animation
$('[id*="reconfigureAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
});
});
}
});
});
});
// test configuration file
$('[id*="configtestAct"]').each(function(){
$(this).click(function(){
// set progress animation
$('[id*="configtestAct_progress"]').each(function(){
$(this).addClass("fa fa-spinner fa-pulse");
});
ajaxCall(url="/api/haproxy/service/configtest", sendData={}, callback=function(data,status) {
// when done, disable progress animation
// set progress animation
$('[id*="configtestAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
$(this).addClass("fa fa-spinner fa-pulse");
});
if (data['result'].indexOf('ALERT') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: "{{ lang._('HAProxy configtest found critical errors') }}",
message: data['result'],
draggable: true
ajaxCall(url="/api/haproxy/service/configtest", sendData={}, callback=function(data,status) {
// when done, disable progress animation
$('[id*="configtestAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
});
} else if (data['result'].indexOf('WARNING') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy configtest found minor errors') }}",
message: data['result'],
draggable: true
});
} else {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy configtest result') }}",
message: "{{ lang._('Your HAProxy config contains no errors.') }}",
draggable: true
});
}
});
if (data['result'].indexOf('ALERT') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: "{{ lang._('HAProxy configtest found critical errors') }}",
message: data['result'],
draggable: true
});
} else if (data['result'].indexOf('WARNING') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy configtest found minor errors') }}",
message: data['result'],
draggable: true
});
} else {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy configtest result') }}",
message: "{{ lang._('Your HAProxy config contains no errors.') }}",
draggable: true
});
}
});
});
});
@ -427,18 +429,26 @@ POSSIBILITY OF SUCH DAMAGE.
if (data['result'].indexOf('ALERT') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_DANGER,
title: "{{ lang._('HAProxy config contains critical errors') }}",
title: "{{ lang._('HAProxy configtest found critical errors') }}",
message: data['result'],
draggable: true
});
} else if (data['result'].indexOf('WARNING') > -1) {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy config contains minor errors') }}",
title: "{{ lang._('HAProxy configtest found minor errors') }}",
message: data['result'],
draggable: true
});
} else {
BootstrapDialog.show({
type: BootstrapDialog.TYPE_WARNING,
title: "{{ lang._('HAProxy configtest result') }}",
message: "{{ lang._('Your HAProxy config contains no errors.') }}",
draggable: true
});
}
// when done, disable progress animation
$('[id*="saveAndTestAct_progress"]').each(function(){
$(this).removeClass("fa fa-spinner fa-pulse");
@ -510,6 +520,11 @@ POSSIBILITY OF SUCH DAMAGE.
message: data['status'],
draggable: true
});
} else {
// reload page to hide pending changes reminder
setTimeout(function () {
window.location.reload(true)
}, 300);
}
// when done, disable progress animation
$('[id*="saveAndReconfigureAct_progress"]').each(function(){
@ -517,15 +532,51 @@ POSSIBILITY OF SUCH DAMAGE.
});
});
}
//});
});
});
});
});
/***********************************************************************
* UI tricks
**********************************************************************/
// show reminder when config has pending changes
function pending_changes_reminder() {
ajaxCall(url="/api/haproxy/export/diff/", sendData={}, callback=function(data,status) {
if (data['response'] && data['response'].trim()) {
$("#haproxyPendingReminder").show();
} else {
$("#haproxyPendingReminder").hide();
}
});
}
pending_changes_reminder();
// show hint after every config change
function add_apply_reminder() {
hint_msg = "{{ lang._('After changing settings, please remember to test and apply them with the buttons below.') }}"
$('[id*="haproxyChangeMessage"]').each(function(){
$(this).append(hint_msg);
});
};
add_apply_reminder();
// show or hide the correct buttons depending on which tab is shown
// NOTE: This does not work on already shown tabs, so this event must
// fire first.
$('.nav-tabs a').on('show.bs.tab', function (e) {
if (/^\#general/.test(e.target.hash)) {
$("#haproxyCommonButtons").hide();
} else {
$("#haproxyCommonButtons").show();
}
});
// update history on tab state and implement navigation
if(window.location.hash != "") {
if (window.location.hash != "") {
$('a[href="' + window.location.hash + '"]').click()
}
$('.nav-tabs a').on('shown.bs.tab', function (e) {
@ -745,7 +796,7 @@ POSSIBILITY OF SUCH DAMAGE.
</div>
<div id="frontends" class="tab-pane fade">
<table id="grid-frontends" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogFrontend">
<table id="grid-frontends" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogFrontend" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -768,17 +819,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-frontends" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-frontends" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="backends" class="tab-pane fade">
<table id="grid-backends" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogBackend">
<table id="grid-backends" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogBackend" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -801,17 +845,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-backends" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-backends" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="servers" class="tab-pane fade">
<table id="grid-servers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogServer">
<table id="grid-servers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogServer" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -837,17 +874,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-servers" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-servers" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="healthchecks" class="tab-pane fade">
<table id="grid-healthchecks" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogHealthcheck">
<table id="grid-healthchecks" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogHealthcheck" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="healthcheckid" data-type="number" data-visible="false">{{ lang._('Health Monitor ID') }}</th>
@ -869,17 +899,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-healthchecks" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-healthchecks" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="actions" class="tab-pane fade">
<table id="grid-actions" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAction">
<table id="grid-actions" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAction" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="actionid" data-type="number" data-visible="false">{{ lang._('Rule ID') }}</th>
@ -901,17 +924,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-actions" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-actions" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="acls" class="tab-pane fade">
<table id="grid-acls" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAcl">
<table id="grid-acls" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogAcl" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="aclid" data-type="number" data-visible="false">{{ lang._('Condition ID') }}</th>
@ -933,17 +949,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-acls" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-acls" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="users" class="tab-pane fade">
<table id="grid-users" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogUser">
<table id="grid-users" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogUser" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -966,17 +975,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-users" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-users" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="groups" class="tab-pane fade">
<table id="grid-groups" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogGroup">
<table id="grid-groups" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogGroup" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -999,17 +1001,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-groups" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-groups" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="luas" class="tab-pane fade">
<table id="grid-luas" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogLua">
<table id="grid-luas" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogLua" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="enabled" data-width="6em" data-type="string" data-formatter="rowtoggle">{{ lang._('Enabled') }}</th>
@ -1032,17 +1027,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-luas" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-luas" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="errorfiles" class="tab-pane fade">
<table id="grid-errorfiles" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogErrorfile">
<table id="grid-errorfiles" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogErrorfile" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="errorfileid" data-type="number" data-visible="false">{{ lang._('Error Message ID') }}</th>
@ -1064,17 +1052,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-errorfiles" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-errorfiles" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="mapfiles" class="tab-pane fade">
<table id="grid-mapfiles" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogMapfile">
<table id="grid-mapfiles" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogMapfile" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="mapfileid" data-type="number" data-visible="false">{{ lang._('Map File ID') }}</th>
@ -1096,17 +1077,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-mapfiles" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-mapfiles" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="cpus" class="tab-pane fade">
<table id="grid-cpus" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogCpu">
<table id="grid-cpus" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogCpu" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="cpuid" data-type="number" data-visible="false">{{ lang._('CPU Rule ID') }}</th>
@ -1131,17 +1105,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-cpus" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-cpus" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="resolvers" class="tab-pane fade">
<table id="grid-resolvers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogResolver">
<table id="grid-resolvers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogResolver" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="resolverid" data-type="number" data-visible="false">{{ lang._('Resolver ID') }}</th>
@ -1164,17 +1131,10 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-resolvers" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-resolvers" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<div id="mailers" class="tab-pane fade">
<table id="grid-mailers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogMailer">
<table id="grid-mailers" class="table table-condensed table-hover table-striped table-responsive" data-editDialog="DialogMailer" data-editAlert="haproxyChangeMessage">
<thead>
<tr>
<th data-column-id="mailerid" data-type="number" data-visible="false">{{ lang._('Mailer ID') }}</th>
@ -1198,13 +1158,6 @@ POSSIBILITY OF SUCH DAMAGE.
</tr>
</tfoot>
</table>
<div class="col-md-12">
<hr/>
<button class="btn btn-primary" id="reconfigureAct-mailers" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-mailers" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/>
<br/>
</div>
</div>
<!-- subtabs for general "Settings" tab below -->
@ -1284,6 +1237,20 @@ POSSIBILITY OF SUCH DAMAGE.
</div>
</div>
</div>
<!-- buttons for all grid pages -->
<div class="col-md-12" id="haproxyCommonButtons" style="display: none">
<div id="haproxyPendingReminder" class="alert alert-warning" style="display: none" role="alert">
{{ lang._("There are pending configuration changes that must be applied in order for them to take effect. To review them visit the %sConfig Diff%s page.") | format('<a href="/ui/haproxy/export#diff" class="alert-link" target="_blank">', '</a>') }}
</div>
<div id="haproxyChangeMessage" class="alert alert-info" style="display: none" role="alert">
</div>
<hr/>
<button class="btn btn-primary" id="reconfigureAct-common" type="button"><b>{{ lang._('Apply') }}</b><i id="reconfigureAct_progress" class=""></i></button>
<button class="btn btn-primary" id="configtestAct-common" type="button"><b>{{ lang._('Test syntax') }}</b><i id="configtestAct_progress" class=""></i></button>
<br/><br/>
</div>
</div>
{# include dialogs #}

View file

@ -548,7 +548,7 @@ POSSIBILITY OF SUCH DAMAGE.
</tfoot>
</table>
<div class="col-md-12">
<p>{{ lang._("%sChoose a command to change a server's state in runtime:%s") | format('<b>', '</b>') }}</p>
<p>{{ lang._("%sThe following commands are available to change a server's state in runtime:%s") | format('<b>', '</b>') }}</p>
<ul>
<li><span class="fa fa-check"></span> {{ lang._('%sSet state to ready:%s This puts the server in normal mode.') | format('<b>', '</b>') }}</li>
<li><span class="fa fa-sort-amount-desc"></span> {{ lang._('%sSet state to drain:%s This removes the server from load balancing. Health checks will continue to run and it still accepts new persistent connections.') | format('<b>', '</b>') }}</li>

View file

@ -2,7 +2,7 @@
<?php
/*
* Copyright (C) 2016 Frank Wall
* Copyright (C) 2016-2021 Frank Wall
* Copyright (C) 2015 Deciso B.V.
* All rights reserved.
*
@ -46,12 +46,17 @@ if (isset($configObj->OPNsense->HAProxy->luas)) {
}
$lua_name = (string)$lua->name;
$lua_id = (string)$lua->id;
if ($lua_id != "") {
$lua_content = htmlspecialchars_decode(str_replace("\r", "", (string)$lua->content));
$lua_filename = $export_path . $lua_id . ".lua";
file_put_contents($lua_filename, $lua_content);
chmod($lua_filename, 0600);
echo "lua script exported to " . $lua_filename . "\n";
$lua_filename_scheme = (string)$lua->filename_scheme;
if ($lua_filename_scheme != '' and $lua_filename_scheme === 'name') {
$_name_alnum = preg_replace("/[^A-Za-z0-9]/", '', $lua_name);
$lua_filename = $export_path . $_name_alnum . '.lua';
} else {
$lua_filename = $export_path . $lua_id . '.lua';
}
$lua_content = htmlspecialchars_decode(str_replace("\r", "", (string)$lua->content));
file_put_contents($lua_filename, $lua_content);
chmod($lua_filename, 0600);
chown($lua_filename, 'www');
echo "lua script exported to " . $lua_filename . "\n";
}
}

View file

@ -994,13 +994,20 @@ global
{% do logging.append('len ' ~ OPNsense.HAProxy.general.logging.length) if OPNsense.HAProxy.general.logging.length|default("") != "" %}
{% do logging.append(OPNsense.HAProxy.general.logging.facility) %}
{% do logging.append(OPNsense.HAProxy.general.logging.level) if OPNsense.HAProxy.general.logging.level|default("") != "" %}
log {{logging|join(' ')}}
log {{logging|join(' ')}}
{# # lua scripts #}
lua-prepend-path /tmp/haproxy/lua/?.lua
{% if helpers.exists('OPNsense.HAProxy.luas.lua') %}
# lua scripts
{% for lua in helpers.toList('OPNsense.HAProxy.luas.lua') %}
{% if lua.enabled == '1' %}
{% if lua.enabled == '1' and lua.preload|default('') == '1' %}
{# # select the filename scheme for lua scripts #}
{% if lua.filename_scheme|default('id') == 'name' %}
{% set lua_filename = lua.name | regex_replace ("[^A-Za-z0-9]","") %}
{% else %}
{% set lua_filename = lua.id %}
{% endif %}
# lua script: {{lua.name}}
lua-load /tmp/haproxy/lua/{{lua.id}}.lua
lua-load /tmp/haproxy/lua/{{lua_filename}}.lua
{% endif %}
{% endfor %}
{% endif %}