Commit 0a1c328a authored by Franco Fichtner's avatar Franco Fichtner

relayd: extensive pluginification

(cherry picked from commit bd6c048d)
(cherry picked from commit 438ad5b7)
(cherry picked from commit bd6d928a)
(cherry picked from commit 8ab6fb4c)
(cherry picked from commit 6d2a95ae)
(cherry picked from commit a5e7a055)
(cherry picked from commit d35678f1)
(cherry picked from commit 1c1d4e07)
(cherry picked from commit 505c27c6)
(cherry picked from commit 7ad477ca)
parent b1e53ce1
......@@ -45,6 +45,9 @@
/usr/local/etc/inc/plugins.inc.d/if_ipsec.inc
/usr/local/etc/inc/plugins.inc.d/if_openvpn.inc
/usr/local/etc/inc/plugins.inc.d/miniupnpd.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/shaper.inc
/usr/local/etc/inc/plugins.inc.d/squid.inc
/usr/local/etc/inc/plugins.inc.d/suricata.inc
......@@ -55,9 +58,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
/usr/local/etc/inc/xmlrpc.inc
/usr/local/etc/inc/xmlrpc/legacy.inc
......@@ -443,6 +443,8 @@
/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.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/Menu/Menu.xml
/usr/local/opnsense/mvc/app/models/OPNsense/TrafficShaper/Migrations/M1_0_0.php
......
......@@ -1709,9 +1709,6 @@ function filter_nat_rules_generate(&$FilterIflist)
unset($tonathosts, $tonathosts_array, $numberofnathosts);
}
$natrules .= "\n# Load balancing\n";
$natrules .= "rdr-anchor \"relayd/*\"\n";
// prevent redirection on ports with "lock out" protection
if (!isset($config['system']['webgui']['noantilockout'])) {
$alports = filter_get_antilockout_ports();
......@@ -2490,9 +2487,6 @@ function filter_rules_generate(&$FilterIflist)
$ipfrules = "";
/* relayd */
$ipfrules .= "anchor \"relayd/*\"\n";
# BEGIN OF firewall rules
/* default block logging? */
$log = array("block"=>null,"pass"=>null);
......
<?php
/*
Copyright (C) 2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2005-2008 Bill Marquette
All rights reserved.
......@@ -8,11 +9,11 @@
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.
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.
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
......@@ -26,21 +27,75 @@
POSSIBILITY OF SUCH DAMAGE.
*/
function subnetv4_expand($subnet) {
function relayd_enabled()
{
global $config;
return isset($config['load_balancer']['lbpool']) && count($config['load_balancer']['lbpool']) &&
isset($config['load_balancer']['virtual_server']) && count($config['load_balancer']['virtual_server']);
}
function relayd_firewall($fw)
{
if (!relayd_enabled()) {
return;
}
$fw->registerAnchor('relayd/*', 'rdr');
$fw->registerAnchor('relayd/*', 'fw');
}
function relayd_services()
{
$services = array();
if (!relayd_enabled()) {
return $services;
}
$pconfig = array();
$pconfig['name'] = 'relayd';
$pconfig['description'] = gettext('Server load balancing daemon');
$pconfig['php']['restart'] = array('relayd_configure_do');
$pconfig['php']['start'] = array('relayd_configure_do');
$services[] = $pconfig;
return $services;
}
function relayd_syslog()
{
$logfacilities = array();
$logfacilities['relayd'] = array('facility' => array('relayd'), 'remote' => 'relayd');
return $logfacilities;
}
function relayd_subnetv4_expand($subnet)
{
$result = array();
list ($ip, $bits) = explode("/", $subnet);
$net = ip2long($ip);
$mask = (0xffffffff << (32 - $bits));
$net &= $mask;
$size = round(exp(log(2) * (32 - $bits)));
for ($i = 0; $i < $size; $i += 1) {
$result[] = long2ip($net | $i);
}
return $result;
}
function relayd_configure()
{
return array('relayd_configure_do');
}
function relayd_configure($kill_first = false)
function relayd_configure_do($kill_first = false)
{
global $config;
......@@ -59,10 +114,15 @@ function relayd_configure($kill_first = false)
} else {
$setting = array();
}
if (isset($config['load_balancer']['monitor_type']) && is_array($config['load_balancer']['monitor_type'])) {
$monitors_a = $config['load_balancer']['monitor_type'];
} else {
$monitors_a = array();
}
$check_a = array();
foreach ((array)$config['load_balancer']['monitor_type'] as $type) {
foreach ($monitors_a as $type) {
$type['options'] = isset($type['options']) ? $type['options'] : array();
switch($type['type']) {
case 'icmp':
......@@ -119,7 +179,7 @@ function relayd_configure($kill_first = false)
$conf .= "table <{$pool_a[$i]['name']}> {\n";
foreach ($pool_a[$i]['servers'] as $server) {
if (is_subnetv4($server)) {
foreach (subnetv4_expand($server) as $ip) {
foreach (relayd_subnetv4_expand($server) as $ip) {
$conf .= "\t{$ip}{$retrytext}\n";
}
} else {
......@@ -137,8 +197,8 @@ function relayd_configure($kill_first = false)
foreach ($vs_a as $vs) {
if (isset($vs['relay_protocol']) && !in_array($vs['relay_protocol'], $used_protocols)) {
$used_protocols[] = $vs['relay_protocol'];
if (is_file('/usr/local/etc/inc/vslb/'.basename($vs['relay_protocol']).'.proto')) {
$conf .= file_get_contents('/usr/local/etc/inc/vslb/'.basename($vs['relay_protocol']).'.proto')."\n";
if (is_file('/usr/local/etc/inc/plugins.inc.d/relayd/'.basename($vs['relay_protocol']).'.proto')) {
$conf .= file_get_contents('/usr/local/etc/inc/plugins.inc.d/relayd/'.basename($vs['relay_protocol']).'.proto')."\n";
}
}
}
......@@ -166,14 +226,14 @@ function relayd_configure($kill_first = false)
foreach (filter_expand_alias_array($vs_a[$i]['ipaddr']) as $item) {
log_error("item is $item");
if (is_subnetv4($item)) {
$ip_list = array_merge($ip_list, subnetv4_expand($item));
$ip_list = array_merge($ip_list, relayd_subnetv4_expand($item));
} else {
$ip_list[] = $item;
}
}
$append_ip_to_name = true;
} elseif (is_subnetv4($vs_a[$i]['ipaddr'])) {
$ip_list = subnetv4_expand($vs_a[$i]['ipaddr']);
$ip_list = relayd_subnetv4_expand($vs_a[$i]['ipaddr']);
$append_ip_to_name = true;
} else {
$ip_list = array($vs_a[$i]['ipaddr']);
......@@ -237,7 +297,7 @@ function relayd_configure($kill_first = false)
if ($kill_first) {
killbyname('relayd');
/* Remove all active relayd anchors now that relayd is no longer running. */
cleanup_lb_anchor('*');
relayd_cleanup_lb_anchor('*');
mwexec('/usr/local/sbin/relayd -f /var/etc/relayd.conf');
} else {
// it's running and there is a config, just reload
......@@ -253,17 +313,17 @@ function relayd_configure($kill_first = false)
*/
killbyname('relayd');
/* Remove all active relayd anchors now that relayd is no longer running. */
cleanup_lb_anchor("*");
relayd_cleanup_lb_anchor("*");
}
} elseif (!empty($vs_a)) {
// not running and there is a config, start it
/* Remove all active relayd anchors so it can start fresh. */
cleanup_lb_anchor('*');
relayd_cleanup_lb_anchor('*');
mwexec('/usr/local/sbin/relayd -f /var/etc/relayd.conf');
}
}
function get_lb_redirects()
function relayd_get_lb_redirects()
{
/*
# relayctl show summary
......@@ -338,7 +398,7 @@ Id Type Name Avlblty Status
return $vs;
}
function get_lb_summary()
function relayd_get_lb_summary()
{
$relayctl = array();
exec('/usr/local/sbin/relayctl show summary 2>&1', $relayctl);
......@@ -367,28 +427,26 @@ function get_lb_summary()
return $relay_hosts;
}
/* Get a list of all relayd virtual server anchors */
function get_lb_anchors() {
/* NOTE: These names come back prepended with "relayd/" e.g. "relayd/MyVSName" */
return explode("\n", trim(`/sbin/pfctl -sA -a relayd | /usr/bin/awk '{print $1;}'`));
}
/* Remove NAT rules from a relayd anchor that is no longer in use.
$anchorname can either be * to clear all anchors or a specific anchor name.*/
function cleanup_lb_anchor($anchorname = "*")
/*
* Remove NAT rules from a relayd anchor that is no longer in use.
* $anchorname can either be "*" to clear all anchors or a specific
* anchor name.
*/
function relayd_cleanup_lb_anchor($anchorname = "*")
{
$lbanchors = get_lb_anchors();
/* NOTE: These names come back prepended with "relayd/" e.g. "relayd/MyVSName" */
$lbanchors = explode("\n", trim(`/sbin/pfctl -sA -a relayd | /usr/bin/awk '{print $1;}'`));
foreach ($lbanchors as $lba) {
if (($anchorname == "*") || ($lba == "relayd/{$anchorname}")) {
/* Flush both the NAT and the Table for the anchor, so it will be completely removed by pf. */
mwexec("/sbin/pfctl -a " . escapeshellarg($lba) . " -F nat");
mwexec("/sbin/pfctl -a " . escapeshellarg($lba) . " -F Tables");
mwexecf('/sbin/pfctl -a %s -F nat', $lba);
mwexecf('/sbin/pfctl -a %s -F Tables', $lba);
}
}
}
/* Mark an anchor for later cleanup. This will allow us to remove an old VS name */
function cleanup_lb_mark_anchor($name)
function relayd_cleanup_lb_mark_anchor($name)
{
/* Nothing to do! */
if (empty($name)) {
......@@ -410,3 +468,39 @@ function cleanup_lb_mark_anchor($name)
file_put_contents($filename, implode("\n", $cleanup_anchors));
}
function relayd_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)) {
relayd_cleanup_lb_anchor($anchor);
}
}
@unlink($filename);
}
......@@ -2575,15 +2575,6 @@ function services_get()
$services[] = $pconfig;
}
if (isset($config['load_balancer']['virtual_server']) && isset($config['load_balancer']['lbpool']) && count($config['load_balancer']['virtual_server']) && count($config['load_balancer']['lbpool'])) {
$pconfig = array();
$pconfig['name'] = "relayd";
$pconfig['description'] = gettext("Server load balancing daemon");
$pconfig['php']['restart'] = array('relayd_configure', 'filter_configure');
$pconfig['php']['start'] = array('relayd_configure', 'filter_configure');
$services[] = $pconfig;
}
if (isset($config['OPNsense']['captiveportal']['zones']['zone'])) {
$enabled = false;
if (!empty($config['OPNsense']['captiveportal']['zones']['zone']['enabled'])) {
......
......@@ -798,7 +798,6 @@ function system_syslogd_start()
$syslogconfs['ntpd'] = array('facility' => array('ntp', 'ntpd', 'ntpdate'));
$syslogconfs['portalauth'] = array('facility' => array('captiveportal'), 'remote' => 'portalauth');
$syslogconfs['ppps'] = array('facility' => array('ppp'));
$syslogconfs['relayd'] = array('facility' => array('relayd'), 'remote' => 'relayd');
$syslogconfs['resolver'] = array('facility' => array('dnsmasq', 'filterdns', 'unbound'));
$syslogconfs['routing'] = array('facility' => array('radvd', 'routed', 'rtsold', 'olsrd', 'zebra', 'ospfd', 'bgpd', 'miniupnpd'));
$syslogconfs['wireless'] = array('facility' => array('hostapd'), 'remote' => 'hostapd');
......
......@@ -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");
......@@ -140,7 +140,7 @@ function filter_configure_xmlrpc()
services_dnsmasq_configure(false);
services_unbound_configure(false);
services_dhcpd_configure();
relayd_configure();
relayd_configure_do();
openvpn_resync_all();
return true;
......
......@@ -30,7 +30,6 @@
require_once("services.inc");
require_once("system.inc");
require_once("vslb.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();
/* start DHCP service */
services_dhcpd_configure();
......
......@@ -255,21 +255,6 @@
<IGMPProxy VisibleName="IGMP Proxy" url="/services_igmpproxy.php" cssClass="fa fa-map-signs fa-fw">
<Edit url="/services_igmpproxy_edit.php" visibility="hidden"/>
</IGMPProxy>
<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>
<NTP VisibleName="Network Time" cssClass="fa fa-clock-o fa-fw">
<General order="10" url="/services_ntpd.php"/>
<GPS order="20" url="/services_ntpd_gps.php"/>
......
......@@ -525,27 +525,6 @@
"interfaces_wireless.php*"
]
},
"page-loadbalancer-pool": {
"name": "WebCfg - Load Balancer: Pool page",
"descr": "Allow access to the 'Load Balancer: Pool' page.",
"match": [
"load_balancer_pool.php*"
]
},
"page-loadbalancer-pool-edit": {
"name": "WebCfg - Load Balancer: Pool: Edit page",
"descr": "Allow access to the 'Load Balancer: Pool: Edit' page.",
"match": [
"load_balancer_pool_edit.php*"
]
},
"page-loadbalancer-virtualserver-edit": {
"name": "WebCfg - Load Balancer: Virtual Server: Edit page",
"descr": "Allow access to the 'Load Balancer: Virtual Server: Edit' page.",
"match": [
"load_balancer_virtual_server_edit.php*"
]
},
"page-system-login\/logout": {
"name": "WebCfg - Lobby: Login \/ Logout \/ Dashboard page",
"descr": "Allow access to the 'Lobby: Login \/ Logout\/ Dashboard' page.",
......@@ -700,34 +679,6 @@
"services_igmpproxy_edit.php*"
]
},
"page-services-loadbalancer-monitor-edit": {
"name": "WebCfg - Services: Load Balancer: Monitor: Edit page",
"descr": "Allow access to the 'Services: Load Balancer: Monitor: Edit' page.",
"match": [
"load_balancer_monitor_edit.php*"
]
},
"page-services-loadbalancer-monitor": {
"name": "WebCfg - Services: Load Balancer: Monitors page",
"descr": "Allow access to the 'Services: Load Balancer: Monitors' page.",
"match": [
"load_balancer_monitor.php*"
]
},
"page-services-loadbalancer-setting": {
"name": "WebCfg - Services: Load Balancer: setting page",
"descr": "Allow access to the 'Settings: Load Balancer: Settings' page.",
"match": [
"load_balancer_setting.php*"
]
},
"page-services-loadbalancer-virtualservers": {
"name": "WebCfg - Services: Load Balancer: Virtual Servers page",
"descr": "Allow access to the 'Services: Load Balancer: Virtual Servers' page.",
"match": [
"load_balancer_virtual_server.php*"
]
},
"page-services-ntpd": {
"name": "WebCfg - Services: NTP",
"descr": "Allow access to the 'Services: NTP' page.",
......@@ -854,20 +805,6 @@
"diag_ipsec_spd.php*"
]
},
"page-status-loadbalancer-pool": {
"name": "WebCfg - Status: Load Balancer: Pool page",
"descr": "Allow access to the 'Status: Load Balancer: Pool' page.",
"match": [
"status_lb_pool.php*"
]
},
"page-status-loadbalancer-virtualserver": {
"name": "WebCfg - Status: Load Balancer: Virtual Server page",
"descr": "Allow access to the 'Status: Load Balancer: Virtual Server' page.",
"match": [
"status_lb_vs.php*"
]
},
"page-services-ntp-gps": {
"name": "WebCfg - Status: NTP GPS page",
"descr": "Allow access to the 'Status: NTP Serial GPS' page.",
......@@ -924,13 +861,6 @@
"diag_logs_ppp.php*"
]
},
"page-status-systemlogs-loadbalancer": {
"name": "WebCfg - Status: System logs: Load Balancer page",
"descr": "Allow access to the 'Status: System logs: Load Balancer' page.",
"match": [
"diag_logs_relayd.php*"
]
},
"page-status-systemlogs-ntpd": {
"name": "WebCfg - Status: System logs: NTP page",
"descr": "Allow access to the 'Status: System logs: NTP' page.",
......
<acl>
<page-services-loadbalancer-monitor-edit>
<name>WebCfg - Services: Load Balancer: Monitor: Edit page</name>
<description>Allow access to the 'Services: Load Balancer: Monitor: Edit' page.</description>
<patterns>
<pattern>load_balancer_monitor_edit.php*</pattern>
</patterns>
</page-services-loadbalancer-monitor-edit>
<page-services-loadbalancer-monitor>
<name>WebCfg - Services: Load Balancer: Monitors page</name>
<description>Allow access to the 'Services: Load Balancer: Monitors' page.</description>
<patterns>
<pattern>load_balancer_monitor.php*</pattern>
</patterns>
</page-services-loadbalancer-monitor>
<page-services-loadbalancer-setting>
<name>WebCfg - Services: Load Balancer: setting page</name>
<description>Allow access to the 'Settings: Load Balancer: Settings' page.</description>
<patterns>
<pattern>load_balancer_setting.php*</pattern>
</patterns>
</page-services-loadbalancer-setting>
<page-services-loadbalancer-virtualservers>
<name>WebCfg - Services: Load Balancer: Virtual Servers page</name>
<description>Allow access to the 'Services: Load Balancer: Virtual Servers' page.</description>
<patterns>
<pattern>load_balancer_virtual_server.php*</pattern>
</patterns>
</page-services-loadbalancer-virtualservers>
<page-status-loadbalancer-pool>
<name>WebCfg - Status: Load Balancer: Pool page</name>
<description>Allow access to the 'Status: Load Balancer: Pool' page.</description>
<patterns>
<pattern>status_lb_pool.php*</pattern>
</patterns>
</page-status-loadbalancer-pool>
<page-status-loadbalancer-virtualserver>
<name>WebCfg - Status: Load Balancer: Virtual Server page</name>
<description>Allow access to the 'Status: Load Balancer: Virtual Server' page.</description>
<patterns>
<pattern>status_lb_vs.php*</pattern>
</patterns>
</page-status-loadbalancer-virtualserver>
<page-status-systemlogs-loadbalancer>
<name>WebCfg - Status: System logs: Load Balancer page</name>
<description>Allow access to the 'Status: System logs: Load Balancer' page.</description>
<patterns>
<pattern>diag_logs_relayd.php*</pattern>
</patterns>
</page-status-systemlogs-loadbalancer>
<page-loadbalancer-pool>
<name>WebCfg - Load Balancer: Pool page</name>
<description>Allow access to the 'Load Balancer: Pool' page.</description>
<patterns>
<pattern>load_balancer_pool.php*</pattern>
</patterns>
</page-loadbalancer-pool>
<page-loadbalancer-pool-edit>
<name>WebCfg - Load Balancer: Pool: Edit page</name>
<description>Allow access to the 'Load Balancer: Pool: Edit' page.</description>
<patterns>
<pattern>load_balancer_pool_edit.php*</pattern>
</patterns>
</page-loadbalancer-pool-edit>
<page-loadbalancer-virtualserver-edit>
<name>WebCfg - Load Balancer: Virtual Server: Edit page</name>
<description>Allow access to the 'Load Balancer: Virtual Server: Edit' page.</description>
<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>
......@@ -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'])) {
......@@ -62,7 +62,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
exit;
} elseif (!empty($_POST['apply'])) {
/* reload all components that use igmpproxy */
relayd_configure();
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_monitor.php'));
......
......@@ -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']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
......@@ -61,7 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
}
exit;
} elseif (!empty($_POST['apply'])) {
relayd_configure();
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_monitor.php'));
......
......@@ -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;
......@@ -53,7 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = $_POST;
$input_errors = array();
if (!empty($pconfig['apply'])) {
relayd_configure();
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /load_balancer_setting.php'));
......@@ -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,17 +41,17 @@ $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');
}
exit;
} elseif (!empty($_POST['apply'])) {
relayd_configure();
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");
......@@ -45,7 +45,7 @@ $a_pool = &$config['load_balancer']['lbpool'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['apply'])) {
relayd_configure();
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /status_lb_pool.php'));
......@@ -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();
......@@ -45,7 +45,7 @@ if (empty($config['load_balancer']['virtual_server']) || !is_array($config['load
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
if (!empty($_POST['apply'])) {
relayd_configure();
relayd_configure_do();
filter_configure();
clear_subsystem_dirty('loadbalancer');
header(url_safe('Location: /status_lb_vs.php'));
......@@ -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