mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
net/relayd: MVC rewrite (#492)
This commit is contained in:
committed by
Franco Fichtner
parent
fd15f0d7c5
commit
11f0e07aae
@@ -0,0 +1 @@
|
||||
/usr/local/opnsense/scripts/OPNsense/Relayd/post-install.php
|
||||
+3
-2
@@ -1,7 +1,8 @@
|
||||
PLUGIN_NAME= relayd
|
||||
PLUGIN_VERSION= 1.2
|
||||
PLUGIN_VERSION= 2.0.d
|
||||
PLUGIN_DEPENDS= relayd
|
||||
PLUGIN_COMMENT= Relayd Load Balancer
|
||||
PLUGIN_MAINTAINER= frank.brendel@eurolog.com
|
||||
PLUGIN_MAINTAINER= frank.brendel@eurolog.com
|
||||
PLUGIN_REVISION= 0
|
||||
|
||||
.include "../../Mk/plugins.mk"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,3 +0,0 @@
|
||||
dns protocol "dns" {
|
||||
tcp { nodelay, sack, socket buffer 1024, backlog 1000 }
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
protocol "tcp" {
|
||||
tcp { nodelay, socket buffer 65536 }
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd\Api;
|
||||
|
||||
use \OPNsense\Base\ApiMutableServiceControllerBase;
|
||||
use \OPNsense\Core\Backend;
|
||||
use \OPNsense\Relayd\Relayd;
|
||||
|
||||
/**
|
||||
* Class ServiceController
|
||||
* @package OPNsense\relayd
|
||||
*/
|
||||
class ServiceController extends ApiMutableServiceControllerBase
|
||||
{
|
||||
static protected $internalServiceClass = '\OPNsense\Relayd\Relayd';
|
||||
static protected $internalServiceEnabled = 'general.enabled';
|
||||
static protected $internalServiceTemplate = 'OPNsense/Relayd';
|
||||
static protected $internalServiceName = 'relayd';
|
||||
|
||||
/**
|
||||
* test relayd configuration
|
||||
* @return array
|
||||
*/
|
||||
public function configtestAction()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
|
||||
$backend = new Backend();
|
||||
|
||||
$result['function'] = "configtest";
|
||||
$result['template'] = trim($backend->configdRun('template reload OPNsense/Relayd'));
|
||||
if ($result['template'] != 'OK') {
|
||||
$result['result'] = "Template error: " . $result['template'];
|
||||
return $result;
|
||||
}
|
||||
$result['result'] = trim($backend->configdRun('relayd configtest'));
|
||||
return $result;
|
||||
} else {
|
||||
return array('status' => 'failed');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* avoid restarting Relayd on reconfigure
|
||||
*/
|
||||
protected function reconfigureForceRestart()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
+271
@@ -0,0 +1,271 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd\Api;
|
||||
|
||||
use \OPNsense\Base\ApiMutableModelControllerBase;
|
||||
use \OPNsense\Core\Config;
|
||||
use \OPNsense\Relayd\Relayd;
|
||||
use \OPNsense\Base\UIModelGrid;
|
||||
|
||||
/**
|
||||
* Class SettingsController
|
||||
* @package OPNsense\Relayd
|
||||
*/
|
||||
class SettingsController extends ApiMutableModelControllerBase
|
||||
{
|
||||
|
||||
static protected $internalModelName = 'relayd';
|
||||
static protected $internalModelClass = '\OPNsense\Relayd\Relayd';
|
||||
|
||||
/**
|
||||
* list with valid model node types
|
||||
*/
|
||||
private $nodeTypes = array('general', 'host', 'tablecheck', 'table', 'protocol', 'virtualserver');
|
||||
|
||||
/**
|
||||
* query relayd settings
|
||||
* @param $nodeType
|
||||
* @param $uuid
|
||||
* @return result array
|
||||
*/
|
||||
public function getAction($nodeType = null, $uuid = null)
|
||||
{
|
||||
if ($nodeType != null) {
|
||||
$this->validateNodeType($nodeType);
|
||||
if ($nodeType == 'general') {
|
||||
$mdlRelayd = new Relayd();
|
||||
return array('result' => 'ok', 'general' => $mdlRelayd->getNodeByReference('general')->getNodes());
|
||||
} else {
|
||||
return $this->getBase($nodeType, $nodeType, $uuid);
|
||||
}
|
||||
}
|
||||
return array("result" => "failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* set relayd properties
|
||||
* @param $nodeType
|
||||
* @param $uuid
|
||||
* @param $action set or add node
|
||||
* @return status array
|
||||
*/
|
||||
public function setAction($nodeType = null, $uuid = null)
|
||||
{
|
||||
if (!$this->request->isPost() || !$this->request->hasPost("relayd") || $nodeType == null) {
|
||||
return array('result' => 'failed');
|
||||
}
|
||||
|
||||
$this->validateNodeType($nodeType);
|
||||
|
||||
$relaydInfo = $this->request->getPost("relayd");
|
||||
|
||||
if ($nodeType == 'general') {
|
||||
$mdlRelayd = new Relayd();
|
||||
$node = $mdlRelayd->getNodeByReference($nodeType);
|
||||
$node->setNodes($relaydInfo[$nodeType]);
|
||||
if ($relaydInfo['general']['enabled'] == '0') {
|
||||
$svcRelayd = new ServiceController();
|
||||
$svcRelayd->stopAction();
|
||||
}
|
||||
$mdlRelayd->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
return array("result" => "saved");
|
||||
}
|
||||
|
||||
// perform plugin specific validations
|
||||
if ($nodeType == 'virtualserver') {
|
||||
if ($relaydInfo[$nodeType]['type'] == 'redirect') {
|
||||
if ($relaydInfo[$nodeType]['transport_tablemode'] != 'least-states' &&
|
||||
$relaydInfo[$nodeType]['transport_tablemode'] != 'roundrobin') {
|
||||
$result["validations"]['relayd.virtualserver.transport_tablemode'] = "Scheduler '" . $relaydInfo[$nodeType]['transport_tablemode'] . "' not supported for redirects.";
|
||||
}
|
||||
if ($relaydInfo[$nodeType]['backuptransport_tablemode'] != 'least-states' &&
|
||||
$relaydInfo[$nodeType]['backuptransport_tablemode'] != 'roundrobin') {
|
||||
$result["validations"]['relayd.virtualserver.backuptransport_tablemode'] = "Scheduler '" . $relaydInfo[$nodeType]['backuptransport_tablemode'] . "' not supported for redirects.";
|
||||
}
|
||||
}
|
||||
if ($relaydInfo[$nodeType]['type'] == 'relay') {
|
||||
if ($relaydInfo[$nodeType]['transport_tablemode'] == 'least-states') {
|
||||
$result["validations"]['relayd.virtualserver.transport_tablemode'] = "Scheduler '" . $relaydInfo[$nodeType]['transport_tablemode'] . "' not supported for relays.";
|
||||
}
|
||||
if ($relaydInfo[$nodeType]['backuptransport_tablemode'] == 'least-states') {
|
||||
$result["validations"]['relayd.virtualserver.backuptransport_tablemode'] = "Scheduler '" . $relaydInfo[$nodeType]['backuptransport_tablemode'] . "' not supported for relays.";
|
||||
}
|
||||
}
|
||||
} elseif ($nodeType == 'tablecheck') {
|
||||
switch ($relaydInfo[$nodeType]['type']) {
|
||||
case 'send':
|
||||
if (empty($relaydInfo[$nodeType]['expect'])) {
|
||||
$result["validations"]['relayd.tablecheck.expect'] = "Expect Pattern cannot be empty.";
|
||||
}
|
||||
break;
|
||||
case 'script':
|
||||
if(empty($relaydInfo[$nodeType]['path'])) {
|
||||
$result["validations"]['relayd.tablecheck.path'] = "Script path cannot be empty.";
|
||||
}
|
||||
break;
|
||||
case 'http':
|
||||
if(empty($relaydInfo[$nodeType]['path'])) {
|
||||
$result["validations"]['relayd.tablecheck.path'] = "Path cannot be empty.";
|
||||
}
|
||||
if(empty($relaydInfo[$nodeType]['code']) && empty($relaydInfo[$nodeType]['digest'])) {
|
||||
$result["validations"]['relayd.tablecheck.code'] = "Provide one of Response Code or Message Digest.";
|
||||
$result["validations"]['relayd.tablecheck.digest'] = "Provide one of Response Code or Message Digest.";
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!empty($result["validations"])) {
|
||||
return $result;
|
||||
}
|
||||
return $this->setBase('relayd', $nodeType, $uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
* delete relayd settings
|
||||
* @param $nodeType
|
||||
* @param $uuid
|
||||
* @return status array
|
||||
*/
|
||||
public function delAction($nodeType = null, $uuid = null)
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
if ($nodeType != null) {
|
||||
$this->validateNodeType($nodeType);
|
||||
if($uuid != null) {
|
||||
$mdlRelayd = new Relayd();
|
||||
$node = $mdlRelayd->getNodeByReference($nodeType . '.' . $uuid);
|
||||
if ($node != null) {
|
||||
$nodeName = $mdlRelayd->getNodeByReference($nodeType . '.' . $uuid . '.name')->__toString();
|
||||
if ($mdlRelayd->$nodeType->del($uuid) == true) {
|
||||
// delete relations
|
||||
switch ($nodeType) {
|
||||
case 'host':
|
||||
$this->deleteRelations('table', 'hosts', $uuid, 'host', $nodeName, $mdlRelayd);
|
||||
break;
|
||||
case 'tablecheck':
|
||||
$this->deleteRelations('virtualserver', 'transport_tablecheck', $uuid, 'tablecheck', $nodeName, $mdlRelayd);
|
||||
$this->deleteRelations('virtualserver', 'backuptransport_tablecheck', $uuid, 'tablecheck', $nodeName, $mdlRelayd);
|
||||
break;
|
||||
case 'table':
|
||||
$this->deleteRelations('virtualserver', 'transport_table', $uuid, 'table', $nodeName, $mdlRelayd);
|
||||
$this->deleteRelations('virtualserver', 'backuptransport_table', $uuid, 'table', $nodeName, $mdlRelayd);
|
||||
break;
|
||||
case 'protocol':
|
||||
$this->deleteRelations('virtualserver', 'protocol', $uuid, 'protocol', $nodeName, $mdlRelayd);
|
||||
break;
|
||||
}
|
||||
$mdlRelayd->serializeToConfig();
|
||||
Config::getInstance()->save();
|
||||
$result["result"] = "ok";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* search relayd settings
|
||||
* @param $nodeType
|
||||
* @return result array
|
||||
*/
|
||||
public function searchAction($nodeType = null)
|
||||
{
|
||||
if ($nodeType != null) {
|
||||
$this->validateNodeType($nodeType);
|
||||
$fields = array();
|
||||
switch ($nodeType) {
|
||||
case 'host':
|
||||
$fields = array('name', 'address');
|
||||
break;
|
||||
case 'tablecheck':
|
||||
$fields = array('name', 'type');
|
||||
break;
|
||||
case 'table':
|
||||
$fields = array('enabled', 'name');
|
||||
break;
|
||||
case 'protocol':
|
||||
$fields = array('name', 'type');
|
||||
break;
|
||||
case 'virtualserver':
|
||||
$fields = array('enabled', 'name', 'type');
|
||||
break;
|
||||
}
|
||||
return $this->searchBase($nodeType, $fields);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* validate nodeType
|
||||
* @param $nodeType
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function validateNodeType($nodeType = null)
|
||||
{
|
||||
if(array_search($nodeType, $this->nodeTypes) === false) {
|
||||
throw new \Exception('unknown nodeType: ' . $nodeType);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* delete relations
|
||||
* @param $nodeType
|
||||
* @param $uuid
|
||||
* @param $relNodeType
|
||||
* @param &$mdlRelayd
|
||||
* @throws \Exception
|
||||
*/
|
||||
private function deleteRelations($nodeType = null, $nodeField = null, $relUuid = null, $relNodeType = null, $relNodeName = null, &$mdlRelayd = null)
|
||||
{
|
||||
$nodes = $mdlRelayd->$nodeType->getNodes();
|
||||
// get nodes with relations
|
||||
foreach ($nodes as $nodeUuid => $node) {
|
||||
// get relation uuids
|
||||
foreach ($node[$nodeField] as $fieldUuid => $field) {
|
||||
// remove uuid from field
|
||||
if ($fieldUuid == $relUuid) {
|
||||
$refField = $nodeType . '.' . $nodeUuid . '.' . $nodeField;
|
||||
$relNode = $mdlRelayd->getNodeByReference($refField);
|
||||
$nodeRels = str_replace($relUuid, '', $relNode->__toString());
|
||||
$nodeRels = str_replace(',,', ',', $nodeRels);
|
||||
$nodeRels = rtrim($nodeRels, ',');
|
||||
$nodeRels = ltrim($nodeRels, ',');
|
||||
$mdlRelayd->setNodeByReference($refField, $nodeRels);
|
||||
if ($relNode->isEmptyAndRequired()) {
|
||||
$nodeName = $mdlRelayd->getNodeByReference($nodeType . '.' . $nodeUuid . '.name')->__toString();
|
||||
throw new \Exception("Cannot delete $relNodeType '$relNodeName' from $nodeType '$nodeName'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd\Api;
|
||||
|
||||
use \OPNsense\Base\ApiControllerBase;
|
||||
use \OPNsense\Relayd\Relayd;
|
||||
|
||||
/**
|
||||
* Class StatusController
|
||||
* @package OPNsense\Relayd
|
||||
*/
|
||||
class StatusController extends ApiControllerBase
|
||||
{
|
||||
/**
|
||||
* get relayd summary
|
||||
*/
|
||||
public function sumAction()
|
||||
{
|
||||
$result = array("result" => "failed");
|
||||
$output = array();
|
||||
$exitcode;
|
||||
exec('/usr/local/sbin/relayctl show summary 2>&1', $output, $exitcode);
|
||||
if ($exitcode != 0) {
|
||||
$result["output"] = join(' ', $output);
|
||||
return $result;
|
||||
}
|
||||
$result["result"] = 'ok';
|
||||
$virtualServerId = 0;
|
||||
$virtualServerType = '';
|
||||
$tableId = 0;
|
||||
$virtualserver = array();
|
||||
$rows = array();
|
||||
foreach ( $output as $line) {
|
||||
$words = explode("\t", $line);
|
||||
$id = trim($words[0]);
|
||||
$type = trim($words[1]);
|
||||
if ($type == 'redirect' || $type == 'relay') {
|
||||
// new virtual server id/type means new record
|
||||
if (($id != $virtualServerId && $virtualServerId > 0) ||
|
||||
($type != $virtualServerType && strlen($virtualServerType) > 5)) {
|
||||
$rows[] = $virtualserver;
|
||||
$virtualserver = array();
|
||||
}
|
||||
$virtualServerId = $id;
|
||||
$virtualServerType = $type;
|
||||
$virtualserver['id'] = $id;
|
||||
$virtualserver['type'] = $type;
|
||||
$virtualserver['name'] = trim($words[2]);
|
||||
$virtualserver['status'] = trim($words[4]);
|
||||
}
|
||||
if ($type == 'table') {
|
||||
$tableId = $id;
|
||||
$virtualserver['tables'][$tableId]['name'] = trim($words[2]);
|
||||
$virtualserver['tables'][$tableId]['status'] = trim($words[4]);
|
||||
}
|
||||
if ($type == 'host') {
|
||||
$hostId = trim($words[0]);
|
||||
$virtualserver['tables'][$tableId]['hosts'][$hostId]['name'] = trim($words[2]);
|
||||
$virtualserver['tables'][$tableId]['hosts'][$hostId]['avlblty'] = trim($words[3]);
|
||||
$virtualserver['tables'][$tableId]['hosts'][$hostId]['status'] = trim($words[4]);
|
||||
}
|
||||
}
|
||||
$rows[] = $virtualserver;
|
||||
$result["rows"] = $rows;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* enable/disable relayd objects
|
||||
*/
|
||||
public function toggleAction($nodeType = null, $id = null, $action = null)
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$this->sessionClose();
|
||||
}
|
||||
$result = array("result" => "failed", "function" => "toggle");
|
||||
$output = array();
|
||||
$exitcode;
|
||||
if ($nodeType != null &&
|
||||
($nodeType == 'redirect' ||
|
||||
$nodeType == 'table' ||
|
||||
$nodeType == 'host')) {
|
||||
if ($action != null &&
|
||||
($action == 'enable' ||
|
||||
$action == 'disable')) {
|
||||
if ($id != null && $id > 0) {
|
||||
exec("/usr/local/sbin/relayctl $nodeType $action $id 2>&1", $output, $exitcode);
|
||||
$result["output"] = join(' ', $output);
|
||||
if ($exitcode == 0) {
|
||||
$result["result"] = 'ok';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd;
|
||||
|
||||
/**
|
||||
* Class IndexController
|
||||
* @package OPNsense\Relayd
|
||||
*/
|
||||
class IndexController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
/**
|
||||
* relayd index page
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->formGeneralSettings = $this->getForm("general");
|
||||
$this->view->formDialogEditHost = $this->getForm("host");
|
||||
$this->view->formDialogEditTableCheck = $this->getForm("tablecheck");
|
||||
$this->view->formDialogEditTable = $this->getForm("table");
|
||||
$this->view->formDialogEditProtocol = $this->getForm("protocol");
|
||||
$this->view->formDialogEditVirtualServer = $this->getForm("virtualserver");
|
||||
$this->view->pick('OPNsense/Relayd/index');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd;
|
||||
|
||||
/**
|
||||
* Class StatusController
|
||||
* @package OPNsense\Relayd
|
||||
*/
|
||||
class StatusController extends \OPNsense\Base\IndexController
|
||||
{
|
||||
/**
|
||||
* relayd status page
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function indexAction()
|
||||
{
|
||||
$this->view->pick('OPNsense/Relayd/status');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.general.enabled</id>
|
||||
<label>Enable load balancer</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[Enable or disable the Relayd loadbalancer.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.general.interval</id>
|
||||
<label>Global Check Interval</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Set the interval in seconds at which the hosts will be checked.<br>
|
||||
The default interval is 10 seconds.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.general.log</id>
|
||||
<label>State Notification</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Log state notifications after completed host checks. Either only<br>
|
||||
log the updates to new states or log all state notifications,<br>
|
||||
even if the state didn't change.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.general.prefork</id>
|
||||
<label>Number Of Processes</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
When using relays, run the specified number of processes to<br>
|
||||
handle relayed connections.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.general.timeout</id>
|
||||
<label>Global Check Timeout</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Set the global timeout in milliseconds for checks. This can be<br>
|
||||
overridden by the timeout value in the table definitions.]]>
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,46 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.host.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The name of the host.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.host.address</id>
|
||||
<label>Address</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The backend host address.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.host.ipTTL</id>
|
||||
<label>IP TTL</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Change the default time-to-live value in the IP headers for host checks.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.host.priority</id>
|
||||
<label>Route Priority</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Change the route priority used when adding a route.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.host.retry</id>
|
||||
<label>Retry Number</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The optional retry option adds a tolerance for failed host checks;
|
||||
the check will be retried for this number more times before setting the
|
||||
host state to down.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,25 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.protocol.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The name of the protocol definition.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.protocol.type</id>
|
||||
<label>Type</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
The type of the protocol definition.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.protocol.options</id>
|
||||
<label>Options</label>
|
||||
<type>textbox</type>
|
||||
<help><![CDATA[
|
||||
The protocol options.]]>
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,26 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.table.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The name of the table.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.table.enabled</id>
|
||||
<label>Enable</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[
|
||||
If unchecked start the table disabled.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.table.hosts</id>
|
||||
<label>Hosts</label>
|
||||
<type>select_multiple</type>
|
||||
<style>tokenize</style>
|
||||
<help><![CDATA[
|
||||
This is a list with backend hosts]]>
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,80 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.tablecheck.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The name of the table check.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.type</id>
|
||||
<label>Type</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[<ul>
|
||||
<li>ICMP - Ping hosts in this table to determine whether they are up or not.</li>
|
||||
<li>TCP - Use a simple TCP connect to check that hosts are up.</li>
|
||||
<li>SSL - Perform a complete SSL handshake with each host to check their availability.</li>
|
||||
<li>SEND - Create a TCP connection, send data and check the response.</li>
|
||||
<li>SCRIPT - Execute an external program to check the host state.</li>
|
||||
<li>HTTP(S) - Check response code or message digest from a http(s) request.</li>
|
||||
</ul>]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.path</id>
|
||||
<label>Path</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The URL path for HTTP(S) or the script path for SCRIPT checks.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.host</id>
|
||||
<label>Host</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The HTTP 'Host' header value.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.code</id>
|
||||
<label>Response Code</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The expected response code.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.digest</id>
|
||||
<label>Message Digest</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The expected response message digest.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.data</id>
|
||||
<label>Send Data</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Send data.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.expect</id>
|
||||
<label>Expect Pattern</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Match response against pattern.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.tablecheck.ssl</id>
|
||||
<label>SSL</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[
|
||||
Use SSL.]]>
|
||||
</help>
|
||||
</field>
|
||||
</form>
|
||||
@@ -0,0 +1,199 @@
|
||||
<form>
|
||||
<field>
|
||||
<id>relayd.virtualserver.name</id>
|
||||
<label>Name</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
The name of the virtual server.]]></help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.enabled</id>
|
||||
<label>Enable</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[
|
||||
If unchecked start the virtual server disabled.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.type</id>
|
||||
<label>Server Type</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
<b>Redirections</b><br>
|
||||
Redirections are translated to pf(4) rdr-to rules for stateful<br>
|
||||
forwarding to a target host from a health-checked table on layer 3.<br><br>
|
||||
<b>Relays</b><br>
|
||||
Relays allow application layer load balancing, SSL acceleration,<br>
|
||||
and general purpose TCP proxying on layer 7.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.listen_address</id>
|
||||
<label>Listen Address</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Specify an address to listen on.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.listen_startport</id>
|
||||
<label>Listen Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Specify the port to listen on.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.listen_endport</id>
|
||||
<label>Listen End Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Specify the end of a port range.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.listen_interface</id>
|
||||
<label>Interface</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
The Interface to listen on. Leave it unset to listen on all interfaces.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_type</id>
|
||||
<label>Transport Type</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
<b>Forward</b> or <b>Route</b> packets to the backend hosts.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_table</id>
|
||||
<label>Table</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Specify the table of target hosts to be used.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_port</id>
|
||||
<label>Port</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Specify the destination port.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_interval</id>
|
||||
<label>Check Interval</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Override the global interval. I must be a multiple of the global interval.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_timeout</id>
|
||||
<label>Check Timeout</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Override the global check timeout.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_tablemode</id>
|
||||
<label>Scheduler</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Set the scheduling algorithm to select a host from the table.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.transport_tablecheck</id>
|
||||
<label>Table Check</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Specify the table check.]]>
|
||||
</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.backuptransport_table</id>
|
||||
<label>Backup Table</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Specify the table of target hosts to be used.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.backuptransport_interval</id>
|
||||
<label>Backup Check Interval</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Override the global interval. I must be a multiple of the global interval.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.backuptransport_timeout</id>
|
||||
<label>Backup Check Timeout</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Override the global check timeout.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.backuptransport_tablemode</id>
|
||||
<label>Backup Table Scheduler</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Set the scheduling algorithm to select a host from the table.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.backuptransport_tablecheck</id>
|
||||
<label>Backup Table Check</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Specify the table check.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.sessiontimeout</id>
|
||||
<label>Session Timeout</label>
|
||||
<type>text</type>
|
||||
<help><![CDATA[
|
||||
Specify the inactivity timeout in seconds for established<br>
|
||||
redirections. The default timeout is 600 seconds (10 minutes).<br>
|
||||
The maximum is 2147483647 seconds (68 years).]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.stickyaddress</id>
|
||||
<label>Sticky Address</label>
|
||||
<type>checkbox</type>
|
||||
<help><![CDATA[
|
||||
It will ensure that multiple connections<br>
|
||||
from the same source are mapped to the same redirection address.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
<field>
|
||||
<id>relayd.virtualserver.protocol</id>
|
||||
<label>Protocol</label>
|
||||
<type>dropdown</type>
|
||||
<help><![CDATA[
|
||||
Use the specified protocol definition for the relay.]]>
|
||||
</help>
|
||||
<advanced>true</advanced>
|
||||
</field>
|
||||
</form>
|
||||
@@ -1,62 +1,10 @@
|
||||
<acl>
|
||||
<page-services-loadbalancer-monitor-edit>
|
||||
<name>Services: Load Balancer: Monitor: Edit</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_monitor_edit.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-loadbalancer-monitor-edit>
|
||||
<page-services-loadbalancer-monitor>
|
||||
<name>Services: Load Balancer: Monitors</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_monitor.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-loadbalancer-monitor>
|
||||
<page-services-loadbalancer-setting>
|
||||
<name>Services: Load Balancer: setting</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_setting.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-loadbalancer-setting>
|
||||
<page-services-loadbalancer-virtualservers>
|
||||
<name>Services: Load Balancer: Virtual Servers</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_virtual_server.php*</pattern>
|
||||
</patterns>
|
||||
</page-services-loadbalancer-virtualservers>
|
||||
<page-status-loadbalancer-pool>
|
||||
<name>Status: Load Balancer: Pool</name>
|
||||
<patterns>
|
||||
<pattern>status_lb_pool.php*</pattern>
|
||||
</patterns>
|
||||
</page-status-loadbalancer-pool>
|
||||
<page-status-loadbalancer-virtualserver>
|
||||
<name>Status: Load Balancer: Virtual Server</name>
|
||||
<patterns>
|
||||
<pattern>status_lb_vs.php*</pattern>
|
||||
</patterns>
|
||||
</page-status-loadbalancer-virtualserver>
|
||||
<page-status-systemlogs-loadbalancer>
|
||||
<name>Status: System logs: Load Balancer</name>
|
||||
<patterns>
|
||||
<pattern>diag_logs_relayd.php*</pattern>
|
||||
</patterns>
|
||||
</page-status-systemlogs-loadbalancer>
|
||||
<page-loadbalancer-pool>
|
||||
<name>Load Balancer: Pool</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_pool.php*</pattern>
|
||||
</patterns>
|
||||
</page-loadbalancer-pool>
|
||||
<page-loadbalancer-pool-edit>
|
||||
<name>Load Balancer: Pool: Edit</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_pool_edit.php*</pattern>
|
||||
</patterns>
|
||||
</page-loadbalancer-pool-edit>
|
||||
<page-loadbalancer-virtualserver-edit>
|
||||
<name>Load Balancer: Virtual Server: Edit</name>
|
||||
<patterns>
|
||||
<pattern>load_balancer_virtual_server_edit.php*</pattern>
|
||||
</patterns>
|
||||
</page-loadbalancer-virtualserver-edit>
|
||||
<page-services-relayd>
|
||||
<name>Services: Load Balancer</name>
|
||||
<description>Allow access to the 'Services: Load Balancer' page.</description>
|
||||
<patterns>
|
||||
<pattern>ui/relayd/*</pattern>
|
||||
<pattern>api/relayd/*</pattern>
|
||||
</patterns>
|
||||
</page-services-relayd>
|
||||
</acl>
|
||||
|
||||
@@ -1,19 +1,9 @@
|
||||
<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>
|
||||
<Services>
|
||||
<Relayd VisibleName="Load Balancer" cssClass="fa fa-truck fa-fw">
|
||||
<Settings url="/ui/relayd/"/>
|
||||
<Status url="/ui/relayd/status/"/>
|
||||
<Log VisibleName="Log File" order="100" url="/diag_logs_relayd.php"/>
|
||||
</Relayd>
|
||||
</Services>
|
||||
</menu>
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Copyright (C) 2018 EURO-LOG AG
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
|
||||
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace OPNsense\Relayd;
|
||||
|
||||
use OPNsense\Base\BaseModel;
|
||||
|
||||
/**
|
||||
* Class Relayd
|
||||
* @package OPNsense\Relayd
|
||||
*/
|
||||
class Relayd extends BaseModel
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,326 @@
|
||||
<model>
|
||||
<mount>//OPNsense/relayd</mount>
|
||||
<version>1.0.0</version>
|
||||
<description>Relayd settings</description>
|
||||
<items>
|
||||
<general>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<interval type="IntegerField">
|
||||
<default>10</default>
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>Check interval must be greater than 0</ValidationMessage>
|
||||
</interval>
|
||||
<log type="OptionField">
|
||||
<Required>N</Required>
|
||||
<OptionValues>
|
||||
<updates>new states</updates>
|
||||
<all>all states</all>
|
||||
</OptionValues>
|
||||
</log>
|
||||
<prefork type="IntegerField">
|
||||
<default>3</default>
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>Number of processes must be greater than 0</ValidationMessage>
|
||||
</prefork>
|
||||
<timeout type="IntegerField">
|
||||
<default>200</default>
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The timeout must be greater than 0</ValidationMessage>
|
||||
</timeout>
|
||||
</general>
|
||||
<host type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\._\- ]){1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters. Allowed characters are letters and numbers as well as underscore, minus, dot and space.</ValidationMessage>
|
||||
</name>
|
||||
<address type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\.,_\-:]){0,1024}$/u</mask>
|
||||
<ChangeCase>lower</ChangeCase>
|
||||
<ValidationMessage>Please specify a valid servername or IP address.</ValidationMessage>
|
||||
</address>
|
||||
<ipTTL type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The IP TTL must be greater than 0</ValidationMessage>
|
||||
</ipTTL>
|
||||
<priority type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The route priority must be greater than 0</ValidationMessage>
|
||||
</priority>
|
||||
<retry type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The number of retries must be greater than 0</ValidationMessage>
|
||||
</retry>
|
||||
</host>
|
||||
<table type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\._\- ]){1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters. Allowed characters are letters and numbers as well as underscore, minus, dot and space.</ValidationMessage>
|
||||
</name>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<hosts type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>host</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Host not found</ValidationMessage>
|
||||
<multiple>Y</multiple>
|
||||
<Required>Y</Required>
|
||||
</hosts>
|
||||
</table>
|
||||
<tablecheck type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\._\- ]){1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters. Allowed characters are letters and numbers as well as underscore, minus, dot and space.</ValidationMessage>
|
||||
</name>
|
||||
<type type="OptionField">
|
||||
<default>icmp</default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<icmp>ICMP</icmp>
|
||||
<tcp>TCP</tcp>
|
||||
<ssl>SSL</ssl>
|
||||
<send>SEND</send>
|
||||
<script>SCRIPT</script>
|
||||
<http>HTTP</http>
|
||||
</OptionValues>
|
||||
</type>
|
||||
<path type="TextField">
|
||||
<Required>N</Required>
|
||||
</path>
|
||||
<host type="TextField">
|
||||
<mask>/^([0-9a-zA-Z\.,_\-:]){0,1024}$/u</mask>
|
||||
<ChangeCase>lower</ChangeCase>
|
||||
<ValidationMessage>Please specify a valid servername or IP address.</ValidationMessage>
|
||||
<Required>N</Required>
|
||||
</host>
|
||||
<code type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<ValidationMessage>Expected return code must be a number.</ValidationMessage>
|
||||
</code>
|
||||
<digest type="TextField">
|
||||
<Required>N</Required>
|
||||
</digest>
|
||||
<data type="TextField">
|
||||
<Required>N</Required>
|
||||
</data>
|
||||
<expect type="TextField">
|
||||
<Required>N</Required>
|
||||
</expect>
|
||||
<ssl type="BooleanField">
|
||||
<Required>N</Required>
|
||||
</ssl>
|
||||
</tablecheck>
|
||||
<virtualserver type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\._\- ]){1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters. Allowed characters are letters and numbers as well as underscore, minus, dot and space.</ValidationMessage>
|
||||
</name>
|
||||
<enabled type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>Y</Required>
|
||||
</enabled>
|
||||
<type type="OptionField">
|
||||
<default>relay</default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<relay>Relay</relay>
|
||||
<redirect>Redirection</redirect>
|
||||
</OptionValues>
|
||||
</type>
|
||||
<listen_address type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\.,_\-:]){0,1024}$/u</mask>
|
||||
<ChangeCase>lower</ChangeCase>
|
||||
<ValidationMessage>Please specify a valid servername or IP address.</ValidationMessage>
|
||||
</listen_address>
|
||||
<listen_startport type="PortField">
|
||||
<Required>Y</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>A valid Port number must be specified.</ValidationMessage>
|
||||
</listen_startport>
|
||||
<listen_endport type="PortField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>A valid Port number must be specified.</ValidationMessage>
|
||||
</listen_endport>
|
||||
<listen_interface type="InterfaceField">
|
||||
<Required>N</Required>
|
||||
<multiple>N</multiple>
|
||||
<filters>
|
||||
<enable>/^(?!0).*$/</enable>
|
||||
<ipaddr>/^((?!dhcp).)*$/</ipaddr>
|
||||
</filters>
|
||||
</listen_interface>
|
||||
<transport_type type="OptionField">
|
||||
<default>forward</default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<forward>Forward</forward>
|
||||
<route>Route</route>
|
||||
</OptionValues>
|
||||
</transport_type>
|
||||
<transport_table type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>table</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Table not found</ValidationMessage>
|
||||
<multiple>N</multiple>
|
||||
<Required>Y</Required>
|
||||
</transport_table>
|
||||
<transport_port type="PortField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>65535</MaximumValue>
|
||||
<ValidationMessage>A valid Port number must be specified.</ValidationMessage>
|
||||
</transport_port>
|
||||
<transport_interval type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>2</MinimumValue>
|
||||
<ValidationMessage>Check interval must be a multiple of the global interval.</ValidationMessage>
|
||||
</transport_interval>
|
||||
<transport_timeout type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The timeout must be greater than 0</ValidationMessage>
|
||||
</transport_timeout>
|
||||
<transport_tablemode type="OptionField">
|
||||
<default>roundrobin</default>
|
||||
<Required>N</Required>
|
||||
<OptionValues>
|
||||
<hash>Hash</hash>
|
||||
<least-states>Least States</least-states>
|
||||
<loadbalance>Load Balance</loadbalance>
|
||||
<random>Random</random>
|
||||
<roundrobin>Round Robin</roundrobin>
|
||||
<source-hash>Source Hash</source-hash>
|
||||
</OptionValues>
|
||||
</transport_tablemode>
|
||||
<transport_tablecheck type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>tablecheck</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Table check not found</ValidationMessage>
|
||||
<multiple>N</multiple>
|
||||
<Required>Y</Required>
|
||||
</transport_tablecheck>
|
||||
<backuptransport_table type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>table</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Table not found</ValidationMessage>
|
||||
<multiple>N</multiple>
|
||||
<Required>N</Required>
|
||||
</backuptransport_table>
|
||||
<backuptransport_interval type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>2</MinimumValue>
|
||||
<ValidationMessage>Check interval must be a multiple of the global interval.</ValidationMessage>
|
||||
</backuptransport_interval>
|
||||
<backuptransport_timeout type="IntegerField">
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<ValidationMessage>The timeout must be greater than 0</ValidationMessage>
|
||||
</backuptransport_timeout>
|
||||
<backuptransport_tablecheck type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>tablecheck</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Table check not found</ValidationMessage>
|
||||
<multiple>N</multiple>
|
||||
<Required>N</Required>
|
||||
</backuptransport_tablecheck>
|
||||
<backuptransport_tablemode type="OptionField">
|
||||
<default>roundrobin</default>
|
||||
<Required>N</Required>
|
||||
<OptionValues>
|
||||
<hash>Hash</hash>
|
||||
<least-states>Least States</least-states>
|
||||
<loadbalance>Load Balance</loadbalance>
|
||||
<random>Random</random>
|
||||
<roundrobin>Round Robin</roundrobin>
|
||||
<source-hash>Source Hash</source-hash>
|
||||
</OptionValues>
|
||||
</backuptransport_tablemode>
|
||||
<sessiontimeout type="IntegerField">
|
||||
<default>600</default>
|
||||
<Required>N</Required>
|
||||
<MinimumValue>1</MinimumValue>
|
||||
<MaximumValue>2147483647</MaximumValue>
|
||||
<ValidationMessage>The timeout must be a number between 1 and 2147483647.</ValidationMessage>
|
||||
</sessiontimeout>
|
||||
<stickyaddress type="BooleanField">
|
||||
<default>0</default>
|
||||
<Required>N</Required>
|
||||
</stickyaddress>
|
||||
<protocol type="ModelRelationField">
|
||||
<Model>
|
||||
<template>
|
||||
<source>OPNsense.relayd.relayd</source>
|
||||
<items>protocol</items>
|
||||
<display>name</display>
|
||||
</template>
|
||||
</Model>
|
||||
<ValidationMessage>Protocol not found</ValidationMessage>
|
||||
<multiple>N</multiple>
|
||||
<Required>N</Required>
|
||||
</protocol>-->
|
||||
</virtualserver>
|
||||
<protocol type="ArrayField">
|
||||
<name type="TextField">
|
||||
<Required>Y</Required>
|
||||
<mask>/^([0-9a-zA-Z\._\- ]){1,255}$/u</mask>
|
||||
<ValidationMessage>Should be a string between 1 and 255 characters. Allowed characters are letters and numbers as well as underscore, minus, dot and space.</ValidationMessage>
|
||||
</name>
|
||||
<type type="OptionField">
|
||||
<default>tcp</default>
|
||||
<Required>Y</Required>
|
||||
<OptionValues>
|
||||
<tcp>TCP</tcp>
|
||||
<dns>DNS</dns>
|
||||
<http>HTTP</http>
|
||||
</OptionValues>
|
||||
</type>
|
||||
<options type="TextField">
|
||||
<Required>N</Required>
|
||||
</options>
|
||||
</protocol>
|
||||
</items>
|
||||
</model>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user