$pd) { if (preg_match("/ldel_(\d+)/", $pn, $matches)) { $delbtn_list = $matches[1]; } } if (is_numeric($delbtn_list) && $a_nat[$delbtn_list]) { $if_real = get_real_interface($a_nat[$delbtn_list]['interface']); $if_friendly = convert_friendly_interface_to_friendly_descr($a_nat[$delbtn_list]['interface']); $suricata_uuid = $a_nat[$delbtn_list]['uuid']; // Check that we still have the real interface defined in pfSense. // The real interface will return as an empty string if it has // been removed in pfSense. if ($if_real == "") { rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}"); rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_*"); logger(LOG_NOTICE, localize_text("Deleted the Suricata instance on a previously removed pfSense interface per user request..."), LOG_PREFIX_PKG_SURICATA); } else { // Delete the interface sub-directories and then the instance itself $if_friendly = convert_friendly_interface_to_friendly_descr($snortcfg['interface']); logger(LOG_NOTICE, localize_text("Stopping Suricata on %s(%s) due to Suricata instance deletion...", $if_friendly, $if_real), LOG_PREFIX_PKG_SURICATA); suricata_stop($a_nat[$delbtn_list], $if_real); rmdir_recursive("{$suricatalogdir}suricata_{$if_real}{$suricata_uuid}"); rmdir_recursive("{$suricatadir}suricata_{$suricata_uuid}_{$if_real}"); logger(LOG_NOTICE, localize_text("Deleted Suricata instance on %s(%s) per user request...", $if_friendly, $if_real), LOG_PREFIX_PKG_SURICATA); } // Finally, delete the interface's config entry entirely unset($a_nat[$delbtn_list]); // Save updated configuration config_set_path('installedpackages/suricata/rule', $a_nat); write_config("Suricata pkg: deleted one or more Suricata interfaces."); sleep(2); sync_suricata_package_config(); header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-store, no-cache, must-revalidate' ); header( 'Cache-Control: post-check=0, pre-check=0', false ); header( 'Pragma: no-cache' ); header("Location: /suricata/suricata_interfaces.php"); exit; } } /* start/stop Suricata */ if ($_POST['toggle']) { // Ensure the interface index is legit, else bail and redisplay this page if (!is_numeric($_POST['id']) || intval($_POST['id']) >= $id_gen) { header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); header( 'Last-Modified: ' . gmdate( 'D, d M Y H:i:s' ) . ' GMT' ); header( 'Cache-Control: no-store, no-cache, must-revalidate' ); header( 'Cache-Control: post-check=0, pre-check=0', false ); header( 'Pragma: no-cache' ); header("Location: /suricata/suricata_interfaces.php"); exit; } $suricatacfg = config_get_path("installedpackages/suricata/rule/{$_POST['id']}"); $if_real = get_real_interface($suricatacfg['interface']); $if_friendly = convert_friendly_interface_to_friendly_descr($suricatacfg['interface']); $id = $_POST['id']; // Suricata can take several seconds to startup, so to // make the GUI more responsive, startup commands are // executed as a background process. The commands // are written to a PHP file in the 'tmp_path' which // is executed by a PHP command line session launched // as a background task. // Create steps for the background task to start Suricata. // These commands will be handed off to a CLI PHP session // for background execution as a self-deleting PHP file. $start_lck_file = "{$g['varrun_path']}/suricata_{$if_real}{$suricatacfg['uuid']}_starting.lck"; $suricata_start_cmd = << EOD; switch ($_POST['toggle']) { case 'start': file_put_contents("{$g['tmp_path']}/suricata_{$if_real}{$suricatacfg['uuid']}_startcmd.php", $suricata_start_cmd); if (suricata_is_running($suricatacfg['uuid'], $if_real)) { logger(LOG_NOTICE, localize_text("Restarting Suricata on %s(%s) per user request...", $if_friendly, $if_real), LOG_PREFIX_PKG_SURICATA); suricata_stop($suricatacfg, $if_real); mwexec_bg("/usr/local/bin/php -f {$g['tmp_path']}/suricata_{$if_real}{$suricatacfg['uuid']}_startcmd.php"); } else { // Forcefully remove the PID file if it exists but a Suricata instance with that PID is not running. // This allows the user the start Suricata in the event of a failed previous start due to a config error. if (!suricata_is_running($suricatacfg['uuid'], $if_real)) { unlink_if_exists("{$g['varrun_path']}/suricata_{$if_real}{$suricatacfg['uuid']}.pid"); } logger(LOG_NOTICE, localize_text("Starting Suricata on %s(%s) per user request...", $if_friendly, $if_real), LOG_PREFIX_PKG_SURICATA); mwexec_bg("/usr/local/bin/php -f {$g['tmp_path']}/suricata_{$if_real}{$suricatacfg['uuid']}_startcmd.php"); } $suri_starting[$id] = TRUE; break; case 'stop': if (suricata_is_running($suricatacfg['uuid'], $if_real)) { logger(LOG_NOTICE, localize_text("Stopping Suricata on %s(%s) per user request...", $if_friendly, $if_real), LOG_PREFIX_PKG_SURICATA); suricata_stop($suricatacfg, $if_real); } unset($suri_starting[$id]); unlink_if_exists($start_lck_file); break; default: unset($suri_starting[$id]); unlink_if_exists('{$start_lck_file}'); } unset($suricata_start_cmd); } /* Ajax call to periodically check Suricata status */ /* on each configured interface. */ if ($_POST['status'] == 'check') { $list = array(); // Iterate configured Suricata interfaces and get status of each // into an associative array. Return the array to the Ajax // caller as a JSON object. foreach ($a_nat as $intf) { // Skip status update for any missing real interface if (($if_real = get_real_interface($intf['interface'])) == "") { continue; } $intf_key = "suricata_" . get_real_interface($intf['interface']) . $intf['uuid']; if ($intf['enable'] == "on") { if (suricata_is_running($intf['uuid'], get_real_interface($intf['interface']))) { $list[$intf_key] = "RUNNING"; } elseif (file_exists("{$g['varrun_path']}/{$intf_key}_starting.lck") || file_exists("{$g['varrun_path']}/suricata_pkg_starting.lck")) { $list[$intf_key] = "STARTING"; $suri_starting[$id] = TRUE; } else { $list[$intf_key] = "STOPPED"; } } else { $list[$intf_key] = "DISABLED"; } } // Return a JSON encoded array as the page output echo json_encode($list); exit; } // May decide to use these again for display, but for now they are not used $suri_bin_ver = SURICATA_BIN_VERSION; $suri_pkg_ver = SURICATA_PKG_VER; $pglinks = array("", "@self"); $pgtitle = array("Services", "Suricata"); include_once("head.inc"); ?>

 
' . $natend_friendly . ''; } else { echo $natend_friendly; } ?>        

This is where you can see an overview of all your interface settings. Please configure the parameters on the Global Settings tab before adding an interface.

Warning: New settings will not take effect until interface restart

Click on the icon to edit an interface and settings.
Click on the icon to delete an interface and settings.
Click on the icon to clone an existing interface.

icons will show current Suricata status
Click the or or icons to start/restart/stop Suricata.

', 'info')?>