diff --git a/net/relayd/src/etc/inc/plugins.inc.d/relayd.inc b/net/relayd/src/etc/inc/plugins.inc.d/relayd.inc
new file mode 100644
index 000000000..474ef00c1
--- /dev/null
+++ b/net/relayd/src/etc/inc/plugins.inc.d/relayd.inc
@@ -0,0 +1,522 @@
+
+ Copyright (C) 2005-2008 Bill Marquette
+ 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.
+*/
+
+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('Relayd Load Balancer');
+ $pconfig['php']['restart'] = array('relayd_configure_do');
+ $pconfig['php']['start'] = array('relayd_configure_do');
+ $services[] = $pconfig;
+
+ return $services;
+}
+
+function relayd_xmlrpc_sync()
+{
+ $result = array();
+
+ $result[] = array(
+ 'description' => gettext('Relayd Load Balancer'),
+ 'section' => 'load_balancer',
+ 'id' => 'lb',
+ );
+
+ return $result;
+}
+
+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(
+ 'bootup' => array('relayd_configure_do'),
+ 'remote' => array('relayd_configure_do'),
+ );
+}
+
+function relayd_configure_do($kill_first = false)
+{
+ global $config;
+
+ if (isset($config['load_balancer']['virtual_server']) && is_array($config['load_balancer']['virtual_server'])) {
+ $vs_a = $config['load_balancer']['virtual_server'];
+ } else {
+ $vs_a = array();
+ }
+ if (isset($config['load_balancer']['lbpool']) && is_array($config['load_balancer']['lbpool'])) {
+ $pool_a = $config['load_balancer']['lbpool'];
+ } else {
+ $pool_a = array();
+ }
+ if (isset($config['load_balancer']['setting']) && is_array($config['load_balancer']['setting'])) {
+ $setting = $config['load_balancer']['setting'];
+ } 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 ($monitors_a as $type) {
+ $type['options'] = isset($type['options']) ? $type['options'] : array();
+ switch($type['type']) {
+ case 'icmp':
+ case 'tcp':
+ $check_a[$type['name']] = 'check ' . $type['type'];
+ break;
+ case 'http':
+ case 'https':
+ $check_a[$type['name']] = 'check ' . $type['type']. " ";
+ if (!empty($type['options']['path'])) {
+ $check_a[$type['name']] .= "'".$type['options']['path'] . "' ";
+ }
+ if (!empty($type['options']['host'])) {
+ $check_a[$type['name']] .= "host ".$type['options']['host'] . " ";
+ }
+ $check_a[$type['name']] .= "code " . $type['options']['code'];
+ break;
+ case 'send':
+ $check_a[$type['name']] = "send ";
+ $check_a[$type['name']] .= !empty($type['options']['send']) ? "\"{$type['options']['send']}\"" : "\"\"" ;
+ $check_a[$type['name']] .= " expect ";
+ $check_a[$type['name']] .= !empty($type['options']['expect']) ? "\"{$type['options']['expect']}\"" : "\"\"" ;
+ break;
+ }
+ }
+
+ $fd = fopen('/var/etc/relayd.conf', 'w');
+ $conf = "log updates \n";
+
+ if (!empty($setting['timeout'])) {
+ $conf .= "timeout ".$setting['timeout']." \n";
+ } else {
+ $conf .= "timeout 1000 \n";
+ }
+
+ if (!empty($setting['interval'])) {
+ $conf .= "interval ".$setting['interval']." \n";
+ }
+
+ if (!empty($setting['prefork'])) {
+ $conf .= "prefork ".$setting['prefork']." \n";
+ }
+
+ /* reindex pools by name as we loop through the pools array */
+ $pools = array();
+ /* Virtual server pools */
+ for ($i = 0; isset($pool_a[$i]); $i++) {
+ if (is_array($pool_a[$i]['servers'])) {
+ if (!empty($pool_a[$i]['retry'])) {
+ $retrytext = " retry {$pool_a[$i]['retry']}";
+ } else {
+ $retrytext = "";
+ }
+ $conf .= "table <{$pool_a[$i]['name']}> {\n";
+ foreach ($pool_a[$i]['servers'] as $server) {
+ if (is_subnetv4($server)) {
+ foreach (relayd_subnetv4_expand($server) as $ip) {
+ $conf .= "\t{$ip}{$retrytext}\n";
+ }
+ } else {
+ $conf .= "\t{$server}{$retrytext}\n";
+ }
+ }
+ $conf .= "}\n";
+ /* Index by name for easier fetching when we loop through the virtual servers */
+ $pools[$pool_a[$i]['name']] = $pool_a[$i];
+ }
+ }
+
+ // collect used protocols
+ $used_protocols = array();
+ 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/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";
+ }
+ }
+ }
+
+ for ($i = 0; isset($vs_a[$i]); $i++) {
+ $append_port_to_name = false;
+ if (is_alias($pools[$vs_a[$i]['poolname']]['port'])) {
+ $dest_port_array = filter_expand_alias_array($pools[$vs_a[$i]['poolname']]['port']);
+ $append_port_to_name = true;
+ } else {
+ $dest_port_array = array($pools[$vs_a[$i]['poolname']]['port']);
+ }
+ if (is_alias($vs_a[$i]['port'])) {
+ $src_port_array = filter_expand_alias_array($vs_a[$i]['port']);
+ $append_port_to_name = true;
+ } elseif ($vs_a[$i]['port']) {
+ $src_port_array = array($vs_a[$i]['port']);
+ } else {
+ $src_port_array = $dest_port_array;
+ }
+
+ $append_ip_to_name = false;
+ if (is_alias($vs_a[$i]['ipaddr'])) {
+ $ip_list = array();
+ 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, relayd_subnetv4_expand($item));
+ } else {
+ $ip_list[] = $item;
+ }
+ }
+ $append_ip_to_name = true;
+ } elseif (is_subnetv4($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']);
+ }
+
+ for ($j = 0; $j < count($ip_list); $j += 1) {
+ $ip = $ip_list[$j];
+ for ($k = 0; $k < count($src_port_array) && $k < count($dest_port_array); $k += 1) {
+ $src_port = $src_port_array[$k];
+ $dest_port = $dest_port_array[$k];
+
+ $name = $vs_a[$i]['name'];
+ if ($append_ip_to_name) {
+ $name .= "_" . $j;
+ }
+ if ($append_port_to_name) {
+ $name .= "_" . $src_port;
+ }
+
+ if ($vs_a[$i]['mode'] == 'relay') {
+ // relay mode
+ $conf .= "relay \"{$name}\" {\n";
+ $conf .= " listen on {$ip} port {$src_port} \n";
+ $conf .= " protocol \"{$vs_a[$i]['relay_protocol']}\"\n";
+ $lbmode = "";
+ if ($pools[$vs_a[$i]['poolname']]['mode'] == "loadbalance") {
+ $lbmode = "mode loadbalance";
+ }
+
+ $conf .= " forward to <{$vs_a[$i]['poolname']}> port {$dest_port} {$lbmode} {$check_a[$pools[$vs_a[$i]['poolname']]['monitor']]} \n";
+
+ if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0 && ($vs_a[$i]['relay_protocol'] != 'dns')) {
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$dest_port} {$lbmode} {$check_a[$pools[$vs_a[$i]['poolname']]['monitor']]} \n";
+ }
+ $conf .= "}\n";
+ } else {
+ // redirect mode
+ $conf .= "redirect \"{$name}\" {\n";
+ $conf .= " listen on {$ip} port {$src_port}\n";
+ $conf .= " forward to <{$vs_a[$i]['poolname']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['poolname']]['monitor']]} \n";
+
+ if (isset($config['load_balancer']['setting']['lb_use_sticky'])) {
+ $conf .= " sticky-address\n";
+ }
+
+ /* sitedown MUST use the same port as the primary pool - sucks, but it's a relayd thing */
+ if (isset($vs_a[$i]['sitedown']) && strlen($vs_a[$i]['sitedown']) > 0 && ($vs_a[$i]['relay_protocol'] != 'dns')) {
+ $conf .= " forward to <{$vs_a[$i]['sitedown']}> port {$dest_port} {$check_a[$pools[$vs_a[$i]['sitedown']]['monitor']]} \n";
+ }
+
+ $conf .= "}\n";
+ }
+ }
+ }
+ }
+ fwrite($fd, $conf);
+ fclose($fd);
+
+ if (is_process_running('relayd')) {
+ if (! empty($vs_a)) {
+ if ($kill_first) {
+ killbyname('relayd');
+ /* Remove all active relayd anchors now that relayd is no longer running. */
+ 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
+ mwexec('/usr/local/sbin/relayctl reload');
+ }
+ } else {
+ /*
+ * XXX: Something breaks our control connection with relayd
+ * and makes 'relayctl stop' not work
+ * rule reloads are the current suspect
+ * mwexec('/usr/local/sbin/relayctl stop');
+ * returns "command failed"
+ */
+ killbyname('relayd');
+ /* Remove all active relayd anchors now that relayd is no longer running. */
+ 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. */
+ relayd_cleanup_lb_anchor('*');
+ mwexec('/usr/local/sbin/relayd -f /var/etc/relayd.conf');
+ }
+}
+
+function relayd_get_lb_redirects()
+{
+/*
+# relayctl show summary
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+5 table test2:80 active (3 hosts up)
+11 host 192.168.1.2 91.55% up
+10 host 192.168.1.3 100.00% up
+9 host 192.168.1.4 88.73% up
+3 table test:80 active (1 hosts up)
+7 host 192.168.1.2 66.20% down
+6 host 192.168.1.3 97.18% up
+0 redirect testvs active
+3 table test:80 active (1 hosts up)
+7 host 192.168.1.2 66.20% down
+6 host 192.168.1.3 97.18% up
+4 table testvs-sitedown:80 active (1 hosts up)
+8 host 192.168.1.4 84.51% up
+# relayctl show redirects
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+0 redirect testvs active
+# relayctl show redirects
+Id Type Name Avlblty Status
+1 redirect testvs2 active
+ total: 2 sessions
+ last: 2/60s 2/h 2/d sessions
+ average: 1/60s 0/h 0/d sessions
+0 redirect testvs active
+*/
+ $rdr_a = array();
+ exec('/usr/local/sbin/relayctl show redirects 2>&1', $rdr_a);
+ $relay_a = array();
+ exec('/usr/local/sbin/relayctl show relays 2>&1', $relay_a);
+ $vs = array();
+ $cur_entry = "";
+ for ($i = 0; isset($rdr_a[$i]); $i++) {
+ $line = $rdr_a[$i];
+ if (preg_match("/^[0-9]+/", $line)) {
+ $regs = array();
+ if ($x = preg_match("/^[0-9]+\s+redirect\s+([^\s]+)\s+([^\s]+)/", $line, $regs)) {
+ $cur_entry = trim($regs[1]);
+ $vs[trim($regs[1])] = array();
+ $vs[trim($regs[1])]['status'] = trim($regs[2]);
+ }
+ } elseif (($x = preg_match("/^\s+total:\s(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['total'] = trim($regs[1]);
+ } elseif (($x = preg_match("/^\s+last:\s(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['last'] = trim($regs[1]);
+ } elseif (($x = preg_match("/^\s+average:(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['average'] = trim($regs[1]);
+ }
+ }
+ $cur_entry = "";
+ for ($i = 0; isset($relay_a[$i]); $i++) {
+ $line = $relay_a[$i];
+ if (preg_match("/^[0-9]+/", $line)) {
+ $regs = array();
+ if ($x = preg_match("/^[0-9]+\s+relay\s+([^\s]+)\s+([^\s]+)/", $line, $regs)) {
+ $cur_entry = trim($regs[1]);
+ $vs[trim($regs[1])] = array();
+ $vs[trim($regs[1])]['status'] = trim($regs[2]);
+ }
+ } elseif (($x = preg_match("/^\s+total:\s(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['total'] = trim($regs[1]);
+ } elseif (($x = preg_match("/^\s+last:\s(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['last'] = trim($regs[1]);
+ } elseif (($x = preg_match("/^\s+average:(.*)\ssessions/", $line, $regs)) && !empty($cur_entry)) {
+ $vs[$cur_entry]['average'] = trim($regs[1]);
+ }
+ }
+ return $vs;
+}
+
+function relayd_get_lb_summary()
+{
+ $relayctl = array();
+ exec('/usr/local/sbin/relayctl show summary 2>&1', $relayctl);
+ $relay_hosts=Array();
+ foreach( (array) $relayctl as $line) {
+ $t = explode("\t", $line);
+ if (isset($t[1])) {
+ switch (trim($t[1])) {
+ case "table":
+ $curpool=trim($t[2]);
+ break;
+ case "host":
+ $curhost=trim($t[2]);
+ if (!isset($relay_hosts[$curpool])) {
+ $relay_hosts[$curpool] = array();
+ }
+ if (!isset($relay_hosts[$curpool][$curhost])) {
+ $relay_hosts[$curpool][$curhost]['avail'] = array();
+ }
+ $relay_hosts[$curpool][$curhost]['avail']=trim($t[3]);
+ $relay_hosts[$curpool][$curhost]['state']=trim($t[4]);
+ break;
+ }
+ }
+ }
+ return $relay_hosts;
+}
+
+/*
+ * 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 = "*")
+{
+ /* 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. */
+ 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 relayd_cleanup_lb_mark_anchor($name)
+{
+ /* Nothing to do! */
+ if (empty($name)) {
+ return;
+ }
+
+ $filename = '/tmp/relayd_anchors_remove';
+ $cleanup_anchors = array();
+
+ /* Read in any currently unapplied name changes */
+ if (file_exists($filename)) {
+ $cleanup_anchors = explode("\n", file_get_contents($filename));
+ }
+
+ /* Only add the anchor to the list if it's not already there. */
+ if (!in_array($name, $cleanup_anchors)) {
+ $cleanup_anchors[] = $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);
+}
diff --git a/net/relayd/src/etc/inc/plugins.inc.d/relayd/dns.proto b/net/relayd/src/etc/inc/plugins.inc.d/relayd/dns.proto
new file mode 100644
index 000000000..0f90ff041
--- /dev/null
+++ b/net/relayd/src/etc/inc/plugins.inc.d/relayd/dns.proto
@@ -0,0 +1,3 @@
+dns protocol "dns" {
+ tcp { nodelay, sack, socket buffer 1024, backlog 1000 }
+}
diff --git a/net/relayd/src/etc/inc/plugins.inc.d/relayd/tcp.proto b/net/relayd/src/etc/inc/plugins.inc.d/relayd/tcp.proto
new file mode 100644
index 000000000..bb20afd89
--- /dev/null
+++ b/net/relayd/src/etc/inc/plugins.inc.d/relayd/tcp.proto
@@ -0,0 +1,3 @@
+protocol "tcp" {
+ tcp { nodelay, socket buffer 65536 }
+}
diff --git a/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/ACL/ACL.xml b/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/ACL/ACL.xml
new file mode 100644
index 000000000..305cf9b02
--- /dev/null
+++ b/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/ACL/ACL.xml
@@ -0,0 +1,62 @@
+
+
+ Services: Load Balancer: Monitor: Edit
+
+ load_balancer_monitor_edit.php*
+
+
+
+ Services: Load Balancer: Monitors
+
+ load_balancer_monitor.php*
+
+
+
+ Services: Load Balancer: setting
+
+ load_balancer_setting.php*
+
+
+
+ Services: Load Balancer: Virtual Servers
+
+ load_balancer_virtual_server.php*
+
+
+
+ Status: Load Balancer: Pool
+
+ status_lb_pool.php*
+
+
+
+ Status: Load Balancer: Virtual Server
+
+ status_lb_vs.php*
+
+
+
+ Status: System logs: Load Balancer
+
+ diag_logs_relayd.php*
+
+
+
+ Load Balancer: Pool
+
+ load_balancer_pool.php*
+
+
+
+ Load Balancer: Pool: Edit
+
+ load_balancer_pool_edit.php*
+
+
+
+ Load Balancer: Virtual Server: Edit
+
+ load_balancer_virtual_server_edit.php*
+
+
+
diff --git a/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/Menu/Menu.xml b/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/Menu/Menu.xml
new file mode 100644
index 000000000..bb37abba1
--- /dev/null
+++ b/net/relayd/src/opnsense/mvc/app/models/OPNsense/Relayd/Menu/Menu.xml
@@ -0,0 +1,19 @@
+
diff --git a/net/relayd/src/www/diag_logs_relayd.php b/net/relayd/src/www/diag_logs_relayd.php
new file mode 100644
index 000000000..4bb293dec
--- /dev/null
+++ b/net/relayd/src/www/diag_logs_relayd.php
@@ -0,0 +1,6 @@
+.
+ 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'),
+);
+
+?>
+
+
+
+
+
+
+
+
+
+ " . gettext("You must apply the changes in order for them to take effect."));?>
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_monitor_edit.php b/net/relayd/src/www/load_balancer_monitor_edit.php
new file mode 100644
index 000000000..09cd208dd
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_monitor_edit.php
@@ -0,0 +1,339 @@
+.
+ 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("services.inc");
+require_once("interfaces.inc");
+
+$rfc2616 = array(
+ 100 => "100 Continue",
+ 101 => "101 Switching Protocols",
+ 200 => "200 OK",
+ 201 => "201 Created",
+ 202 => "202 Accepted",
+ 203 => "203 Non-Authoritative Information",
+ 204 => "204 No Content",
+ 205 => "205 Reset Content",
+ 206 => "206 Partial Content",
+ 300 => "300 Multiple Choices",
+ 301 => "301 Moved Permanently",
+ 302 => "302 Found",
+ 303 => "303 See Other",
+ 304 => "304 Not Modified",
+ 305 => "305 Use Proxy",
+ 306 => "306 (Unused)",
+ 307 => "307 Temporary Redirect",
+ 400 => "400 Bad Request",
+ 401 => "401 Unauthorized",
+ 402 => "402 Payment Required",
+ 403 => "403 Forbidden",
+ 404 => "404 Not Found",
+ 405 => "405 Method Not Allowed",
+ 406 => "406 Not Acceptable",
+ 407 => "407 Proxy Authentication Required",
+ 408 => "408 Request Timeout",
+ 409 => "409 Conflict",
+ 410 => "410 Gone",
+ 411 => "411 Length Required",
+ 412 => "412 Precondition Failed",
+ 413 => "413 Request Entity Too Large",
+ 414 => "414 Request-URI Too Long",
+ 415 => "415 Unsupported Media Type",
+ 416 => "416 Requested Range Not Satisfiable",
+ 417 => "417 Expectation Failed",
+ 500 => "500 Internal Server Error",
+ 501 => "501 Not Implemented",
+ 502 => "502 Bad Gateway",
+ 503 => "503 Service Unavailable",
+ 504 => "504 Gateway Timeout",
+ 505 => "505 HTTP Version Not Supported"
+);
+
+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'] === 'GET') {
+ if (isset($_GET['id']) && !empty($a_monitor[$_GET['id']])) {
+ $id = $_GET['id'];
+ }
+ $pconfig = array();
+ foreach (array('name', 'type', 'descr') as $fieldname) {
+ if (isset($id) && isset($a_monitor[$id][$fieldname])) {
+ $pconfig[$fieldname] = $a_monitor[$id][$fieldname];
+ } else {
+ $pconfig[$fieldname] = null;
+ }
+ }
+ if (isset($id)) {
+ $pconfig['options_send'] = isset($a_monitor[$id]['options']['send']) ? $a_monitor[$id]['options']['send'] : null;
+ $pconfig['options_expect'] = isset($a_monitor[$id]['options']['expect']) ? $a_monitor[$id]['options']['expect'] : null;
+ $pconfig['options_path'] = isset($a_monitor[$id]['options']['path']) ? $a_monitor[$id]['options']['path'] : null;
+ $pconfig['options_host'] = isset($a_monitor[$id]['options']['host']) ? $a_monitor[$id]['options']['host'] : null;
+ $pconfig['options_code'] = isset($a_monitor[$id]['options']['code']) ? $a_monitor[$id]['options']['code'] : null;
+ } else {
+ /* option defaults */
+ $pconfig['options_send'] = null;
+ $pconfig['options_expect'] = null;
+ $pconfig['options_path'] = '/';
+ $pconfig['options_code'] = 200;
+ $pconfig['options_host'] = null;
+ }
+} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ if (isset($_POST['id']) && !empty($a_monitor[$_POST['id']])) {
+ $id = $_POST['id'];
+ }
+ $pconfig = $_POST;
+ $input_errors = array();
+
+ /* input validation */
+ $reqdfields = explode(" ", "name type descr");
+ $reqdfieldsn = array(gettext("Name"),gettext("Type"),gettext("Description"));
+
+ do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
+ /* Ensure that our monitor names are unique */
+ for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) {
+ if ($pconfig['name'] == $config['load_balancer']['monitor_type'][$i]['name'] && $i != $id) {
+ $input_errors[] = gettext("This monitor name has already been used. Monitor names must be unique.");
+ }
+ }
+
+ if (strpos($pconfig['name'], " ") !== false) {
+ $input_errors[] = gettext("You cannot use spaces in the 'name' field.");
+ }
+ switch($pconfig['type']) {
+ case 'icmp':
+ case 'tcp':
+ break;
+ case 'http':
+ case 'https':
+ if (!empty($pconfig['options_host']) && !is_hostname($pconfig['options_host'])) {
+ $input_errors[] = gettext("The hostname can only contain the characters A-Z, 0-9 and '-'.");
+ }
+ if (!empty($pconfig['options_code']) && !isset($rfc2616[$pconfig['options_code']])) {
+ $input_errors[] = gettext("HTTP(S) codes must be from RFC 2616.");
+ }
+ if (empty($pconfig['options_path'])) {
+ $input_errors[] = gettext("The path to monitor must be set.");
+ }
+ break;
+ case 'send':
+ break;
+ }
+
+ if (count($input_errors) == 0) {
+ $monent = array();
+ $monent['name'] = $pconfig['name'];
+ $monent['type'] = $pconfig['type'];
+ $monent['descr'] = $pconfig['descr'];
+ $monent['options'] = array();
+ if($pconfig['type'] == "http" || $pconfig['type'] == "https") {
+ $monent['options']['path'] = $pconfig['options_path'];
+ $monent['options']['host'] = $pconfig['options_host'];
+ $monent['options']['code'] = $pconfig['options_code'];
+ } elseif ($pconfig['type'] == "send") {
+ $monent['options']['send'] = $pconfig['options_send'];
+ $monent['options']['expect'] = $pconfig['options_expect'];
+ }
+
+ if (isset($id)) {
+ /* modify all pools with this name */
+ for ($i = 0; isset($config['load_balancer']['lbpool'][$i]); $i++) {
+ if ($config['load_balancer']['lbpool'][$i]['monitor'] == $a_monitor[$id]['name']) {
+ $config['load_balancer']['lbpool'][$i]['monitor'] = $monent['name'];
+ }
+ }
+ $a_monitor[$id] = $monent;
+ } else {
+ $a_monitor[] = $monent;
+ }
+
+ mark_subsystem_dirty('loadbalancer');
+ write_config();
+ header(url_safe('Location: /load_balancer_monitor.php'));
+ exit;
+ }
+}
+
+$service_hook = 'relayd';
+
+include("head.inc");
+legacy_html_escape_form_data($pconfig);
+$types = array("icmp" => gettext("ICMP"), "tcp" => gettext("TCP"), "http" => gettext("HTTP"), "https" => gettext("HTTPS"), "send" => gettext("Send/Expect"));
+?>
+
+
+
+
+
+
+
+
+ 0) print_input_errors($input_errors); ?>
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_pool.php b/net/relayd/src/www/load_balancer_pool.php
new file mode 100644
index 000000000..db5dc7386
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_pool.php
@@ -0,0 +1,196 @@
+.
+ 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'),
+);
+
+?>
+
+
+
+
+
+
+
+
+
+ "));?>
+
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_pool_edit.php b/net/relayd/src/www/load_balancer_pool_edit.php
new file mode 100644
index 000000000..035cf10c1
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_pool_edit.php
@@ -0,0 +1,389 @@
+.
+ 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("services.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'];
+
+
+$copy_fields = array('name', 'mode', 'descr', 'port', 'retry', 'monitor', 'servers', 'serversdisabled');
+if ($_SERVER['REQUEST_METHOD'] === 'GET') {
+ if (isset($_GET['id']) && !empty($a_pool[$_GET['id']])) {
+ $id = $_GET['id'];
+ }
+ $pconfig = array();
+
+ // copy fields
+ foreach ($copy_fields as $fieldname) {
+ if (isset($id) && isset($a_pool[$id][$fieldname])) {
+ $pconfig[$fieldname] = $a_pool[$id][$fieldname];
+ } else {
+ $pconfig[$fieldname] = null;
+ }
+ }
+
+ // init arrays
+ $pconfig['servers'] = is_array($pconfig['servers']) ? $pconfig['servers'] : array();
+ $pconfig['serversdisabled'] = is_array($pconfig['serversdisabled']) ? $pconfig['serversdisabled'] : array();
+} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ if (isset($_POST['id']) && !empty($a_pool[$_POST['id']])) {
+ $id = $_POST['id'];
+ }
+ $pconfig = $_POST;
+ $input_errors = array();
+ /* input validation */
+ $reqdfields = explode(" ", "name mode port monitor servers");
+ $reqdfieldsn = array(gettext("Name"),gettext("Mode"),gettext("Port"),gettext("Monitor"),gettext("Server List"));
+
+ do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
+
+ /* Ensure that our pool names are unique */
+ for ($i=0; isset($config['load_balancer']['lbpool'][$i]); $i++) {
+ if ($pconfig['name'] == $config['load_balancer']['lbpool'][$i]['name'] && $i != $id) {
+ $input_errors[] = gettext("This pool name has already been used. Pool names must be unique.");
+ }
+ }
+
+ if (strpos($pconfig['name'], " ") !== false) {
+ $input_errors[] = gettext("You cannot use spaces in the 'name' field.");
+ }
+
+ if (in_array($pconfig['name'], $reserved_table_names)) {
+ $input_errors[] = sprintf(gettext("The name '%s' is a reserved word and cannot be used."), $_POST['name']);
+ }
+
+ if (is_alias($pconfig['name'])) {
+ $input_errors[] = sprintf(gettext("Sorry, an alias is already named %s."), $_POST['name']);
+ }
+
+ if (!is_portoralias($pconfig['port'])) {
+ $input_errors[] = gettext("The port must be an integer between 1 and 65535, or a port alias.");
+ }
+
+ // May as well use is_port as we want a positive integer and such.
+ if (!empty($pconfig['retry']) && !is_port($pconfig['retry'])) {
+ $input_errors[] = gettext("The retry value must be an integer between 1 and 65535.");
+ }
+
+ if (is_array($pconfig['servers'])) {
+ foreach($pconfig['servers'] as $svrent) {
+ if (!is_ipaddr($svrent) && !is_subnetv4($svrent)) {
+ $input_errors[] = sprintf(gettext("%s is not a valid IP address or IPv4 subnet (in \"enabled\" list)."), $svrent);
+ } elseif (is_subnetv4($svrent) && subnet_size($svrent) > 64) {
+ $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses (in \"enabled\" list)."), $svrent);
+ }
+ }
+ }
+ if (is_array($pconfig['serversdisabled'])) {
+ foreach($pconfig['serversdisabled'] as $svrent) {
+ if (!is_ipaddr($svrent) && !is_subnetv4($svrent)) {
+ $input_errors[] = sprintf(gettext("%s is not a valid IP address or IPv4 subnet (in \"disabled\" list)."), $svrent);
+ } elseif (is_subnetv4($svrent) && subnet_size($svrent) > 64) {
+ $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses (in \"disabled\" list)."), $svrent);
+ }
+ }
+ }
+ $m = array();
+ for ($i=0; isset($config['load_balancer']['monitor_type'][$i]); $i++) {
+ $m[$config['load_balancer']['monitor_type'][$i]['name']] = $config['load_balancer']['monitor_type'][$i];
+ }
+ if (!isset($m[$pconfig['monitor']])) {
+ $input_errors[] = gettext("Invalid monitor chosen.");
+ }
+ if (count($input_errors) == 0) {
+ $poolent = array();
+ foreach ($copy_fields as $fieldname) {
+ $poolent[$fieldname] = $pconfig[$fieldname];
+ }
+
+ if (isset($id)) {
+ /* modify all virtual servers with this name */
+ for ($i = 0; isset($config['load_balancer']['virtual_server'][$i]); $i++) {
+ if ($config['load_balancer']['virtual_server'][$i]['lbpool'] == $a_pool[$id]['name']) {
+ $config['load_balancer']['virtual_server'][$i]['lbpool'] = $poolent['name'];
+ }
+ }
+ $a_pool[$id] = $poolent;
+ } else {
+ $a_pool[] = $poolent;
+ }
+
+ mark_subsystem_dirty('loadbalancer');
+ write_config();
+ header(url_safe('Location: /load_balancer_pool.php'));
+ exit;
+ }
+}
+
+$service_hook = 'relayd';
+legacy_html_escape_form_data($pconfig);
+
+include("head.inc");
+
+?>
+
+
+
+
+
+
+
+
+
+
+ 0) print_input_errors($input_errors); ?>
+
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_setting.php b/net/relayd/src/www/load_balancer_setting.php
new file mode 100644
index 000000000..fb1855bfd
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_setting.php
@@ -0,0 +1,184 @@
+
+ Copyright (C) 2012 Pierre POMES
+ 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");
+
+?>
+
+
+
+
+
+ 0) print_input_errors($input_errors); ?>
+
+ " . gettext("You must apply the changes in order for them to take effect."));?>
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_virtual_server.php b/net/relayd/src/www/load_balancer_virtual_server.php
new file mode 100644
index 000000000..68feb8586
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_virtual_server.php
@@ -0,0 +1,181 @@
+.
+ 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'),
+);
+?>
+
+
+
+
+
+
+
+
+
+ " . gettext("You must apply the changes in order for them to take effect."));?>
+
+
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/load_balancer_virtual_server_edit.php b/net/relayd/src/www/load_balancer_virtual_server_edit.php
new file mode 100644
index 000000000..d23dd78b1
--- /dev/null
+++ b/net/relayd/src/www/load_balancer_virtual_server_edit.php
@@ -0,0 +1,342 @@
+.
+ 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("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']['virtual_server']) || !is_array($config['load_balancer']['virtual_server'])) {
+ $config['load_balancer']['virtual_server'] = array();
+}
+$a_vs = &$config['load_balancer']['virtual_server'];
+
+
+$copy_fields=array('name', 'descr', 'poolname', 'port', 'sitedown', 'ipaddr', 'mode', 'relay_protocol');
+if ($_SERVER['REQUEST_METHOD'] === 'GET') {
+ if (isset($_GET['id']) && !empty($a_vs[$_GET['id']])) {
+ $id = $_GET['id'];
+ }
+ $pconfig = array();
+ // copy fields
+ foreach ($copy_fields as $fieldname) {
+ if (isset($id) && isset($a_vs[$id][$fieldname])) {
+ $pconfig[$fieldname] = $a_vs[$id][$fieldname];
+ } else {
+ $pconfig[$fieldname] = null;
+ }
+ }
+} elseif ($_SERVER['REQUEST_METHOD'] === 'POST') {
+ if (isset($_POST['id']) && !empty($a_vs[$_POST['id']])) {
+ $id = $_POST['id'];
+ }
+ $pconfig = $_POST;
+ $input_errors = array();
+
+ /* input validation */
+ switch($pconfig['mode']) {
+ case "redirect":
+ $reqdfields = explode(" ", "ipaddr name mode");
+ $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Mode"));
+ break;
+ case "relay":
+ $reqdfields = explode(" ", "ipaddr name mode relay_protocol");
+ $reqdfieldsn = array(gettext("IP Address"),gettext("Name"),gettext("Relay Protocol"));
+ break;
+ }
+
+ do_input_validation($pconfig, $reqdfields, $reqdfieldsn, $input_errors);
+
+ for ($i=0; isset($config['load_balancer']['virtual_server'][$i]); $i++) {
+ if (($pconfig['name'] == $config['load_balancer']['virtual_server'][$i]['name']) && ($i != $id)) {
+ $input_errors[] = gettext("This virtual server name has already been used. Virtual server names must be unique.");
+ }
+ }
+
+ if (preg_match('/[ \/]/', $pconfig['name'])) {
+ $input_errors[] = gettext("You cannot use spaces or slashes in the 'name' field.");
+ }
+
+ if ($pconfig['port'] != "" && !is_portoralias($pconfig['port'])) {
+ $input_errors[] = gettext("The port must be an integer between 1 and 65535, a port alias, or left blank.");
+ }
+
+ if (!is_ipaddroralias($pconfig['ipaddr']) && !is_subnetv4($pconfig['ipaddr'])) {
+ $input_errors[] = sprintf(gettext("%s is not a valid IP address, IPv4 subnet, or alias."), $_POST['ipaddr']);
+ } elseif (is_subnetv4($pconfig['ipaddr']) && subnet_size($pconfig['ipaddr']) > 64) {
+ $input_errors[] = sprintf(gettext("%s is a subnet containing more than 64 IP addresses."), $pconfig['ipaddr']);
+ }
+
+ if ((strtolower($pconfig['relay_protocol']) == "dns") && !empty($pconfig['sitedown'])) {
+ $input_errors[] = gettext("You cannot select a Fall Back Pool when using the DNS relay protocol.");
+ }
+
+ if (count($input_errors) == 0) {
+ $vsent = array();
+ foreach ($copy_fields as $fieldname) {
+ $vsent[$fieldname] = $pconfig[$fieldname];
+ }
+ if ($vsent['sitedown'] == "") {
+ unset($vsent['sitedown']);
+ }
+ if ($vsent['mode'] != 'relay'){
+ // relay protocol only applies to relay
+ unset($vsent['relay_protocol']);
+ }
+
+ if (isset($id)) {
+ if ($a_vs[$id]['name'] != $pconfig['name']) {
+ /* Because the VS name changed, mark the old name for cleanup. */
+ relayd_cleanup_lb_mark_anchor($a_vs[$id]['name']);
+ }
+ $a_vs[$id] = $vsent;
+ } else {
+ $a_vs[] = $vsent;
+ }
+
+ mark_subsystem_dirty('loadbalancer');
+ write_config();
+
+ header(url_safe('Location: /load_balancer_virtual_server.php'));
+ exit;
+ }
+}
+
+$service_hook = 'relayd';
+legacy_html_escape_form_data($pconfig);
+
+include("head.inc");
+
+?>
+
+
+
+
+
+
+
+
+
+ 0) print_input_errors($input_errors); ?>
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/status_lb_pool.php b/net/relayd/src/www/status_lb_pool.php
new file mode 100644
index 000000000..7b7bbaed4
--- /dev/null
+++ b/net/relayd/src/www/status_lb_pool.php
@@ -0,0 +1,180 @@
+.
+ 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);
+
+?>
+
+
+
+
+
+
+ "));?>
+
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/status_lb_vs.php b/net/relayd/src/www/status_lb_vs.php
new file mode 100644
index 000000000..efa211e94
--- /dev/null
+++ b/net/relayd/src/www/status_lb_vs.php
@@ -0,0 +1,142 @@
+.
+ 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");
+
+?>
+
+
+
+
+
+
+
+
+
diff --git a/net/relayd/src/www/widgets/include/load_balancer.inc b/net/relayd/src/www/widgets/include/load_balancer.inc
new file mode 100644
index 000000000..5dfeabbbf
--- /dev/null
+++ b/net/relayd/src/www/widgets/include/load_balancer.inc
@@ -0,0 +1,4 @@
+
+ Copyright (C) 2005-2008 Bill Marquette
+ Copyright (C) 2004-2005 T. Lechat , Manuel Kasper
+ and Jonathan Watt .
+ 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;
+
+?>
+