1
0
Fork 0
mirror of https://github.com/pavel-odintsov/fastnetmon synced 2024-05-10 08:36:22 +02:00

Compare commits

...

5 Commits

4 changed files with 14 additions and 12 deletions

View File

@ -190,6 +190,7 @@ set(FASTNETMON_ATTACK_DETAILS_FOLDER "/var/log/fastnetmon_attacks")
set(FASTNETMON_NOTIFY_SCRIPT_PATH_DEFAULT "/usr/local/bin/notify_about_attack.sh")
set(FASTNETMON_NETWORK_WHITELIST_PATH "/etc/networks_whitelist")
set(FASTNETMON_NETWORKS_LIST_PATH "/etc/networks_list")
set(FASTNETMON_BACKTRACE_PATH "/var/log/fastnetmon_backtrace.dump")
# For FreeBSD based platforms we need to adjust them
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
@ -202,6 +203,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Dr
set(FASTNETMON_NOTIFY_SCRIPT_PATH_DEFAULT "${FREEBSD_DEFAULT_PREFIX}/bin/notify_about_attack.sh")
set(FASTNETMON_NETWORK_WHITELIST_PATH "${FREEBSD_DEFAULT_PREFIX}/etc/networks_whitelist")
set(FASTNETMON_NETWORKS_LIST_PATH "${FREEBSD_DEFAULT_PREFIX}/etc/networks_list")
set(FASTNETMON_BACKTRACE_PATH "/var/log/fastnetmon/fastnetmon_backtrace.dump")
endif()
configure_file(fast_platform.h.template "${PROJECT_SOURCE_DIR}/fast_platform.hpp")

View File

@ -1,11 +1,10 @@
#pragma once
// This file automatically generated for your platform (Linux, FreeBSD and others) with cmake
// This file is automatically generated for your platform with cmake, please do not edit it manually
class FastnetmonPlatformConfigurtion {
public:
/* Platform specific paths */
std::string fastnetmon_version = "${FASTNETMON_APPLICATION_VERSION}";
std::string pid_path = "${FASTNETMON_PID_PATH}";
@ -23,5 +22,6 @@ class FastnetmonPlatformConfigurtion {
// Default path to file with all networks listing
std::string networks_list_path = "${FASTNETMON_NETWORKS_LIST_PATH}";
/* Platform specific paths end */
// Path to temporarily store backtrace when fatal failure happened
std::string backtrace_path = "${FASTNETMON_BACKTRACE_PATH}";
};

View File

@ -157,9 +157,6 @@ unsigned int stats_thread_initial_call_delay = 30;
std::string reporting_server = "community-stats.fastnetmon.com";
// Path to temporarily store backtrace when fatal failure happened
std::string backtrace_path = "/var/log/fastnetmon_backtrace.dump";
// Each this seconds we will check about available data in bucket
unsigned int check_for_availible_for_processing_packets_buckets = 1;
@ -239,6 +236,8 @@ bool monitor_openvz_vps_ip_addresses = false;
// We will announce whole subnet instead single IP with BGP if this flag enabled
bool exabgp_announce_whole_subnet = false;
std::string exabgp_command_pipe = "";
// We will announce only /32 host
bool exabgp_announce_host = false;
@ -423,7 +422,6 @@ std::string exabgp_community_subnet = "";
std::string exabgp_community_host = "";
std::string exabgp_command_pipe = "/var/run/exabgp.cmd";
std::string exabgp_next_hop = "";
// Graphite monitoring
@ -1519,7 +1517,7 @@ void redirect_fds() {
// Handles fatal failure of FastNetMon's daemon
void fatal_signal_handler(int signum) {
::signal(signum, SIG_DFL);
boost::stacktrace::safe_dump_to(backtrace_path.c_str());
boost::stacktrace::safe_dump_to(fastnetmon_platform_configuration.backtrace_path.c_str());
::raise(SIGABRT);
}
@ -1650,9 +1648,9 @@ int main(int argc, char** argv) {
init_logging(log_to_console);
if (std::filesystem::exists(backtrace_path)) {
if (std::filesystem::exists(fastnetmon_platform_configuration.backtrace_path)) {
// there is a backtrace
std::ifstream ifs(backtrace_path);
std::ifstream ifs(fastnetmon_platform_configuration.backtrace_path);
boost::stacktrace::stacktrace st = boost::stacktrace::stacktrace::from_dump(ifs);
logger << log4cpp::Priority::ERROR << "Previous run crashed, you can find stack trace below";
@ -1660,7 +1658,7 @@ int main(int argc, char** argv) {
// cleaning up
ifs.close();
std::filesystem::remove(backtrace_path);
std::filesystem::remove(fastnetmon_platform_configuration.backtrace_path);
}
#ifdef FASTNETMON_API

View File

@ -322,7 +322,9 @@ std::string print_ban_thresholds(ban_settings_t current_ban_settings) {
void print_attack_details_to_file(const std::string& details, const std::string& client_ip_as_string, const attack_details_t& current_attack) {
std::ofstream my_attack_details_file;
// TODO: it may not work well with systems which do not allow ":" as part of file name (macOS)
std::string ban_timestamp_as_string = print_time_t_in_fastnetmon_format(current_attack.ban_timestamp);
std::string attack_dump_path =
fastnetmon_platform_configuration.attack_details_folder + "/" + client_ip_as_string + "_" + ban_timestamp_as_string + ".txt";
@ -1220,7 +1222,7 @@ void call_blackhole_actions_per_host(attack_action_t attack_action,
std::string full_attack_description = basic_attack_information + "\n\nAttack traffic dump\n\n" + simple_packets_dump + "\n\nFlow dump\n\n" + flow_attack_details;
if (store_attack_details_to_file && ipv4) {
if (store_attack_details_to_file) {
print_attack_details_to_file(full_attack_description, client_ip_as_string, current_attack);
}
}