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 @@ Darkstat Diagnostics: Darkstat + /usr/local/pkg/darkstat.inc - Darkstat Settings + darkstat Settings Setup darkstat specific settings.
Diagnostics
/pkg_edit.php?xml=darkstat.xml
+ + darkstat + Access darkstat +
Diagnostics
+ /darkstat_redirect.php +
darkstat darkstat.sh @@ -41,13 +48,13 @@ - Darkstat Settings + darkstat Settings /pkg_edit.php?xml=darkstat.xml - Access Darkstat - http://$myurl:666 + Access darkstat + /darkstat_redirect.php enabled @@ -56,6 +63,7 @@ Enable darkstat enable checkbox + Check to enable darkstat. Capture Interfaces @@ -85,22 +93,20 @@ 3 true - - Local Network Traffic localnetworkenable @@ -234,153 +240,6 @@ - - 0) && ($hostsmax > $hostskeep)) { - $start .= " --hosts-max {$hostsmax}"; - } - if (($hostskeep > 0) && ($hostskeep < $hostsmax)) { - $start .= " --hosts-keep {$hostskeep}"; - } - $portsmax = $darkstat_config['portsmax']; - $portskeep = $darkstat_config['portskeep']; - if (($portsmax > 0) && ($portsmax > $portskeep)) { - $start .= " --ports-max {$portsmax}"; - } - if (($portskeep > 0) && ($portskeep < $portsmax)) { - $start .= " --ports-keep {$portskeep}"; - } - $advfilter = $darkstat_config['advfilter']; - if ($advfilter != "") { - $start .= " -f " . escapeshellarg(base64_decode($advfilter)); - } - - 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) { - if (($_POST['port']) && ($_POST['port'] < 1 || $_POST['port'] < 65535 || !is_numericint($_POST['port']))) { - $input_errors[] = gettext("The value for 'Maximum number of ports' to keep' must be a positive integer between 1 and 65535."); - } - if (($_POST['hostsmax']) && ($_POST['hostsmax'] < 1 || !is_numericint($_POST['hostsmax']))) { - $input_errors[] = gettext("The value for 'Maximum hosts count' must be a positive integer."); - } - if (($_POST['hostskeep']) && ($_POST['hostskeep'] < 1 || !is_numericint($_POST['hostskeep']))) { - $input_errors[] = gettext("The value for 'Maximum number of hosts to keep' must be a positive integer."); - } - if ($_POST['hostsmax'] || $_POST['hostskeep']) { - if ($_POST['hostsmax'] <= $_POST['hostskeep']) { - $input_errors[] = gettext("'Maximum hosts count' must be greater than 'Maximum number of hosts to keep'."); - } - } - if (($_POST['portsmax']) && ($_POST['portsmax'] < 1 || !is_numericint($_POST['portsmax']))) { - $input_errors[] = gettext("The value for 'Maximum ports count' must be a positive integer."); - } - if (($_POST['portskeep']) && ($_POST['portskeep'] < 1 || !is_numericint($_POST['portskeep']))) { - $input_errors[] = gettext("The value for 'Maximum number of ports' to keep' must be a positive integer."); - } - if ($_POST['portsmax'] || $_POST['portskeep']) { - if ($_POST['portsmax'] <= $_POST['portskeep']) { - $input_errors[] = gettext("'Maximum ports count' must be greater than 'Maximum number of ports to keep'."); - } - } - if ($_POST['localnetworkenable'] && $_POST['nopromisc'] != "") { - $input_errors[] = gettext("'Do not use promiscuous mode to capture' cannot be used when the 'local network' feature is enabled."); - } - 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."); - } - } - 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.'); - } - } - ]]> - sync_package_darkstat(); diff --git a/net-mgmt/pfSense-pkg-darkstat/files/usr/local/www/darkstat_redirect.php b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/www/darkstat_redirect.php new file mode 100644 index 000000000000..d5f223275f84 --- /dev/null +++ b/net-mgmt/pfSense-pkg-darkstat/files/usr/local/www/darkstat_redirect.php @@ -0,0 +1,47 @@ + diff --git a/net-mgmt/pfSense-pkg-darkstat/pkg-plist b/net-mgmt/pfSense-pkg-darkstat/pkg-plist index acd30c17072b..90673f11df9c 100644 --- a/net-mgmt/pfSense-pkg-darkstat/pkg-plist +++ b/net-mgmt/pfSense-pkg-darkstat/pkg-plist @@ -1,4 +1,6 @@ pkg/darkstat.xml +pkg/darkstat.inc +www/darkstat_redirect.php /etc/inc/priv/darkstat.priv.inc %%DATADIR%%/info.xml @dir /etc/inc/priv