C-ICAP plugin (#226)

* api fix
* Create antivirus.xml
* few modelling
* file type scanning
* fix in template
* indent fixes
* initial c-icap commit
* modelling
* Rename actions_clamav.conf to actions_cicap.conf
* Rename c-icap.inc to cicap.inc
* templating and typos
* typo
* Update actions_cicap.conf
* Update antivirus.xml
* Update Antivirus.xml
* Update c-icap.conf
* Update GeneralController.php
* Update general.volt
* Update General.xml
* Update Makefile
* Update Menu.xml
* Update ServiceController.php
* Update +TARGETS
* Update virus_scan.conf
* update volt
This commit is contained in:
Michael
2017-08-16 22:15:15 +02:00
committed by Fabian Franz
parent 46554a1f7f
commit 44b60a4264
23 changed files with 975 additions and 1 deletions
@@ -12,7 +12,7 @@
<Required>Y</Required>
</fc_enabled>
<enabletcp type="BooleanField">
<default>0</default>
<default>1</default>
<Required>Y</Required>
</enabletcp>
<maxthreads type="IntegerField">
+8
View File
@@ -0,0 +1,8 @@
PLUGIN_NAME= c-icap
PLUGIN_VERSION= 0.1
PLUGIN_COMMENT= c-icap connects your Proxy with a virus scanner
PLUGIN_DEPENDS= c-icap c-icap-modules
PLUGIN_MAINTAINER= m.muenz@gmail.com
PLUGIN_DEVEL= yes
.include "../../Mk/plugins.mk"
+6
View File
@@ -0,0 +1,6 @@
c-icap is an implementation of an ICAP server.
It can be used with HTTP proxies that support
the ICAP protocol to implement content adaptation
and filtering services.
WWW: http://c-icap.sourceforge.net/
@@ -0,0 +1,49 @@
<?php
/*
Copyright (C) 2017 Michael Muenz
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 cicap_services()
{
global $config;
$services = array();
if (isset($config['OPNsense']['cicap']['general']['enabled']) && $config['OPNsense']['cicap']['general']['enabled'] == 1) {
$services[] = array(
'description' => gettext('C-ICAP server'),
'configd' => array(
'restart' => array('cicap restart'),
'start' => array('cicap start'),
'stop' => array('cicap stop'),
),
'name' => 'cicap',
'pidfile' => '/var/run/c-icap/c-icap.pid'
);
}
return $services;
}
@@ -0,0 +1,77 @@
<?php
/**
* Copyright (C) 2015 - 2017 Deciso B.V.
* Copyright (C) 2017 Michael Muenz
*
* 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\CICAP\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\CICAP\Antivirus;
use \OPNsense\Core\Config;
class AntivirusController extends ApiControllerBase
{
public function getAction()
{
// define list of configurable settings
$result = array();
if ($this->request->isGet()) {
$mdlAntivirus = new Antivirus();
$result['antivirus'] = $mdlAntivirus->getNodes();
}
return $result;
}
public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlAntivirus = new Antivirus();
$mdlAntivirus->setNodes($this->request->getPost("antivirus"));
// perform validation
$valMsgs = $mdlAntivirus->performValidation();
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validations", $result)) {
$result["validations"] = array();
}
$result["validations"]["antivirus.".$msg->getField()] = $msg->getMessage();
}
// serialize model to config and save
if ($valMsgs->count() == 0) {
$mdlAntivirus->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
}
return $result;
}
}
@@ -0,0 +1,77 @@
<?php
/**
* Copyright (C) 2015 - 2017 Deciso B.V.
* Copyright (C) 2017 Michael Muenz
*
* 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\CICAP\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\CICAP\General;
use \OPNsense\Core\Config;
class GeneralController extends ApiControllerBase
{
public function getAction()
{
// define list of configurable settings
$result = array();
if ($this->request->isGet()) {
$mdlGeneral = new General();
$result['general'] = $mdlGeneral->getNodes();
}
return $result;
}
public function setAction()
{
$result = array("result"=>"failed");
if ($this->request->isPost()) {
// load model and update with provided data
$mdlGeneral = new General();
$mdlGeneral->setNodes($this->request->getPost("general"));
// perform validation
$valMsgs = $mdlGeneral->performValidation();
foreach ($valMsgs as $field => $msg) {
if (!array_key_exists("validations", $result)) {
$result["validations"] = array();
}
$result["validations"]["general.".$msg->getField()] = $msg->getMessage();
}
// serialize model to config and save
if ($valMsgs->count() == 0) {
$mdlGeneral->serializeToConfig();
Config::getInstance()->save();
$result["result"] = "saved";
}
}
return $result;
}
}
@@ -0,0 +1,160 @@
<?php
/**
* Copyright (C) 2015 - 2017 Deciso B.V.
* Copyright (C) 2017 Michael Muenz
*
* 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\CICAP\Api;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\CICAP\General;
/**
* Class ServiceController
* @package OPNsense\CICAP
*/
class ServiceController extends ApiControllerBase
{
/**
* check if ClamAV plugin is installed
* @return array
*/
public function checkclamavAction()
{
$backend = new Backend();
$mdlGeneral = new General();
$response = $backend->configdRun("firmware plugin clamav");
return $response;
}
/**
* start cicap service (in background)
* @return array
*/
public function startAction()
{
if ($this->request->isPost()) {
$backend = new Backend();
$response = $backend->configdRun("cicap start", true);
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* stop cicap service
* @return array
*/
public function stopAction()
{
if ($this->request->isPost()) {
$backend = new Backend();
$response = $backend->configdRun("cicap stop");
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* restart cicap service
* @return array
*/
public function restartAction()
{
if ($this->request->isPost()) {
$backend = new Backend();
$response = $backend->configdRun("cicap restart");
return array("response" => $response);
} else {
return array("response" => array());
}
}
/**
* retrieve status of cicap
* @return array
* @throws \Exception
*/
public function statusAction()
{
$backend = new Backend();
$mdlGeneral = new General();
$response = $backend->configdRun("cicap status");
if (strpos($response, "not running") > 0) {
if ($mdlGeneral->enabled->__toString() == 1) {
$status = "stopped";
} else {
$status = "disabled";
}
} elseif (strpos($response, "is running") > 0) {
$status = "running";
} elseif ($mdlGeneral->enabled->__toString() == 0) {
$status = "disabled";
} else {
$status = "unkown";
}
return array("status" => $status);
}
/**
* reconfigure cicap, generate config and reload
*/
public function reconfigureAction()
{
if ($this->request->isPost()) {
// close session for long running action
$this->sessionClose();
$mdlGeneral = new General();
$backend = new Backend();
$runStatus = $this->statusAction();
// stop cicap if it is running or not
$this->stopAction();
// generate template
$backend->configdRun('template reload OPNsense/CICAP');
// (res)start daemon
if ($mdlGeneral->enabled->__toString() == 1) {
$this->startAction();
}
return array("status" => "ok");
} else {
return array("status" => "failed");
}
}
}
@@ -0,0 +1,40 @@
<?php
/*
Copyright (C) 2017 Michael Muenz
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\CICAP;
class GeneralController extends \OPNsense\Base\IndexController
{
public function indexAction()
{
$this->view->title = gettext("C-ICAP Settings");
$this->view->generalForm = $this->getForm("general");
$this->view->antivirusForm = $this->getForm("antivirus");
$this->view->pick('OPNsense/CICAP/general');
}
}
@@ -0,0 +1,45 @@
<form>
<field>
<id>antivirus.enable_clamav</id>
<label>Enable ClamAV</label>
<type>checkbox</type>
<help>This will activate ClamAV</help>
</field>
<field>
<id>antivirus.scanfiletypes</id>
<label>Scan for filetypes</label>
<type>select_multiple</type>
<style>tokenize</style>
<help>Choose for which file types to scan, if unsure select all.</help>
</field>
<field>
<id>antivirus.sendpercentdata</id>
<label>Send percentage data</label>
<type>text</type>
<help>The percentage of data that can be sent by the c-icap server before receiving the complete body of a request. This feature in conjuction with the folowing can be useful because if the download of the object takes a lot of time the connection of web client to proxy can be expired.</help>
</field>
<field>
<id>antivirus.startsendpercentdataafter</id>
<label>Start send pecerantage data</label>
<type>text</type>
<help>Only if the object is bigger than size then the percentage of data which defined by SendPercentData sent by the c-icap server before receiving the complete body of request.</help>
</field>
<field>
<id>antivirus.allow204responses</id>
<label>Allow 204 responses</label>
<type>checkbox</type>
<help>Disable 204 responses outside previews for virus_scan if your ICAP client does not support it.</help>
</field>
<field>
<id>antivirus.passonerror</id>
<label>Pass on error</label>
<type>checkbox</type>
<help>Pass the content instead of blocking it, in the case when the virus scanner or the virus_scan module finds an error.</help>
</field>
<field>
<id>antivirus.maxobjectsize</id>
<label>Max object size</label>
<type>text</type>
<help>The maximum size of files which will be scanned by antivirus service. You can use K and M indicators to define size in kilobytes or megabytes.</help>
</field>
</form>
@@ -0,0 +1,80 @@
<form>
<field>
<id>general.enabled</id>
<label>Enable c-icap service</label>
<type>checkbox</type>
<help>This will activate the c-icap service.</help>
</field>
<field>
<id>general.timeout</id>
<label>Timeout</label>
<type>text</type>
<help>The time in seconds after which a connection without activity can be cancelled.</help>
</field>
<field>
<id>general.maxkeepaliverequests</id>
<label>Max keepalive requests</label>
<type>text</type>
<help>The maximum number of requests can be served by one connection</help>
</field>
<field>
<id>general.keepalivetimeout</id>
<label>Max keepalive timeout</label>
<type>text</type>
<help>The maximum time in seconds waiting for a new requests before a connection will be closed.</help>
</field>
<field>
<id>general.startservers</id>
<label>Start servers</label>
<type>text</type>
<help>The initial number of server processes. Each server process generates a number of threads, which serve the requests.</help>
</field>
<field>
<id>general.maxservers</id>
<label>Max servers</label>
<type>text</type>
<help>The maximum allowed number of server processes.</help>
</field>
<field>
<id>general.minsparethreads</id>
<label>Min spare threads</label>
<type>text</type>
<help>If the number of the available threads is less than number, the c-icap server starts a new child.</help>
</field>
<field>
<id>general.maxsparethreads</id>
<label>Max spare threads</label>
<type>test</type>
<help>If the number of the available threads is more than number then the c-icap server kills a child.</help>
</field>
<field>
<id>general.threadsperchild</id>
<label>Threads per child</label>
<type>text</type>
<help>The number of threads per child process.</help>
</field>
<field>
<id>general.maxrequestsperchild</id>
<label>Max requests per child</label>
<type>text</type>
<help>The maximum number of requests that a child process can serve. After this number has been reached, process dies.</help>
</field>
<field>
<id>general.listenaddress</id>
<label>Listen address</label>
<type>text</type>
<help>Network address that the c-icap server uses to listen to requests.</help>
</field>
<field>
<id>general.serveradmin</id>
<label>Server admin</label>
<type>text</type>
<help>The Administrator of this server. Used when displaying information about this server.</help>
</field>
<field>
<id>general.servername</id>
<label>Servername</label>
<type>text</type>
<help>A name for this server. Used when displaying information about this server (logs, info service, etc).</help>
</field>
</form>
@@ -0,0 +1,9 @@
<acl>
<page-services-cicap>
<name>Services: C-ICAP</name>
<patterns>
<pattern>ui/cicap/*</pattern>
<pattern>api/cicap/*</pattern>
</patterns>
</page-services-cicap>
</acl>
@@ -0,0 +1,35 @@
<?php
/*
Copyright (C) 2017 Michael Muenz
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\CICAP;
use OPNsense\Base\BaseModel;
class Antivirus extends BaseModel
{
}
@@ -0,0 +1,45 @@
<model>
<mount>//OPNsense/cicap/antivirus</mount>
<description>AntiVirus configuration</description>
<version>1.0.0</version>
<items>
<enable_clamav type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enable_clamav>
<scanfiletypes type="OptionField">
<default></default>
<multiple>Y</multiple>
<Required>Y</Required>
<OptionValues>
<TEXT>Text files</TEXT>
<DATA>Binary files</DATA>
<EXECUTABLE>Executables</EXECUTABLE>
<ARCHIVE>Archives</ARCHIVE>
<GIF>GIF animations</GIF>
<JPEG>JPEG pictures</JPEG>
<MSOFFICE>Microsoft office files</MSOFFICE>
</OptionValues>
</scanfiletypes>
<sendpercentdata type="IntegerField">
<default>5</default>
<Required>Y</Required>
</sendpercentdata>
<startsendpercentdataafter type="TextField">
<default>2M</default>
<Required>Y</Required>
</startsendpercentdataafter>
<allow204responses type="BooleanField">
<default>1</default>
<Required>Y</Required>
</allow204responses>
<passonerror type="BooleanField">
<default>N</default>
<Required>Y</Required>
</passonerror>
<maxobjectsize type="TextField">
<default>5M</default>
<Required>Y</Required>
</maxobjectsize>
</items>
</model>
@@ -0,0 +1,35 @@
<?php
/*
Copyright (C) 2017 Michael Muenz
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\CICAP;
use OPNsense\Base\BaseModel;
class General extends BaseModel
{
}
@@ -0,0 +1,62 @@
<model>
<mount>//OPNsense/cicap/general</mount>
<description>c-icap configuration</description>
<version>1.0.0</version>
<items>
<enabled type="BooleanField">
<default>0</default>
<Required>Y</Required>
</enabled>
<timeout type="IntegerField">
<default>300</default>
<Required>Y</Required>
</timeout>
<maxkeepaliverequests type="IntegerField">
<default>100</default>
<Required>Y</Required>
</maxkeepaliverequests>
<keepalivetimeout type="IntegerField">
<default>600</default>
<Required>Y</Required>
</keepalivetimeout>
<startservers type="IntegerField">
<default>3</default>
<Required>Y</Required>
</startservers>
<maxservers type="IntegerField">
<default>10</default>
<Required>Y</Required>
</maxservers>
<minsparethreads type="IntegerField">
<default>10</default>
<Required>Y</Required>
</minsparethreads>
<maxsparethreads type="IntegerField">
<default>20</default>
<Required>Y</Required>
</maxsparethreads>
<threadsperchild type="IntegerField">
<default>10</default>
<Required>Y</Required>
</threadsperchild>
<maxrequestsperchild type="IntegerField">
<default>0</default>
<Required>Y</Required>
</maxrequestsperchild>
<listenaddress type="NetworkField">
<default>::1</default>
<WildcardEnabled>N</WildcardEnabled>
<NetMaskRequired>N</NetMaskRequired>
<FieldSeparator>,</FieldSeparator>
<Required>Y</Required>
</listenaddress>
<serveradmin type="TextField">
<default></default>
<Required>N</Required>
</serveradmin>
<servername type="TextField">
<default></default>
<Required>N</Required>
</servername>
</items>
</model>
@@ -0,0 +1,5 @@
<menu>
<Services>
<C_ICAP VisibleName="C-ICAP" cssClass="fa fa-ambulance" url="/ui/cicap/general/index" />
</Services>
</menu>
@@ -0,0 +1,104 @@
{#
OPNsense® is Copyright © 2014 2017 by Deciso B.V.
This file is Copyright © 2017 by Michael Muenz
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.
#}
<div class="alert alert-warning" role="alert" id="missing_clamav" style="display:none;min-height:65px;">
<div style="margin-top: 8px;">{{ lang._('No ClamAV plugin found, please install via System > Firmware > Plugins.')}}</div>
</div>
<ul class="nav nav-tabs" data-tabs="tabs" id="maintabs">
<li class="active"><a data-toggle="tab" href="#general">{{ lang._('General') }}</a></li>
<li><a data-toggle="tab" href="#antivirus">{{ lang._('Antivirus') }}</a></li>
</ul>
<div class="tab-content content-box tab-content">
<div id="general" class="tab-pane fade in active">
<div class="content-box" style="padding-bottom: 1.5em;">
{{ partial("layout_partials/base_form",['fields':generalForm,'id':'frm_general_settings'])}}
<hr />
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct_progress" class=""></i></button>
</div>
</div>
</div>
<div id="antivirus" class="tab-pane fade in">
<div class="content-box" style="padding-bottom: 1.5em;">
{{ partial("layout_partials/base_form",['fields':antivirusForm,'id':'frm_antivirus_settings'])}}
<hr />
<div class="col-md-12">
<button class="btn btn-primary" id="saveAct2" type="button"><b>{{ lang._('Save') }}</b><i id="saveAct2_progress" class=""></i></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
$( document ).ready(function() {
var data_get_map = {'frm_general_settings':"/api/cicap/general/get"};
mapDataToFormUI(data_get_map).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
var data_get_map2 = {'frm_antivirus_settings':"/api/cicap/antivirus/get"};
mapDataToFormUI(data_get_map2).done(function(data){
formatTokenizersUI();
$('.selectpicker').selectpicker('refresh');
});
ajaxCall(url="/api/cicap/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
// check if ClamAV plugin is installed
ajaxCall(url="/api/cicap/service/checkclamav", sendData={}, callback=function(data,status) {
if (data == "0") {
$('#missing_clamav').show();
}
});
// link save button to API set action
$("#saveAct").click(function(){
saveFormToEndpoint(url="/api/cicap/general/set", formid='frm_general_settings',callback_ok=function(){
$("#saveAct_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/cicap/service/reconfigure", sendData={}, callback=function(data,status) {
ajaxCall(url="/api/cicap/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
$("#saveAct_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
$("#saveAct2").click(function(){
saveFormToEndpoint(url="/api/cicap/antivirus/set", formid='frm_antivirus_settings',callback_ok=function(){
$("#saveAct2_progress").addClass("fa fa-spinner fa-pulse");
ajaxCall(url="/api/cicap/service/reconfigure", sendData={}, callback=function(data,status) {
ajaxCall(url="/api/cicap/service/status", sendData={}, callback=function(data,status) {
updateServiceStatusUI(data['status']);
});
$("#saveAct2_progress").removeClass("fa fa-spinner fa-pulse");
});
});
});
});
</script>
@@ -0,0 +1,9 @@
#!/bin/sh
mkdir -p /var/run/c-icap
chown -R c_icap:c_icap /var/run/c-icap
chmod 750 /var/run/c-icap
mkdir -p /var/log/c-icap
chown -R c_icap:c_icap /var/log/c-icap
chmod 750 /var/log/c-icap
@@ -0,0 +1,29 @@
[start]
command:/usr/local/opnsense/scripts/OPNsense/CICAP/setup.sh;/usr/local/etc/rc.d/c-icap start
parameters:
type:script
message:starting c-icap
[stop]
command:/usr/local/etc/rc.d/c-icap stop; exit 0
parameters:
type:script
message:stopping c-icap
[restart]
command:/usr/local/opnsense/scripts/OPNsense/CICAP/setup.sh;/usr/local/etc/rc.d/c-icap restart
parameters:
type:script
message:restarting c-icap
[reconfigure]
command:/usr/local/opnsense/scripts/OPNsense/CICAP/setup.sh;/usr/local/etc/rc.d/c-icap restart
parameters:
type:script
message:reconfigure c-icap
[status]
command:/usr/local/etc/rc.d/c-icap status;exit 0
parameters:
type:script_output
message:request c-icap status
@@ -0,0 +1,3 @@
c_icap:/etc/rc.conf.d/c_icap
c-icap.conf:/usr/local/etc/c-icap/c-icap.conf
virus_scan.conf:/usr/local/etc/c-icap/virus_scan.conf

Some files were not shown because too many files have changed in this diff Show More