aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Buechler <cmb@pfsense.org>2015-11-16 01:47:22 -0600
committerChris Buechler <cmb@pfsense.org>2015-11-16 01:47:22 -0600
commita8b2bcdaffc7b1f30fa82799f90e15d3c8c93a26 (patch)
tree047658cd4b60fd1e3ef20e210a79b466d7988944
parent52c1506c5441c2d5d492ef1bc28a9b97a4fad67c (diff)
parentd74b03f386cf2cb80c1be781e0ad82c8168a453e (diff)
downloadpfsense-packages-a8b2bcdaffc7b1f30fa82799f90e15d3c8c93a26.tar.gz
pfsense-packages-a8b2bcdaffc7b1f30fa82799f90e15d3c8c93a26.tar.bz2
pfsense-packages-a8b2bcdaffc7b1f30fa82799f90e15d3c8c93a26.zip
Merge pull request #1172 from doktornotor/patch-4
-rw-r--r--config/pfflowd/pfflowd.priv.inc37
-rw-r--r--config/pfflowd/pfflowd.xml149
-rw-r--r--pkg_config.10.xml2
-rw-r--r--pkg_config.8.xml2
-rw-r--r--pkg_config.8.xml.amd642
5 files changed, 109 insertions, 83 deletions
diff --git a/config/pfflowd/pfflowd.priv.inc b/config/pfflowd/pfflowd.priv.inc
new file mode 100644
index 00000000..67074f52
--- /dev/null
+++ b/config/pfflowd/pfflowd.priv.inc
@@ -0,0 +1,37 @@
+<?php
+/*
+ pfflowd.priv.inc
+ part of pfSense (http://www.pfSense.org/)
+ Copyright (C) 2015 ESF, LLC
+ 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.
+*/
+global $priv_list;
+
+$priv_list['page-services-pfflowd'] = array();
+$priv_list['page-services-pfflowd']['name'] = "WebCfg - Services: pfflowd package";
+$priv_list['page-services-pfflowd']['descr'] = "Allow access to pfflowd package GUI";
+$priv_list['page-services-pfflowd']['match'] = array();
+$priv_list['page-services-pfflowd']['match'][] = "pkg_edit.php?xml=pfflowd.xml*";
+
+?>
diff --git a/config/pfflowd/pfflowd.xml b/config/pfflowd/pfflowd.xml
index 44294d69..25a68a2c 100644
--- a/config/pfflowd/pfflowd.xml
+++ b/config/pfflowd/pfflowd.xml
@@ -42,138 +42,130 @@
]]>
</copyright>
<name>pfflowd</name>
- <version>1.0.3</version>
- <title>pfflowd: Settings</title>
- <aftersaveredirect>pkg_edit.php?xml=pfflowd.xml&amp;id=0</aftersaveredirect>
+ <version>1.0.4</version>
+ <title>Services: pfflowd Settings</title>
+ <aftersaveredirect>pkg_edit.php?xml=pfflowd.xml</aftersaveredirect>
<menu>
<name>pfflowd</name>
<tooltiptext>Modify pfflowd settings.</tooltiptext>
<section>Services</section>
<configfile>pfflowd.xml</configfile>
- <url>/pkg_edit.php?xml=pfflowd.xml&amp;id=0</url>
+ <url>/pkg_edit.php?xml=pfflowd.xml</url>
</menu>
<service>
<name>pfflowd</name>
<rcfile>pfflowd.sh</rcfile>
<executable>pfflowd</executable>
+ <description>Netflow Export Daemon</description>
</service>
<configpath>installedpackages->package->$packagename->configuration->settings</configpath>
+ <additional_files_needed>
+ <prefix>/etc/inc/priv/</prefix>
+ <item>https://packages.pfsense.org/packages/config/pfflowd/pfflowd.priv.inc</item>
+ </additional_files_needed>
<fields>
<field>
- <fielddescr>Host</fielddescr>
+ <fielddescr>Enable pfflowd</fielddescr>
+ <fieldname>enabled</fieldname>
+ <description>Check this to enable pfflowd daemon.</description>
+ <type>checkbox</type>
+ </field>
+ <field>
+ <fielddescr>Destination Host</fielddescr>
<fieldname>host</fieldname>
- <description>Specify the host that datagrams are to be sent to.</description>
+ <description>Specify the IP address of the host that datagrams are to be sent to.</description>
<type>input</type>
+ <required/>
</field>
<field>
- <fielddescr>Port</fielddescr>
+ <fielddescr>Destination Port</fielddescr>
<fieldname>port</fieldname>
<description>Enter the port that datagrams are to be sent to.</description>
<type>input</type>
+ <required/>
</field>
<field>
- <fielddescr>Source Hostname/IP</fielddescr>
+ <fielddescr>Source IP</fielddescr>
<fieldname>sourcehost</fieldname>
- <description>Specify the hostname or IP address that datagrams are to be sent from. The hostname/IP must be local to this system.</description>
+ <description>
+ <![CDATA[
+ Specify the IP address that datagrams are to be sent from. <strong>The IP must be local to this system.</strong>
+ ]]>
+ </description>
<type>input</type>
</field>
<field>
- <fielddescr>pf rule direction restriction</fielddescr>
+ <fielddescr>pf Rule Direction Restriction</fielddescr>
<fieldname>direction</fieldname>
<description>Restrict creation of flow records to states matching a certain direction (in, out, or any).</description>
<type>select</type>
<options>
- <option>
- <name>Any</name>
- <value>any</value>
- </option>
- <option>
- <name>In</name>
- <value>in</value>
- </option>
- <option>
- <name>Out</name>
- <value>out</value>
- </option>
+ <option><name>Any</name><value>any</value></option>
+ <option><name>In</name><value>in</value></option>
+ <option><name>Out</name><value>out</value></option>
</options>
</field>
<field>
- <fielddescr>Netflow version</fielddescr>
+ <fielddescr>Netflow Version</fielddescr>
<fieldname>version</fieldname>
<description>Select which version of the NetFlow protocol to use.</description>
<type>select</type>
<options>
- <option>
- <name>9</name>
- <value>9</value>
- </option>
- <option>
- <name>5</name>
- <value>5</value>
- </option>
- <option>
- <name>1</name>
- <value>1</value>
- </option>
+ <option><name>9</name><value>9</value></option>
+ <option><name>5</name><value>5</value></option>
+ <option><name>1</name><value>1</value></option>
</options>
</field>
</fields>
<custom_php_global_functions>
<![CDATA[
function sync_package_pfflowd() {
- conf_mount_rw();
global $config;
- foreach ($config['installedpackages']['pfflowd']['config'] as $cf) {
- if ($cf['host'] != "") {
- $start = "\n/sbin/ifconfig pfsync0 up\n";
- $start .= "/usr/local/sbin/pfflowd ";
- $start .= " -n {$cf['host']}";
- if ($cf['port'] != "") {
- $start .= ":{$cf['port']}";
- }
- if (!empty($cf['sourcehost'])) {
- $start .= " -s {$cf['sourcehost']} ";
- }
- if ($cf['direction'] != "") {
- $start .= " -S {$cf['direction']}";
- }
- if ($cf['version'] != "") {
- $start .= " -v {$cf['version']}";
- }
- write_rcfile(array(
- "file" => "pfflowd.sh",
- "start" => $start,
- "stop" => "/usr/bin/killall pfflowd"
- )
- );
+ conf_mount_rw();
+ if (is_array($config['installedpackages']['pfflowd']['config'])) {
+ $cf = $config['installedpackages']['pfflowd']['config'][0];
+ } else {
+ $cf = array();
+ }
+ if ($cf['enabled'] == "on") {
+ $start = "\n/sbin/ifconfig pfsync0 up\n";
+ $start .= "/usr/local/sbin/pfflowd ";
+ $start .= " -n {$cf['host']}";
+ $start .= ":{$cf['port']}";
+ if (!empty($cf['sourcehost'])) {
+ $start .= " -s {$cf['sourcehost']} ";
+ }
+ if ($cf['direction'] != "") {
+ $start .= " -S {$cf['direction']}";
+ }
+ if ($cf['version'] != "") {
+ $start .= " -v {$cf['version']}";
+ }
+ write_rcfile(array("file" => "pfflowd.sh", "start" => $start, "stop" => "/usr/bin/killall pfflowd"));
+ if (is_service_running("pfflowd")) {
restart_service("pfflowd");
- break;
+ } else {
+ start_service("pfflowd");
+ }
+ } else {
+ if (is_service_running("pfflowd")) {
+ stop_service("pfflowd");
}
+ unlink_if_exists("/usr/local/etc/rc.d/pfflowd.sh");
}
conf_mount_ro();
}
function validate_form_pfflowd($post, &$input_errors) {
- if (($post['host'] == "") || !is_ipaddr($post['host'])) {
- $input_errors[] = 'You must specify a valid ip address in the \'Host\' field';
+ if ($post['host'] != "" && !is_ipaddr($post['host'])) {
+ $input_errors[] = 'You must specify a valid IP address in the \'Destination Host\' field';
}
- if (($post['port'] == "") || !is_port($post['port'])) {
- $input_errors[] = 'You must specify a valid port number in the \'Port\' field';
+ if ($post['port'] != "" && !is_port($post['port'])) {
+ $input_errors[] = 'You must specify a valid port number in the \'Destination Port\' field';
}
- }
-
- function cleanup_config_pfflowd() {
- global $a_pkg;
- $pffconf = array();
- if (is_array($a_pkg)) {
- foreach($a_pkg as $cf) {
- if ($cf['host'] != "") {
- $pffconf = $cf;
- }
- }
+ if ($post['sourcehost'] != "" && !is_ipaddr($post['sourcehost'])) {
+ $input_errors[] = 'You must specify a valid IP address in the \'Source IP\' field';
}
- $a_pkg = array();
- $a_pkg[0] = $pffconf;
}
]]>
</custom_php_global_functions>
@@ -183,7 +175,4 @@
<custom_php_validation_command>
validate_form_pfflowd($_POST, $input_errors);
</custom_php_validation_command>
- <custom_php_command_before_form>
- cleanup_config_pfflowd();
- </custom_php_command_before_form>
</packagegui>
diff --git a/pkg_config.10.xml b/pkg_config.10.xml
index bad12f6c..5904697b 100644
--- a/pkg_config.10.xml
+++ b/pkg_config.10.xml
@@ -897,7 +897,7 @@
<category>Network Management</category>
<config_file>https://packages.pfsense.org/packages/config/pfflowd/pfflowd.xml</config_file>
<depends_on_package_pbi>pfflowd-0.8_1-##ARCH##.pbi</depends_on_package_pbi>
- <version>1.0.3</version>
+ <version>1.0.4</version>
<status>RELEASE</status>
<required_version>3.0</required_version>
<configurationfile>pfflowd.xml</configurationfile>
diff --git a/pkg_config.8.xml b/pkg_config.8.xml
index 12352ac4..520fb3b0 100644
--- a/pkg_config.8.xml
+++ b/pkg_config.8.xml
@@ -928,7 +928,7 @@
<depends_on_package_base_url>https://files.pfsense.org/packages/8/All/</depends_on_package_base_url>
<depends_on_package>pfflowd-0.8.tbz</depends_on_package>
<depends_on_package_pbi>pfflowd-0.8-i386.pbi</depends_on_package_pbi>
- <version>0.8.3 pkg v1.0.1</version>
+ <version>0.8.3 pkg v1.0.4</version>
<status>Stable</status>
<required_version>2.0</required_version>
<configurationfile>pfflowd.xml</configurationfile>
diff --git a/pkg_config.8.xml.amd64 b/pkg_config.8.xml.amd64
index 701c6bd4..a452835b 100644
--- a/pkg_config.8.xml.amd64
+++ b/pkg_config.8.xml.amd64
@@ -915,7 +915,7 @@
<depends_on_package_base_url>https://files.pfsense.org/packages/amd64/8/All/</depends_on_package_base_url>
<depends_on_package>pfflowd-0.8.tbz</depends_on_package>
<depends_on_package_pbi>pfflowd-0.8-amd64.pbi</depends_on_package_pbi>
- <version>0.8.3 pkg v1.0.1</version>
+ <version>0.8.3 pkg v1.0.4</version>
<status>Stable</status>
<required_version>2.0</required_version>
<configurationfile>pfflowd.xml</configurationfile>