Commit fadc0ab5 authored by Franco Fichtner's avatar Franco Fichtner

load balancer (relayd): remove from core

parent 44e4ae85
...@@ -135,7 +135,6 @@ CORE_DEPENDS?= apinger \ ...@@ -135,7 +135,6 @@ CORE_DEPENDS?= apinger \
py${CORE_PY}-ujson \ py${CORE_PY}-ujson \
radvd \ radvd \
rate \ rate \
relayd \
rrdtool12 \ rrdtool12 \
samplicator \ samplicator \
squid \ squid \
......
...@@ -51,9 +51,6 @@ ...@@ -51,9 +51,6 @@
/usr/local/etc/inc/plugins.inc.d/netflow.inc /usr/local/etc/inc/plugins.inc.d/netflow.inc
/usr/local/etc/inc/plugins.inc.d/ntpd.inc /usr/local/etc/inc/plugins.inc.d/ntpd.inc
/usr/local/etc/inc/plugins.inc.d/pf.inc /usr/local/etc/inc/plugins.inc.d/pf.inc
/usr/local/etc/inc/plugins.inc.d/relayd.inc
/usr/local/etc/inc/plugins.inc.d/relayd/dns.proto
/usr/local/etc/inc/plugins.inc.d/relayd/tcp.proto
/usr/local/etc/inc/plugins.inc.d/squid.inc /usr/local/etc/inc/plugins.inc.d/squid.inc
/usr/local/etc/inc/plugins.inc.d/suricata.inc /usr/local/etc/inc/plugins.inc.d/suricata.inc
/usr/local/etc/inc/plugins.inc.d/unbound.inc /usr/local/etc/inc/plugins.inc.d/unbound.inc
...@@ -456,8 +453,6 @@ ...@@ -456,8 +453,6 @@
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Migrations/M1_0_0.php /usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Migrations/M1_0_0.php
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.php /usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.php
/usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml /usr/local/opnsense/mvc/app/models/OPNsense/Proxy/Proxy.xml
/usr/local/opnsense/mvc/app/models/OPNsense/Relayd/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/Relayd/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/ACL/ACL.xml /usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/ACL/ACL.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Menu/Menu.xml /usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Migrations/M1_0_0.php /usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Migrations/M1_0_0.php
...@@ -954,7 +949,6 @@ ...@@ -954,7 +949,6 @@
/usr/local/www/diag_logs_openvpn.php /usr/local/www/diag_logs_openvpn.php
/usr/local/www/diag_logs_ppp.php /usr/local/www/diag_logs_ppp.php
/usr/local/www/diag_logs_proxy.php /usr/local/www/diag_logs_proxy.php
/usr/local/www/diag_logs_relayd.php
/usr/local/www/diag_logs_resolver.php /usr/local/www/diag_logs_resolver.php
/usr/local/www/diag_logs_routing.php /usr/local/www/diag_logs_routing.php
/usr/local/www/diag_logs_settings.php /usr/local/www/diag_logs_settings.php
...@@ -1022,13 +1016,6 @@ ...@@ -1022,13 +1016,6 @@
/usr/local/www/javascript/wizard/disablekeys.js /usr/local/www/javascript/wizard/disablekeys.js
/usr/local/www/javascript/wizard/suggestions.js /usr/local/www/javascript/wizard/suggestions.js
/usr/local/www/license.php /usr/local/www/license.php
/usr/local/www/load_balancer_monitor.php
/usr/local/www/load_balancer_monitor_edit.php
/usr/local/www/load_balancer_pool.php
/usr/local/www/load_balancer_pool_edit.php
/usr/local/www/load_balancer_setting.php
/usr/local/www/load_balancer_virtual_server.php
/usr/local/www/load_balancer_virtual_server_edit.php
/usr/local/www/reboot.php /usr/local/www/reboot.php
/usr/local/www/reporting_settings.php /usr/local/www/reporting_settings.php
/usr/local/www/services_dhcp.php /usr/local/www/services_dhcp.php
...@@ -1063,8 +1050,6 @@ ...@@ -1063,8 +1050,6 @@
/usr/local/www/status_graph.php /usr/local/www/status_graph.php
/usr/local/www/status_habackup.php /usr/local/www/status_habackup.php
/usr/local/www/status_interfaces.php /usr/local/www/status_interfaces.php
/usr/local/www/status_lb_pool.php
/usr/local/www/status_lb_vs.php
/usr/local/www/status_ntpd.php /usr/local/www/status_ntpd.php
/usr/local/www/status_openvpn.php /usr/local/www/status_openvpn.php
/usr/local/www/status_services.php /usr/local/www/status_services.php
...@@ -1118,7 +1103,6 @@ ...@@ -1118,7 +1103,6 @@
/usr/local/www/widgets/include/interface_statistics.inc /usr/local/www/widgets/include/interface_statistics.inc
/usr/local/www/widgets/include/interfaces.inc /usr/local/www/widgets/include/interfaces.inc
/usr/local/www/widgets/include/ipsec.inc /usr/local/www/widgets/include/ipsec.inc
/usr/local/www/widgets/include/load_balancer.inc
/usr/local/www/widgets/include/log.inc /usr/local/www/widgets/include/log.inc
/usr/local/www/widgets/include/ntp_status.inc /usr/local/www/widgets/include/ntp_status.inc
/usr/local/www/widgets/include/openvpn.inc /usr/local/www/widgets/include/openvpn.inc
...@@ -1132,7 +1116,6 @@ ...@@ -1132,7 +1116,6 @@
/usr/local/www/widgets/widgets/interface_list.widget.php /usr/local/www/widgets/widgets/interface_list.widget.php
/usr/local/www/widgets/widgets/interface_statistics.widget.php /usr/local/www/widgets/widgets/interface_statistics.widget.php
/usr/local/www/widgets/widgets/ipsec.widget.php /usr/local/www/widgets/widgets/ipsec.widget.php
/usr/local/www/widgets/widgets/load_balancer_status.widget.php
/usr/local/www/widgets/widgets/log.widget.php /usr/local/www/widgets/widgets/log.widget.php
/usr/local/www/widgets/widgets/ntp_status.widget.php /usr/local/www/widgets/widgets/ntp_status.widget.php
/usr/local/www/widgets/widgets/openvpn.widget.php /usr/local/www/widgets/widgets/openvpn.widget.php
......
This diff is collapsed.
dns protocol "dns" {
tcp { nodelay, sack, socket buffer 1024, backlog 1000 }
}
protocol "tcp" {
tcp { nodelay, socket buffer 65536 }
}
<acl>
<page-services-loadbalancer-monitor-edit>
<name>Services: Load Balancer: Monitor: Edit</name>
<patterns>
<pattern>load_balancer_monitor_edit.php*</pattern>
</patterns>
</page-services-loadbalancer-monitor-edit>
<page-services-loadbalancer-monitor>
<name>Services: Load Balancer: Monitors</name>
<patterns>
<pattern>load_balancer_monitor.php*</pattern>
</patterns>
</page-services-loadbalancer-monitor>
<page-services-loadbalancer-setting>
<name>Services: Load Balancer: setting</name>
<patterns>
<pattern>load_balancer_setting.php*</pattern>
</patterns>
</page-services-loadbalancer-setting>
<page-services-loadbalancer-virtualservers>
<name>Services: Load Balancer: Virtual Servers</name>
<patterns>
<pattern>load_balancer_virtual_server.php*</pattern>
</patterns>
</page-services-loadbalancer-virtualservers>
<page-status-loadbalancer-pool>
<name>Status: Load Balancer: Pool</name>
<patterns>
<pattern>status_lb_pool.php*</pattern>
</patterns>
</page-status-loadbalancer-pool>
<page-status-loadbalancer-virtualserver>
<name>Status: Load Balancer: Virtual Server</name>
<patterns>
<pattern>status_lb_vs.php*</pattern>
</patterns>
</page-status-loadbalancer-virtualserver>
<page-status-systemlogs-loadbalancer>
<name>Status: System logs: Load Balancer</name>
<patterns>
<pattern>diag_logs_relayd.php*</pattern>
</patterns>
</page-status-systemlogs-loadbalancer>
<page-loadbalancer-pool>
<name>Load Balancer: Pool</name>
<patterns>
<pattern>load_balancer_pool.php*</pattern>
</patterns>
</page-loadbalancer-pool>
<page-loadbalancer-pool-edit>
<name>Load Balancer: Pool: Edit</name>
<patterns>
<pattern>load_balancer_pool_edit.php*</pattern>
</patterns>
</page-loadbalancer-pool-edit>
<page-loadbalancer-virtualserver-edit>
<name>Load Balancer: Virtual Server: Edit</name>
<patterns>
<pattern>load_balancer_virtual_server_edit.php*</pattern>
</patterns>
</page-loadbalancer-virtualserver-edit>
</acl>
<menu>
<Services>
<LoadBalancer VisibleName="Load Balancer" cssClass="fa fa-truck fa-fw">
<Monitors order="10" url="/load_balancer_monitor.php">
<Edit url="/load_balancer_monitor_edit.php*" visibility="hidden"/>
</Monitors>
<PoolSetup order="20" VisibleName="Pool Setup" url="/load_balancer_pool.php">
<Edit url="/load_balancer_pool_edit.php*" visibility="hidden"/>
</PoolSetup>
<VirtualServer order="30" VisibleName="Virtual Server Setup" url="/load_balancer_virtual_server.php">
<Edit url="/load_balancer_virtual_server_edit.php*" visibility="hidden"/>
</VirtualServer>
<Settings order="40" url="/load_balancer_setting.php"/>
<PoolStatus order="50" VisibleName="Pool Status" url="/status_lb_pool.php"/>
<VirtualServerStatus order="60" VisibleName="Virtual Server Status" url="/status_lb_vs.php"/>
<Log VisibleName="Log File" order="100" url="/diag_logs_relayd.php"/>
</LoadBalancer>
</Services>
</menu>
<?php
$logfile = '/var/log/relayd.log';
$logclog = true;
require_once 'diag_logs_template.inc';
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2008 Bill Marquette <bill.marquette@gmail.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, 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_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']['monitor_type']) || !is_array($config['load_balancer']['monitor_type'])) {
$config['load_balancer']['monitor_type'] = array();
}
$a_monitor = &$config['load_balancer']['monitor_type'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && $_POST['act'] == "del") {
if (isset($_POST['id']) && !empty($a_monitor[$_POST['id']])){
$input_errors = array();
/* make sure no pools reference this entry */
if (is_array($config['load_balancer']['lbpool'])) {
foreach ($config['load_balancer']['lbpool'] as $pool) {
if ($pool['monitor'] == $a_monitor[$_GET['id']]['name']) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one pool.");
break;
}
}
}
if (count($input_errors) == 0) {
unset($a_monitor[$_POST['id']]);
write_config();
mark_subsystem_dirty('loadbalancer');
} else {
echo implode('\n', $input_errors);
}
}
exit;
} elseif (!empty($_POST['apply'])) {
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_monitor.php'));
exit;
}
}
$service_hook = 'relayd';
include("head.inc");
legacy_html_escape_form_data($a_monitor);
$main_buttons = array(
array('label'=>gettext('Add'), 'href'=>'load_balancer_monitor_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete host action
$(".act_delete").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("Load Balancer: Monitors");?>",
message: "<?=gettext("Do you really want to delete this entry?");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
if (data == "") {
// no errors
location.reload();
} else {
dialogRef.close();
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("Load Balancer: Monitors");?>",
message: data
});
}
});
}
}]
});
});
});
//]]>
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(gettext("The load balancer configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?=gettext("Name");?></th>
<th><?=gettext("Type");?></th>
<th><?=gettext("Description");?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($a_monitor as $monitor): ?>
<tr>
<td><?=$monitor['name'];?></td>
<td><?=$monitor['type'];?></td>
<td><?=$monitor['descr'];?></td>
<td>
<a href="load_balancer_monitor_edit.php?act=edit&amp;id=<?=$i;?>" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a data-id="<?=$i;?>" class="act_delete btn btn-default btn-xs">
<span class="fa fa-trash text-muted"></span>
</a>
</td>
</tr>
<?php
++$i;
endforeach;?>
</tbody>
</table>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2005-2008 Bill Marquette <bill.marquette@gmail.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, 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_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
}
$a_pool = &$config['load_balancer']['lbpool'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && $_POST['act'] == "del") {
if (isset($_POST['id']) && !empty($a_pool[$_POST['id']])){
$input_errors = array();
/* 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['poolname'] == $a_pool[$_POST['id']]['name']) {
$input_errors[] = gettext("This entry cannot be deleted because it is still referenced by at least one virtual server.");
break;
}
}
}
if (count($input_errors) == 0) {
unset($a_pool[$_POST['id']]);
write_config();
mark_subsystem_dirty('loadbalancer');
} else {
echo implode('\n', $input_errors);
}
}
exit;
} elseif (!empty($_POST['apply'])) {
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_monitor.php'));
exit;
}
}
/* Index monitor_type array for easy hyperlinking */
$mondex = array();
for ($i = 0; isset($config['load_balancer']['monitor_type'][$i]); $i++) {
$mondex[$config['load_balancer']['monitor_type'][$i]['name']] = $i;
}
$service_hook = 'relayd';
include("head.inc");
legacy_html_escape_form_data($a_pool);
$main_buttons = array(
array('label'=>gettext('Add'), 'href'=>'load_balancer_pool_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete host action
$(".act_delete").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("Load Balancer: Monitors");?>",
message: "<?=gettext("Do you really want to delete this entry?");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
if (data == "") {
// no errors
location.reload();
} else {
dialogRef.close();
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("Load Balancer: Monitors");?>",
message: data
});
}
});
}
}]
});
});
});
//]]>
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "<br />"));?><br />
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?=gettext("Name");?></th>
<th><?=gettext("Mode");?></th>
<th><?=gettext("Servers");?></th>
<th><?=gettext('Port');?></th>
<th><?=gettext('Monitor');?></th>
<th><?=gettext("Description");?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($a_pool as $pool): ?>
<tr>
<td><?=$pool['name'];?></td>
<td><?=$pool['mode'];?></td>
<td><?= !empty($pool['servers']) ? implode('<br/>', $pool['servers']) : '' ?></td>
<td><?=$pool['port'];?></td>
<td>
<a href="load_balancer_monitor_edit.php?id=<?=$mondex[$pool['monitor']];?>"><?=$pool['monitor'];?></a>
</td>
<td><?=$pool['descr'];?></td>
<td>
<a href="load_balancer_pool_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a data-id="<?=$i;?>" class="act_delete btn btn-default btn-xs">
<span class="fa fa-trash text-muted"></span>
</a>
<a href="load_balancer_pool_edit.php?act=dup&id=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone rule");?>">
<span class="fa fa-clone text-muted"></span>
</a>
</td>
</tr>
<?php
++$i;
endforeach;?>
</tbody>
<tfoot>
<tr>
<td colspan="7">
<?= sprintf(gettext('This feature is intended for server load balancing, not multi-WAN. For load balancing or failover for multiple WANs, use %sGateway Groups%s.'), '<a href="/system_gateway_groups.php">', '</a>'); ?>
</td>
</tr>
</tfoot>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2008 Bill Marquette <bill.marquette@gmail.com>
Copyright (C) 2012 Pierre POMES <pierre.pomes@gmail.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, 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_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
}
if (empty($config['load_balancer']['setting']) || !is_array($config['load_balancer']['setting'])) {
$config['load_balancer']['setting'] = array();
}
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array();
$pconfig['timeout'] = !empty($config['load_balancer']['setting']['timeout']) ? $config['load_balancer']['setting']['timeout'] : null;
$pconfig['interval'] = !empty($config['load_balancer']['setting']['interval']) ? $config['load_balancer']['setting']['interval'] : null;
$pconfig['prefork'] = !empty($config['load_balancer']['setting']['prefork']) ? $config['load_balancer']['setting']['prefork'] : null;
$pconfig['lb_use_sticky'] = isset($config['load_balancer']['setting']['lb_use_sticky']);
} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
$pconfig = $_POST;
$input_errors = array();
if (!empty($pconfig['apply'])) {
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_setting.php'));
exit;
} else {
/* input validation */
if (!empty($pconfig['timeout']) && !is_numeric($pconfig['timeout'])) {
$input_errors[] = gettext("Timeout must be a numeric value");
}
if (!empty($pconfig['interval']) && !is_numeric($pconfig['interval'])) {
$input_errors[] = gettext("Interval must be a numeric value");
}
if (!empty($pconfig['prefork'])) {
if (!is_numeric($pconfig['prefork'])) {
$input_errors[] = gettext("Prefork must be a numeric value");
} elseif ($pconfig['prefork']<=0 || $pconfig['prefork']>32) {
$input_errors[] = gettext("Prefork value must be between 1 and 32");
}
}
if (count($input_errors) == 0) {
$config['load_balancer']['setting']['timeout'] = $pconfig['timeout'];
$config['load_balancer']['setting']['interval'] = $pconfig['interval'];
$config['load_balancer']['setting']['prefork'] = $pconfig['prefork'];
if (!empty($pconfig['lb_use_sticky'])) {
$config['load_balancer']['setting']['lb_use_sticky'] = true;
} elseif (isset($config['load_balancer']['setting']['lb_use_sticky'])) {
unset($config['load_balancer']['setting']['lb_use_sticky']);
}
write_config();
mark_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_setting.php'));
exit;
}
}
}
$service_hook = 'relayd';
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(gettext("The load balancer configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped opnsense_standard_table_form">
<tr>
<td width="22%">
<strong><?=gettext("Global settings"); ?></strong>
</td>
<td width="78%" align="right">
<small><?=gettext("full help"); ?> </small>
<i class="fa fa-toggle-off text-danger" style="cursor: pointer;" id="show_all_help_page" type="button"></i>
</td>
</tr>
<tr>
<td><a id="help_for_timeout" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Timeout") ; ?></td>
<td>
<input type="text" name="timeout" id="timeout" value="<?=$pconfig['timeout'];?>" />
<div class="hidden" for="help_for_timeout">
<?=gettext("Set the global timeout in milliseconds for checks. Leave blank to use the default value of 1000 ms "); ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_interval" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Interval") ; ?></td>
<td>
<input type="text" name="interval" id="interval" value="<?=$pconfig['interval']; ?>"/>
<div class="hidden" for="help_for_interval">
<?=gettext("Set the interval in seconds at which the member of a pool will be checked. Leave blank to use the default interval of 10 seconds"); ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_prefork" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Prefork") ; ?></td>
<td>
<input type="text" name="prefork" id="prefork" value="<?=$pconfig['prefork']; ?>"/>
<div class="hidden" for="help_for_prefork">
<?=gettext("Number of processes used by relayd for dns protocol. Leave blank to use the default value of 5 processes"); ?>
</div>
</td>
</tr>
<tr>
<td><a id="help_for_lb_use_sticky" href="#" class="showhelp"><i class="fa fa-info-circle"></i></a> <?=gettext("Sticky connections");?> </td>
<td>
<input name="lb_use_sticky" type="checkbox" id="lb_use_sticky" value="yes" <?= !empty($pconfig['lb_use_sticky']) ? 'checked="checked"' : '';?>/>
<strong><?=gettext("Use sticky connections"); ?></strong><br />
<div class="hidden" for="help_for_lb_use_sticky">
<?=gettext("Successive connections will be redirected to the servers " .
"in a round-robin manner with connections from the same " .
"source being sent to the same web server. This 'sticky " .
"connection' will exist as long as there are states that " .
"refer to this connection. Once the states expire, so will " .
"the sticky connection. Further connections from that host " .
"will be redirected to the next web server in the round-robin."); ?>
</div>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input name="Submit" type="submit" class="btn btn-primary" value="<?=gettext("Save");?>" />
</td>
</tr>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2005-2008 Bill Marquette <bill.marquette@gmail.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, 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_once("guiconfig.inc");
require_once("filter.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("services.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']['virtual_server']) || !is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array();
}
$a_vs = &$config['load_balancer']['virtual_server'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (isset($_POST['act']) && $_POST['act'] == "del") {
if (isset($_POST['id']) && !empty($a_vs[$_POST['id']])){
relayd_cleanup_lb_mark_anchor($a_vs[$_POST['id']]['name']);
unset($a_vs[$_POST['id']]);
write_config();
mark_subsystem_dirty('loadbalancer');
}
exit;
} elseif (!empty($_POST['apply'])) {
relayd_configure_do();
filter_configure();
/* Wipe out old relayd anchors no longer in use. */
relayd_cleanup_lb_marked();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_virtual_server.php'));
exit;
}
}
/* Index lbpool array for easy hyperlinking */
$poodex = array();
for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) {
$poodex[$config['load_balancer']['lbpool'][$i]['name']] = $i;
}
$service_hook = 'relayd';
include("head.inc");
legacy_html_escape_form_data($a_vs);
$main_buttons = array(
array('label'=>gettext('Add'), 'href'=>'load_balancer_virtual_server_edit.php'),
);
?>
<body>
<script type="text/javascript">
$( document ).ready(function() {
// delete host action
$(".act_delete").click(function(event){
event.preventDefault();
var id = $(this).data("id");
// delete single
BootstrapDialog.show({
type:BootstrapDialog.TYPE_DANGER,
title: "<?= gettext("Load Balancer: Virtual Server Setup");?>",
message: "<?=gettext("Do you really want to delete this entry?");?>",
buttons: [{
label: "<?= gettext("No");?>",
action: function(dialogRef) {
dialogRef.close();
}}, {
label: "<?= gettext("Yes");?>",
action: function(dialogRef) {
$.post(window.location, {act: 'del', id:id}, function(data) {
location.reload();
});
}
}]
});
});
});
//]]>
</script>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(gettext("The virtual server configuration has been changed") . ".<br />" . gettext("You must apply the changes in order for them to take effect."));?><br />
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post" name="iform" id="iform">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?=gettext("Name");?></th>
<th><?=gettext("Protocol");?></th>
<th><?=gettext("IP Address");?></th>
<th><?=gettext('Port');?></th>
<th><?=gettext('Pool');?></th>
<th><?=gettext('Fall Back Pool');?></th>
<th><?=gettext("Description");?></th>
<th></th>
</tr>
</thead>
<tbody>
<?php
$i=0;
foreach ($a_vs as $vs):?>
<tr>
<td><?=$vs['name'];?></td>
<td><?=$vs['relay_protocol'];?></td>
<td><?=$vs['ipaddr'];?></td>
<td><?=$vs['port'];?></td>
<td>
<a href="load_balancer_pool_edit.php?id=<?=$poodex[$vs['poolname']];?>">
<?=$vs['poolname'];?>
</a>
<td>
<?php
if(!empty($vs['sitedown'])):?>
<a href="load_balancer_pool_edit.php?id=<?=$poodex[$vs['sitedown']];?>">
<?=$vs['sitedown'];?>
</a>
<?php
else:?>
<?=gettext("none");?>
<?php
endif;?>
<td><?=$vs['descr'];?></td>
<td>
<a href="load_balancer_virtual_server_edit.php?id=<?=$i;?>" class="btn btn-default btn-xs">
<span class="glyphicon glyphicon-pencil"></span>
</a>
<a data-id="<?=$i;?>" class="act_delete btn btn-default btn-xs">
<span class="fa fa-trash text-muted"></span>
</a>
<a href="load_balancer_virtual_server_edit.php?act=dup&id=<?=$i;?>" class="btn btn-default btn-xs" data-toggle="tooltip" title="<?=gettext("clone rule");?>">
<span class="fa fa-clone text-muted"></span>
</a>
</td>
</tr>
<?php
++$i;
endforeach;?>
</tbody>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
This diff is collapsed.
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
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_once("guiconfig.inc");
require_once("filter.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("services.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
}
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
}
$a_pool = &$config['load_balancer']['lbpool'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['apply'])) {
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /status_lb_pool.php'));
exit;
} else {
// change pool configuration (enabled/disabled servers)
$pconfig = $_POST;
if (!empty($pconfig['pools'])) {
foreach ($pconfig['pools'] as $form_pool) {
foreach ($a_pool as & $pool) {
if ($pool['name'] == $form_pool) {
$all_ips = array_merge((array) $pool['servers'], (array) $pool['serversdisabled']);
$new_disabled = array_diff($all_ips, (array)$pconfig[$form_pool]);
$new_enabled = (array)$pconfig[$form_pool];
$pool['servers'] = $new_enabled;
$pool['serversdisabled'] = $new_disabled;
}
}
}
mark_subsystem_dirty('loadbalancer');
write_config("Updated load balancer pools via status screen.");
}
header(url_safe('Location: /status_lb_pool.php'));
exit;
}
}
$service_hook = 'relayd';
include("head.inc");
$relay_hosts = relayd_get_lb_summary();
legacy_html_escape_form_data($a_pool);
legacy_html_escape_form_data($relay_hosts);
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "<br />"));?>
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<form method="post">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th><?=gettext("Name");?></th>
<th><?=gettext("Mode");?></th>
<th><?=gettext("Servers");?></th>
<th><?=gettext("Monitor");?></th>
<th><?=gettext("Description");?></th>
</tr>
</thead>
<tbody>
<?php
foreach ($a_pool as & $pool): ?>
<tr>
<td><?=$pool['name'];?></td>
<td>
<?php
switch($pool['mode']) {
case "loadbalance":
echo "Load balancing";
break;
case "failover":
echo "Manual failover";
break;
default:
echo "(default)";
}?>
</td>
<td>
<input type="hidden" name="pools[]" value="<?=$pool['name'];?>">
<table class="table table-condensed">
<?php
$pool_hosts=array();
$svr = array();
foreach ((array) $pool['servers'] as $server) {
$svr['addr']=$server;
$svr['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state'];
$svr['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail'];
$svr['bgcolor'] = $svr['state'] == 'up' ? "#90EE90" : "#F08080";
$pool_hosts[]=$svr;
}
foreach ((array) $pool['serversdisabled'] as $server) {
$svr['addr']="$server";
$svr['state']='disabled';
$svr['avail']='disabled';
$svr['bgcolor']='white';
$pool_hosts[]=$svr;
}
asort($pool_hosts);
foreach ($pool_hosts as $server):?>
<tr>
<td>
<input type="<?=$pool['mode'] == "loadbalance" ? "checkbox" : "radio";?>"
name="<?=$pool['name'];?>[]" value="<?=$server['addr'];?>"
<?=$server['state'] != 'disabled' ? "checked=\"checked\"" : "";?>
/>
</td>
<td style="background:<?=$server['bgcolor'];?>"><?="{$server['addr']}:{$pool['port']}";?></td>
<td style="background:<?=$server['bgcolor'];?>"><?=!empty($server['avail']) ? " ({$server['avail']}) " : "";?></td>
</tr>
<?php
endforeach;?>
</table>
</td>
<td><?=$pool['monitor']; ?></td>
<td><?=$pool['descr'];?></td>
</tr>
<?php
endforeach; ?>
<tr>
<td colspan="5">
<input name="Submit" type="submit" class="btn btn-primary" value="<?= gettext("Save"); ?>" />
</td>
</tr>
</tbody>
</table>
</div>
</form>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
/*
Copyright (C) 2014-2016 Deciso B.V.
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>.
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_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("plugins.inc.d/relayd.inc");
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$a_pool = array();
} else {
$a_pool = &$config['load_balancer']['lbpool'];
}
if (empty($config['load_balancer']['virtual_server']) || !is_array($config['load_balancer']['virtual_server'])) {
$a_vs = array();
} else {
$a_vs = &$config['load_balancer']['virtual_server'];
}
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['apply'])) {
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /status_lb_vs.php'));
exit;
}
}
$rdr_a = relayd_get_lb_redirects();
$service_hook = 'relayd';
legacy_html_escape_form_data($a_vs);
legacy_html_escape_form_data($a_pool);
legacy_html_escape_form_data($rdr_a);
include("head.inc");
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
<div class="container-fluid">
<div class="row">
<?php if (is_subsystem_dirty('loadbalancer')): ?><br/>
<?php print_info_box_apply(sprintf(gettext("The load balancer configuration has been changed%sYou must apply the changes in order for them to take effect."), "<br />"));?>
<?php endif; ?>
<section class="col-xs-12">
<div class="tab-content content-box col-xs-12">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<td><?=gettext("Name"); ?></td>
<td><?=gettext("Address"); ?></td>
<td><?=gettext("Servers"); ?></td>
<td><?=gettext("Status"); ?></td>
<td><?=gettext("Description"); ?></td>
</tr>
</thead>
<tbody>
<?php
$i = 0;
foreach ($a_vs as $vsent): ?>
<tr>
<td><?=$vsent['name'];?></td>
<td><?=$vsent['ipaddr']." : ".$vsent['port'];?></td>
<td>
<?php
foreach ($a_pool as $vipent):
if ($vipent['name'] == $vsent['poolname']):?>
<?=implode('<br/>',$vipent['servers']);?>
<?php
endif;
endforeach;?>
</td>
<?php
switch (trim($rdr_a[$vsent['name']]['status'])) {
case 'active':
$bgcolor = "#90EE90"; // lightgreen
$rdr_a[$vsent['name']]['status'] = "Active";
break;
case 'down':
$bgcolor = "#F08080"; // lightcoral
$rdr_a[$vsent['name']]['status'] = "Down";
break;
default:
$bgcolor = "#D3D3D3"; // lightgray
$rdr_a[$vsent['name']]['status'] = 'Unknown - relayd not running?';
}
?>
<td>
<table border="0" cellpadding="3" cellspacing="2" summary="status">
<tr><td bgcolor="<?=$bgcolor?>"><?=$rdr_a[$vsent['name']]['status']?> </td></tr>
</table>
<?=!empty($rdr_a[$vsent['name']]['total']) ? "Total Sessions: {$rdr_a[$vsent['name']]['total']}" : "";?>
<?=!empty($rdr_a[$vsent['name']]['last']) ? "<br />Last: {$rdr_a[$vsent['name']]['last']}" : "";?>
<?=!empty($rdr_a[$vsent['name']]['average']) ? "<br />Average: {$rdr_a[$vsent['name']]['average']}" : "";?>
</td>
<td><?=$vsent['descr'];?></td>
</tr>
<?php
$i++;
endforeach; ?>
</tbody>
</table>
</div>
</div>
</section>
</div>
</div>
</section>
<?php include("foot.inc"); ?>
<?php
$load_balancer_status_title = gettext('Load Balancer');
$load_balancer_status_title_link = 'status_lb_pool.php';
<?php
/*
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2010 Jim Pingle
Copyright (C) 2010 Seth Mos <seth.mos@dds.nl>
Copyright (C) 2005-2008 Bill Marquette
Copyright (C) 2004-2005 T. Lechat <dev@lechat.org>, Manuel Kasper <mk@neon1.net>
and Jonathan Watt <jwatt@jwatt.org>.
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_once("guiconfig.inc");
require_once("filter.inc");
require_once("plugins.inc.d/relayd.inc");
$now = time();
$year = date("Y");
if (!is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
}
if (!is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
}
if (!is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array();
}
$a_vs = &$config['load_balancer']['virtual_server'];
$a_pool = &$config['load_balancer']['lbpool'];
$rdr_a = relayd_get_lb_redirects();
$relay_hosts = relayd_get_lb_summary();
$lb_logfile = '/var/log/relayd.log';
$nentries = isset($config['syslog']['nentries']) ? $config['syslog']['nentries'] : 50;
?>
<table class="table table-striped table-condensed">
<thead>
<tr>
<th width="10%" class="listhdrr"><?= gettext('Server') ?></th>
<th width="10%" class="listhdrr"><?= gettext('Pool') ?></th>
<th width="30%" class="listhdr"><?= gettext('Description') ?></th>
</tr>
</thead>
<?php $i = 0; foreach ($a_vs as $vsent) :
?>
<tr>
<?php
switch (trim($rdr_a[$vsent['name']]['status'])) {
case 'active':
$bgcolor = "#90EE90"; // lightgreen
$rdr_a[$vsent['name']]['status'] = gettext("Active");
break;
case 'down':
$bgcolor = "#F08080"; // lightcoral
$rdr_a[$vsent['name']]['status'] = gettext("Down");
break;
default:
$bgcolor = "#D3D3D3"; // lightgray
$rdr_a[$vsent['name']]['status'] = gettext('Unknown - relayd not running?');
}
?>
<td class="listlr">
<?=$vsent['name'];?><br />
<span style="background-color: <?=$bgcolor?>; display: block"><i><?= $rdr_a[$vsent['name']]['status'] ?></i></span>
<?=$vsent['ipaddr'].":".$vsent['port'];?><br />
</td>
<td class="listr" align="center" >
<table>
<?php
foreach ($a_pool as $pool) {
if ($pool['name'] == $vsent['poolname']) {
$pool_hosts=array();
foreach ((array) $pool['servers'] as $server) {
$svr['ip']['addr']=$server;
$svr['ip']['state']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['state'];
$svr['ip']['avail']=$relay_hosts[$pool['name'].":".$pool['port']][$server]['avail'];
$pool_hosts[]=$svr;
}
foreach ((array) $pool['serversdisabled'] as $server) {
$svr['ip']['addr']="$server";
$svr['ip']['state']='disabled';
$svr['ip']['avail']='disabled';
$pool_hosts[]=$svr;
}
asort($pool_hosts);
foreach ((array) $pool_hosts as $server) {
if ($server['ip']['addr']!="") {
switch ($server['ip']['state']) {
case 'up':
$bgcolor = "#90EE90"; // lightgreen
$checked = "checked";
break;
case 'disabled':
$bgcolor = "#FFFFFF"; // white
$checked = "";
break;
default:
$bgcolor = "#F08080"; // lightcoral
$checked = "checked";
}
echo "<tr>";
echo "<td bgcolor=\"{$bgcolor}\">&nbsp;{$server['ip']['addr']}:{$pool['port']}&nbsp;</td><td bgcolor=\"{$bgcolor}\">&nbsp;";
if ($server['ip']['avail']) {
echo " ({$server['ip']['avail']}) ";
}
echo "&nbsp;</td></tr>";
}
}
}
}
?>
</table>
</td>
<td class="listbg" >
<?=$vsent['descr'];?>
</td>
</tr>
<?php $i++;
endforeach; ?>
</table>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment