Commit 8ab6fb4c authored by Franco Fichtner's avatar Franco Fichtner

relayd: extensive pluginification

Not perfect yet, some spots still taint the backend with
requiring relayd.inc which should only be included by the
plugin's own files directly.
parent bd6d928a
......@@ -57,7 +57,6 @@
/usr/local/etc/inc/unbound.inc
/usr/local/etc/inc/upgrade_config.inc
/usr/local/etc/inc/util.inc
/usr/local/etc/inc/vslb.inc
/usr/local/etc/inc/vslb/dns.proto
/usr/local/etc/inc/vslb/tcp.proto
/usr/local/etc/inc/xmlparse.inc
......
This diff is collapsed.
This diff is collapsed.
......@@ -126,7 +126,7 @@ function filter_configure_xmlrpc()
require_once("system.inc");
require_once("util.inc");
require_once("interfaces.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("openvpn.inc");
require_once("services.inc");
require_once("rrd.inc");
......
......@@ -30,7 +30,7 @@
require_once("services.inc");
require_once("system.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once('util.inc');
require_once("unbound.inc");
require_once("openvpn.inc");
......
......@@ -49,8 +49,6 @@ require_once("system.inc");
echo ".";
require_once("unbound.inc");
echo ".";
require_once("vslb.inc");
echo ".";
require_once("filter.inc");
echo ".";
require_once("ipsec.inc");
......@@ -200,9 +198,6 @@ echo "Starting NTP time client...";
system_ntp_configure(false);
echo "done.\n";
/* start load balancer daemon */
relayd_configure_do();
/* start DHCP service */
services_dhcpd_configure();
......
......@@ -29,7 +29,6 @@
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("config.inc");
......@@ -38,7 +37,7 @@ require_once("util.inc");
require_once("xmlrpc.inc");
require_once("interfaces.inc");
require_once("openvpn.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("system.inc");
require_once("services.inc");
require_once("rrd.inc");
......
......@@ -30,7 +30,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("vslb.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'])) {
......
......@@ -30,7 +30,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (!is_array($config['load_balancer']['lbpool'])) {
......
......@@ -31,7 +31,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
......@@ -42,7 +42,6 @@ if (empty($config['load_balancer']['setting']) || !is_array($config['load_balanc
$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;
......@@ -94,12 +93,12 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
$service_hook = 'relayd';
legacy_html_escape_form_data($pconfig);
include("head.inc");
?>
?>
<body>
<?php include("fbegin.inc"); ?>
<section class="page-content-main">
......
......@@ -29,48 +29,10 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("services.inc");
require_once("interfaces.inc");
/* Cleanup relayd anchors that have been marked for cleanup. */
function cleanup_lb_marked()
{
global $config;
$filename = '/tmp/relayd_anchors_remove';
$cleanup_anchors = array();
/* Nothing to do! */
if (!file_exists($filename)) {
return;
} else {
$cleanup_anchors = explode("\n", file_get_contents($filename));
/* Nothing to do! */
if (empty($cleanup_anchors)) {
return;
}
}
/* Load current names so we can make sure we don't remove an anchor that is still in use. */
$active_vsnames = array();
if (isset($config['load_balancer']['virtual_server'])) {
foreach ($config['load_balancer']['virtual_server'] as $vs) {
$active_vsnames[] = $vs['name'];
}
}
foreach ($cleanup_anchors as $anchor) {
/* Only cleanup an anchor if it is not still active. */
if (!in_array($anchor, $active_vsnames)) {
cleanup_lb_anchor($anchor);
}
}
@unlink($filename);
}
if (empty($config['load_balancer']['virtual_server']) || !is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array();
}
......@@ -79,7 +41,7 @@ $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']])){
cleanup_lb_mark_anchor($a_vs[$_POST['id']]['name']);
relayd_cleanup_lb_mark_anchor($a_vs[$_POST['id']]['name']);
unset($a_vs[$_POST['id']]);
write_config();
mark_subsystem_dirty('loadbalancer');
......@@ -89,7 +51,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
relayd_configure_do();
filter_configure();
/* Wipe out old relayd anchors no longer in use. */
cleanup_lb_marked();
relayd_cleanup_lb_marked();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_virtual_server.php'));
exit;
......
......@@ -29,7 +29,7 @@
require_once("guiconfig.inc");
require_once("services.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("interfaces.inc");
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
......@@ -116,7 +116,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
if (isset($id)) {
if ($a_vs[$id]['name'] != $pconfig['name']) {
/* Because the VS name changed, mark the old name for cleanup. */
cleanup_lb_mark_anchor($a_vs[$id]['name']);
relayd_cleanup_lb_mark_anchor($a_vs[$id]['name']);
}
$a_vs[$id] = $vsent;
} else {
......
......@@ -29,7 +29,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
require_once("services.inc");
require_once("interfaces.inc");
......@@ -76,11 +76,11 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$service_hook = 'relayd';
include("head.inc");
$relay_hosts = get_lb_summary();
$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">
......
......@@ -30,7 +30,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$a_pool = array();
......@@ -53,7 +53,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
}
$rdr_a = get_lb_redirects();
$rdr_a = relayd_get_lb_redirects();
$service_hook = 'relayd';
legacy_html_escape_form_data($a_vs);
......
......@@ -30,7 +30,6 @@
require_once("guiconfig.inc");
require_once("services.inc");
require_once("vslb.inc");
require_once("system.inc");
require_once("unbound.inc");
require_once("openvpn.inc");
......
......@@ -32,7 +32,6 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("ipsec.inc");
require_once("vslb.inc");
require_once("system.inc");
require_once("services.inc");
require_once("interfaces.inc");
......
......@@ -33,7 +33,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("vslb.inc");
require_once("plugins.inc.d/relayd.inc");
$now = time();
$year = date("Y");
......@@ -49,15 +49,14 @@ if (!is_array($config['load_balancer']['virtual_server'])) {
}
$a_vs = &$config['load_balancer']['virtual_server'];
$a_pool = &$config['load_balancer']['lbpool'];
$rdr_a = get_lb_redirects();
$relay_hosts = get_lb_summary();
$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>
......
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