Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/haproxy: Release 2.4 #483

Merged
merged 13 commits into from Jan 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions net/haproxy/Makefile
@@ -1,7 +1,7 @@
PLUGIN_NAME= haproxy
PLUGIN_VERSION= 2.3
PLUGIN_VERSION= 2.4
PLUGIN_COMMENT= Reliable, high performance TCP/HTTP load balancer
PLUGIN_DEPENDS= haproxy
PLUGIN_DEPENDS= haproxy-devel
PLUGIN_MAINTAINER= opnsense@moov.de

.include "../../Mk/plugins.mk"
Expand Up @@ -29,133 +29,20 @@
*/
namespace OPNsense\HAProxy\Api;

use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Base\ApiMutableServiceControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\HAProxy\HAProxy;

/**
* Class ServiceController
* @package OPNsense\HAProxy
*/
class ServiceController extends ApiControllerBase
class ServiceController extends ApiMutableServiceControllerBase
{
/**
* start haproxy service (in background)
* @return array
*/
public function startAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("haproxy start");
return array("response" => $response);
} else {
return array("response" => array());
}
}

/**
* stop haproxy service
* @return array
*/
public function stopAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("haproxy stop");
return array("response" => $response);
} else {
return array("response" => array());
}
}

/**
* restart haproxy service
* @return array
*/
public function restartAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$backend = new Backend();
$response = $backend->configdRun("haproxy restart");
return array("response" => $response);
} else {
return array("response" => array());
}
}

/**
* retrieve status of haproxy service
* @return array
* @throws \Exception
*/
public function statusAction()
{
$backend = new Backend();
$mdlProxy = new HAProxy();
$response = $backend->configdRun("haproxy status");

if (strpos($response, "not running") > 0) {
if ($mdlProxy->general->enabled->__toString() == 1) {
$status = "stopped";
} else {
$status = "disabled";
}
} elseif (strpos($response, "is running") > 0) {
$status = "running";
} elseif ($mdlProxy->general->enabled->__toString() == 0) {
$status = "disabled";
} else {
$status = "unkown";
}

return array("status" => $status);
}

/**
* reconfigure haproxy, generate config and reload
*/
public function reconfigureAction()
{
if ($this->request->isPost()) {
$force_restart = false;
// close session for long running action
$this->sessionClose();

$mdlProxy = new HAProxy();
$backend = new Backend();

$runStatus = $this->statusAction();

// stop haproxy when disabled
if ($runStatus['status'] == "running" &&
($mdlProxy->general->enabled->__toString() == 0 || $force_restart)) {
$this->stopAction();
}

// generate template
$backend->configdRun('template reload OPNsense/HAProxy');

// (res)start daemon
if ($mdlProxy->general->enabled->__toString() == 1) {
if ($runStatus['status'] == "running" && !$force_restart) {
$backend->configdRun("haproxy reload");
} else {
$this->startAction();
}
}

return array("status" => "ok");
} else {
return array("status" => "failed");
}
}
static protected $internalServiceClass = '\OPNsense\HAProxy\HAProxy';
static protected $internalServiceTemplate = 'OPNsense/Haproxy';
static protected $internalServiceEnabled = 'general.enabled';
static protected $internalServiceName = 'haproxy';

/**
* run syntax check for haproxy configuration
Expand Down
Expand Up @@ -198,6 +198,214 @@
<type>text</type>
<help><![CDATA[Verify the source IPv4 address of the client of the session matches the specified IPv4 or IPv6 address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_bytes_in_rate</style>
</field>
<field>
<id>acl.src_bytes_in_rate_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_bytes_in_rate</id>
<label>Incoming bytes rate</label>
<type>text</type>
<help><![CDATA[The average bytes rate from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_bytes_out_rate</style>
</field>
<field>
<id>acl.src_bytes_out_rate_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_bytes_out_rate</id>
<label>Outgoing bytes rate</label>
<type>text</type>
<help><![CDATA[The average bytes rate to the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_conn_cnt</style>
</field>
<field>
<id>acl.src_conn_cnt_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_conn_cnt</id>
<label>Connections count</label>
<type>text</type>
<help><![CDATA[The cumulative number of connections initiated from the current incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_conn_cur</style>
</field>
<field>
<id>acl.src_conn_cur_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_conn_cur</id>
<label>Concurrent connections</label>
<type>text</type>
<help><![CDATA[The current amount of concurrent connections initiated from the current incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_conn_rate</style>
</field>
<field>
<id>acl.src_conn_rate_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_conn_rate</id>
<label>Connection rate</label>
<type>text</type>
<help><![CDATA[The average connection rate from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_http_err_cnt</style>
</field>
<field>
<id>acl.src_http_err_cnt_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_http_err_cnt</id>
<label>HTTP error count</label>
<type>text</type>
<help><![CDATA[The cumulative number of HTTP errors from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_http_err_rate</style>
</field>
<field>
<id>acl.src_http_err_rate_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_http_err_rate</id>
<label>HTTP error rate</label>
<type>text</type>
<help><![CDATA[The average rate of HTTP errors from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_http_req_cnt</style>
</field>
<field>
<id>acl.src_http_req_cnt_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_http_req_cnt</id>
<label>HTTP request count</label>
<type>text</type>
<help><![CDATA[The cumulative number of HTTP requests from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_http_req_rate</style>
</field>
<field>
<id>acl.src_http_req_rate_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_http_req_rate</id>
<label>HTTP request rate</label>
<type>text</type>
<help><![CDATA[The average rate of HTTP requests from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_kbytes_in</style>
</field>
<field>
<id>acl.src_kbytes_in_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_kbytes_in</id>
<label>Data received</label>
<type>text</type>
<help><![CDATA[The total amount of data received from the incoming connection's source address (in kilobytes).]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_kbytes_out</style>
</field>
<field>
<id>acl.src_kbytes_out_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_kbytes_out</id>
<label>Data sent</label>
<type>text</type>
<help><![CDATA[The total amount of data sent to the incoming connection's source address (in kilobytes).]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_port</style>
</field>
<field>
<id>acl.src_port_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_port</id>
<label>Source port</label>
<type>text</type>
<help><![CDATA[An integer value corresponding to the TCP source port of the connection on the client side, which is the port the client connected from.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
<style>expression_table table_src_sess_cnt</style>
</field>
<field>
<id>acl.src_sess_cnt_comparison</id>
<label>Comparison</label>
<type>dropdown</type>
</field>
<field>
<id>acl.src_sess_cnt</id>
<label>Session count</label>
<type>text</type>
<help><![CDATA[The cumulative number of connections initiated from the incoming connection's source address.]]></help>
</field>
<field>
<label>Parameters</label>
<type>header</type>
Expand Down