diff --git a/net-mgmt/pfSense-pkg-darkstat/Makefile b/net-mgmt/pfSense-pkg-darkstat/Makefile
index fe83d18eefd4..d6dbe3699f26 100644
--- a/net-mgmt/pfSense-pkg-darkstat/Makefile
+++ b/net-mgmt/pfSense-pkg-darkstat/Makefile
@@ -2,6 +2,7 @@
PORTNAME= pfSense-pkg-darkstat
PORTVERSION= 3.1.3
+PORTREVISION= 1
CATEGORIES= net-mgmt
MASTER_SITES= # empty
DISTFILES= # empty
@@ -25,10 +26,15 @@ do-extract:
do-install:
${MKDIR} ${STAGEDIR}${PREFIX}/pkg
+ ${MKDIR} ${STAGEDIR}${PREFIX}/www
${MKDIR} ${STAGEDIR}/etc/inc/priv
${MKDIR} ${STAGEDIR}${DATADIR}
- ${INSTALL_DATA} -m 0644 ${FILESDIR}${PREFIX}/pkg/darkstat.xml \
+ ${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/darkstat.xml \
${STAGEDIR}${PREFIX}/pkg
+ ${INSTALL_DATA} ${FILESDIR}${PREFIX}/pkg/darkstat.inc \
+ ${STAGEDIR}${PREFIX}/pkg
+ ${INSTALL_DATA} ${FILESDIR}${PREFIX}/www/darkstat_redirect.php \
+ ${STAGEDIR}${PREFIX}/www
${INSTALL_DATA} ${FILESDIR}/etc/inc/priv/darkstat.priv.inc \
${STAGEDIR}/etc/inc/priv
${INSTALL_DATA} ${FILESDIR}${DATADIR}/info.xml \
diff --git a/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.inc b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.inc
new file mode 100644
index 000000000000..617eb22d0bb3
--- /dev/null
+++ b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.inc
@@ -0,0 +1,220 @@
+ 0) && ($hostsmax > $hostskeep)) {
+ $start .= " --hosts-max {$hostsmax}";
+ }
+ /* Maximum Hosts to Keep */
+ if (($hostskeep > 0) && ($hostskeep < $hostsmax)) {
+ $start .= " --hosts-keep {$hostskeep}";
+ }
+ /* Maximum Ports Count */
+ $portsmax = $darkstat_config['portsmax'];
+ $portskeep = $darkstat_config['portskeep'];
+ if (($portsmax > 0) && ($portsmax > $portskeep)) {
+ $start .= " --ports-max {$portsmax}";
+ }
+ /* Maximum Ports to Keep */
+ if (($portskeep > 0) && ($portskeep < $portsmax)) {
+ $start .= " --ports-keep {$portskeep}";
+ }
+ /* Advanced Filtering Options */
+ $advfilter = $darkstat_config['advfilter'];
+ if ($advfilter != "") {
+ $start .= " -f " . escapeshellarg(base64_decode($advfilter));
+ }
+
+ /* Create rc script */
+ write_rcfile(array(
+ "file" => "darkstat.sh",
+ "start" => $start,
+ "stop" => "/usr/bin/killall darkstat"
+ )
+ );
+
+ /* Do not (re)start service on boot */
+ if (platform_booting()) {
+ return;
+ } elseif (is_process_running("darkstat")) {
+ restart_service("darkstat");
+ } else {
+ start_service("darkstat");
+ }
+
+ conf_mount_ro();
+}
+
+function validate_input_darkstat($post, &$input_errors) {
+ global $config;
+ /* Validate Web Interface Port */
+ if ($post['port']) {
+ if (!is_port($post['port'])) {
+ $input_errors[] = gettext("The value for 'Web Interface Port' must be a valid port (1-65535).");
+ }
+ // Check webGUI port conflicts
+ $webgui_port = $config['system']['webgui']['port'];
+ if ($config['system']['webgui']['port'] == "") {
+ if ($config['system']['webgui']['protocol'] == "http") {
+ $webgui_port = 80;
+ } elseif ($config['system']['webgui']['protocol'] == "https") {
+ $webgui_port = 443;
+ }
+ }
+ if ($post['port'] == "{$webgui_port}") {
+ $input_errors[] = gettext("The value for 'Web Interface Port' must not be the same port where pfSense WebGUI is running ($webgui_port).");
+ }
+ }
+ /* Validate Maximum Hosts Count */
+ if ($post['hostsmax']) {
+ if ($post['hostsmax'] < 1 || !is_numericint($post['hostsmax'])) {
+ $input_errors[] = gettext("The value for 'Maximum Hosts Count' must be a positive integer.");
+ }
+ }
+ /* Validate Maximum Hosts to Keep */
+ if ($post['hostskeep']) {
+ if ($post['hostskeep'] < 1 || !is_numericint($post['hostskeep'])) {
+ $input_errors[] = gettext("The value for 'Maximum Hosts to Keep' must be a positive integer.");
+ }
+ }
+ /* Validate sanity for hosts limits */
+ if ($post['hostsmax'] || $post['hostskeep']) {
+ if ($post['hostsmax'] <= $post['hostskeep']) {
+ $input_errors[] = gettext("'Maximum Hosts Count' must be greater than 'Maximum Hosts to Keep'.");
+ }
+ }
+ /* Validate Maximum Ports Count */
+ if ($post['portsmax']) {
+ if ($post['portsmax'] < 1 || !is_numericint($post['portsmax'])) {
+ $input_errors[] = gettext("The value for 'Maximum Ports Count' must be a positive integer.");
+ }
+ }
+ /* Validate Maximum Ports to Keep */
+ if ($post['portskeep']) {
+ if ($post['portskeep'] < 1 || !is_numericint($post['portskeep'])) {
+ $input_errors[] = gettext("The value for 'Maximum Ports to Keep' to keep' must be a positive integer.");
+ }
+ }
+ /* Validate sanity for ports limits */
+ if ($post['portsmax'] || $post['portskeep']) {
+ if ($post['portsmax'] <= $post['portskeep']) {
+ $input_errors[] = gettext("'Maximum Ports to Keep' must be greater than 'Maximum Ports Count'.");
+ }
+ }
+ /* Validate Local Network Traffic */
+ if ($post['localnetworkenable'] && $post['nopromisc'] != "") {
+ $input_errors[] = gettext("'No Promiscuous Mode' cannot be used when the 'Local Network' feature is enabled.");
+ }
+ /* Local Network must be IPv4 - no IPv6 support in darkstat */
+ if ($post['localnetwork']) {
+ $int = convert_friendly_interface_to_real_interface_name($post['localnetwork']);
+ $ip = find_interface_ip($int);
+ if (!is_ipaddrv4($ip)) {
+ $input_errors[] = gettext("The selected 'local network' interface has no IPv4 configured. Configured IPv4 is required.");
+ }
+ }
+ /* Basic sanity validation for Advanced Filtering Options*/
+ if (($post['advfilter']) && !preg_match("/^[a-zA-Z0-9\+\-\=\(\):. ]*$/", $post['advfilter'])) {
+ $input_errors[] = gettext('Advanced traffic filtering options may only contain characters matching ^[a-zA-Z0-9\+\-\=\(\):. ]*$ regexp.');
+ }
+}
diff --git a/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.xml b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.xml
index ecff1d00fd98..376d69eb2b38 100644
--- a/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.xml
+++ b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/pkg/darkstat.xml
@@ -27,12 +27,19 @@