mirror of
https://github.com/opnsense/plugins.git
synced 2026-05-28 04:34:15 -04:00
net/ntopng: release 1.1
This commit is contained in:
parent
d379475bec
commit
335d9912a2
7 changed files with 113 additions and 3 deletions
|
|
@ -1,6 +1,5 @@
|
|||
PLUGIN_NAME= ntopng
|
||||
PLUGIN_VERSION= 1.0
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_VERSION= 1.1
|
||||
PLUGIN_COMMENT= Traffic Analysis and Flow Collection
|
||||
PLUGIN_DEPENDS= ntopng
|
||||
PLUGIN_MAINTAINER= m.muenz@gmail.com
|
||||
|
|
|
|||
|
|
@ -18,6 +18,18 @@
|
|||
<type>text</type>
|
||||
<help>HTTP Port this service listens on.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.httpsport</id>
|
||||
<label>HTTPS Port</label>
|
||||
<type>text</type>
|
||||
<help>HTTPS Port this service listens on. If you enable HTTPS you will be redirected from HTTP to HTTPS. Please select a certificate below</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.cert</id>
|
||||
<label>Certificate</label>
|
||||
<type>dropdown</type>
|
||||
<help>Set the certificate to use for HTTPS connections.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>general.dnsmode</id>
|
||||
<label>DNS Mode</label>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,27 @@
|
|||
<Required>Y</Required>
|
||||
<default>3000</default>
|
||||
</httpport>
|
||||
<httpsport type="PortField">
|
||||
<Required>N</Required>
|
||||
<Constraints>
|
||||
<check001>
|
||||
<ValidationMessage>Please select a HTTPS port and a valid certificate</ValidationMessage>
|
||||
<type>AllOrNoneConstraint</type>
|
||||
<addFields>
|
||||
<field1>cert</field1>
|
||||
</addFields>
|
||||
</check001>
|
||||
</Constraints>
|
||||
</httpsport>
|
||||
<cert type="CertificateField">
|
||||
<Type>cert</Type>
|
||||
<Required>N</Required>
|
||||
<Constraints>
|
||||
<check001>
|
||||
<reference>httpsport.check001</reference>
|
||||
</check001>
|
||||
</Constraints>
|
||||
</cert>
|
||||
<dnsmode type="OptionField">
|
||||
<Required>N</Required>
|
||||
<OptionValues>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/local/bin/php
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright (C) 2015 Deciso B.V.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
// use legacy code to generate certs and ca's
|
||||
// eventually we need to replace this.
|
||||
require_once("config.inc");
|
||||
require_once("certs.inc");
|
||||
require_once("legacy_bindings.inc");
|
||||
|
||||
use OPNsense\Core\Config;
|
||||
|
||||
$cert_pem_filename = '/usr/local/share/ntopng/httpdocs/ssl/ntopng-cert.pem';
|
||||
$cert_pem_content = '';
|
||||
|
||||
// traverse Postfix plugin for certficiates
|
||||
$configObj = Config::getInstance()->object();
|
||||
if (isset($configObj->OPNsense->ntopng)) {
|
||||
foreach ($configObj->OPNsense->ntopng->children() as $find_cert) {
|
||||
$cert_refid = (string)$find_cert->cert;
|
||||
// if httpsport has a certificate attached, search for its contents
|
||||
if ($cert_refid != "") {
|
||||
foreach ($configObj->cert as $cert) {
|
||||
if ($cert_refid == (string)$cert->refid) {
|
||||
// generate cert pem file
|
||||
$pem_content = trim(str_replace("\n\n", "\n", str_replace(
|
||||
"\r",
|
||||
"",
|
||||
base64_decode((string)$cert->crt)
|
||||
)));
|
||||
|
||||
$pem_content .= "\n";
|
||||
$pem_content .= trim(str_replace(
|
||||
"\n\n",
|
||||
"\n",
|
||||
str_replace("\r", "", base64_decode((string)$cert->prv))
|
||||
));
|
||||
$pem_content .= "\n";
|
||||
$cert_pem_content .= $pem_content;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
file_put_contents($cert_pem_filename, $cert_pem_content);
|
||||
chmod($cert_pem_filename, 0644);
|
||||
echo "Certificates generated $cert_pem_filename\n";
|
||||
|
|
@ -7,3 +7,5 @@ chown ntopng:ntopng /var/run/ntopng
|
|||
mkdir -p /var/tmp/ntopng/
|
||||
chmod 755 /var/tmp/ntopng
|
||||
chown ntopng:wheel /var/tmp/ntopng
|
||||
|
||||
/usr/local/opnsense/scripts/OPNsense/Ntopng/generate_certs.php
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ type:script
|
|||
message:restarting ntopng
|
||||
|
||||
[status]
|
||||
command:sh /usr/local/etc/rc.d/ntopng status;exit 0
|
||||
command:/usr/local/etc/rc.d/ntopng status; exit 0
|
||||
parameters:
|
||||
type:script_output
|
||||
message:ntopng status
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@
|
|||
{% if helpers.exists('OPNsense.ntopng.general.httpport') and OPNsense.ntopng.general.httpport != '' %}
|
||||
-w={{ OPNsense.ntopng.general.httpport }}
|
||||
{% endif %}
|
||||
{% if helpers.exists('OPNsense.ntopng.general.httpsport') and OPNsense.ntopng.general.httpsport != '' %}
|
||||
-W={{ OPNsense.ntopng.general.httpsport }}
|
||||
{% endif %}
|
||||
{% if helpers.exists('OPNsense.ntopng.general.dnsmode') and OPNsense.ntopng.general.dnsmode != '' %}
|
||||
-n={{ OPNsense.ntopng.general.dnsmode }}
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Reference in a new issue