From 12a4ff878a41e407aa1a446fb5b6a757c6207706 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Sun, 15 Nov 2015 22:46:44 +0100 Subject: pfflowd - add privileges configuration, fixes and cleanups - Add privileges configuration - Add Enable checkbox instead of using the foreach() hack - Validate Source IP as well --- config/pfflowd/pfflowd.xml | 149 +++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 80 deletions(-) (limited to 'config') 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 @@ ]]> pfflowd - 1.0.3 - pfflowd: Settings - pkg_edit.php?xml=pfflowd.xml&id=0 + 1.0.4 + Services: pfflowd Settings + pkg_edit.php?xml=pfflowd.xml pfflowd Modify pfflowd settings.
Services
pfflowd.xml - /pkg_edit.php?xml=pfflowd.xml&id=0 + /pkg_edit.php?xml=pfflowd.xml
pfflowd pfflowd.sh pfflowd + Netflow Export Daemon installedpackages->package->$packagename->configuration->settings + + /etc/inc/priv/ + https://packages.pfsense.org/packages/config/pfflowd/pfflowd.priv.inc + - Host + Enable pfflowd + enabled + Check this to enable pfflowd daemon. + checkbox + + + Destination Host host - Specify the host that datagrams are to be sent to. + Specify the IP address of the host that datagrams are to be sent to. input + - Port + Destination Port port Enter the port that datagrams are to be sent to. input + - Source Hostname/IP + Source IP sourcehost - Specify the hostname or IP address that datagrams are to be sent from. The hostname/IP must be local to this system. + + The IP must be local to this system. + ]]> + input - pf rule direction restriction + pf Rule Direction Restriction direction Restrict creation of flow records to states matching a certain direction (in, out, or any). select - - - + + + - Netflow version + Netflow Version version Select which version of the NetFlow protocol to use. select - - - + + + "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; } ]]> @@ -183,7 +175,4 @@ validate_form_pfflowd($_POST, $input_errors); - - cleanup_config_pfflowd(); - -- cgit v1.2.3