mirror of
https://github.com/pavel-odintsov/fastnetmon
synced 2024-05-10 12:46:08 +02:00
Compare commits
6 Commits
f309dbdff1
...
52ce2486c1
Author | SHA1 | Date | |
---|---|---|---|
Michael Cho | 52ce2486c1 | ||
Pavel Odintsov | a74f7a90a9 | ||
Pavel Odintsov | 5321a50558 | ||
Pavel Odintsov | 3932570572 | ||
Pavel Odintsov | 1da33bb50e | ||
Michael Cho | fad8757b89 |
|
@ -181,6 +181,29 @@ execute_process(COMMAND git rev-list HEAD COMMAND head -n 1 COMMAND cut -c1-8 OU
|
|||
message(STATUS "Commit hash: ${GIT_LAST_COMMIT_HASH_SHORT}")
|
||||
|
||||
set(FASTNETMON_APPLICATION_VERSION "${FASTNETMON_VERSION_MAJOR}.${FASTNETMON_VERSION_MINOR}.${FASTNETMON_VERSION_PATCH} ${GIT_LAST_COMMIT_HASH_SHORT}")
|
||||
|
||||
# Set standard values which work for majority of platforms
|
||||
set(FASTNETMON_PID_PATH "/var/run/fastnetmon.pid")
|
||||
set(FASTNETMON_CONFIGURATION_PATH "/etc/fastnetmon.conf")
|
||||
set(FASTNETMON_LOG_FILE_PATH "/var/log/fastnetmon.log")
|
||||
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")
|
||||
|
||||
# For FreeBSD based platforms we need to adjust them
|
||||
if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "DragonFly")
|
||||
set(FREEBSD_DEFAULT_PREFIX "/usr/local")
|
||||
|
||||
set(FASTNETMON_PID_PATH "/var/run/fastnetmon/fastnetmon.pid")
|
||||
set(FASTNETMON_CONFIGURATION_PATH "${FREEBSD_DEFAULT_PREFIX}/etc/fastnetmon.conf")
|
||||
set(FASTNETMON_LOG_FILE_PATH "/var/log/fastnetmon/fastnetmon.log")
|
||||
set(FASTNETMON_ATTACK_DETAILS_FOLDER "/var/log/fastnetmon_attacks")
|
||||
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")
|
||||
endif()
|
||||
|
||||
configure_file(fast_platform.h.template "${PROJECT_SOURCE_DIR}/fast_platform.hpp")
|
||||
|
||||
# Use new Memory Model Aware Atomic Operations
|
||||
|
@ -594,26 +617,26 @@ if (ENABLE_GOBGP_SUPPORT)
|
|||
target_link_libraries(gobgp_action absl::base absl::synchronization)
|
||||
endif()
|
||||
|
||||
# By default use module supplied by cmake to search for Protobuf
|
||||
set(FIND_PACKAGE_MODE_PROTOBUF "MODULE")
|
||||
|
||||
if (DO_NOT_USE_SYSTEM_LIBRARIES_FOR_BUILD)
|
||||
# We add our custom path to Protobuf to top of search_list used by find_package: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html
|
||||
# This approach has advantage over Protobuf_DIR which requires us to set direct path to cmake folder of custom built dependency
|
||||
# which resides in vendor specific folder with name lib which may be lib64 on CentOS platforms:
|
||||
# protobuf_21_12/lib/cmake/protobuf or protobuf_21_12/lib64/cmake/protobuf on CentOS
|
||||
list(APPEND CMAKE_PREFIX_PATH ${PROTOCOL_BUFFERS_CUSTOM_INSTALL_PATH})
|
||||
|
||||
# Switch to use to configuration supplied by custom Protobuf installation as it may be better
|
||||
set(FIND_PACKAGE_MODE_PROTOBUF "CONFIG")
|
||||
|
||||
# Apparently it's required to set this flag because without this flag set it cannot find protoc when custom library path is in use
|
||||
# https://github.com/protocolbuffers/protobuf/issues/1931
|
||||
set(protobuf_MODULE_COMPATIBLE true)
|
||||
endif()
|
||||
|
||||
# https://cmake.org/cmake/help/latest/module/FindProtobuf.html
|
||||
find_package(Protobuf ${FIND_PACKAGE_MODE_PROTOBUF} REQUIRED)
|
||||
# Apparently it's required to set this flag because without this flag set it cannot find protoc when custom library path is in use
|
||||
# https://github.com/protocolbuffers/protobuf/issues/1931
|
||||
set(protobuf_MODULE_COMPATIBLE true)
|
||||
|
||||
# Switch to use to configuration supplied by custom Protobuf installation as it may be better
|
||||
find_package(Protobuf CONFIG)
|
||||
|
||||
if (NOT Protobuf_FOUND)
|
||||
# Fall back to module supplied by cmake to search for Protobuf
|
||||
# https://cmake.org/cmake/help/latest/module/FindProtobuf.html
|
||||
find_package(Protobuf MODULE REQUIRED)
|
||||
endif()
|
||||
|
||||
if (Protobuf_FOUND)
|
||||
message(STATUS "Found Protobuf ${Protobuf_VERSION}")
|
||||
|
|
|
@ -421,8 +421,6 @@ void start_af_packet_capture_for_interface(std::string capture_interface, int fa
|
|||
logger << log4cpp::Priority::INFO << "Start AF_PACKET worker process for " << capture_interface
|
||||
<< " with fanout group id " << fanout_group_id << " on CPU " << cpu;
|
||||
|
||||
// Well, we have thread attributes from Boost 1.50
|
||||
#if defined(BOOST_THREAD_PLATFORM_PTHREAD) && BOOST_VERSION / 100 % 1000 >= 50 && defined(__GLIBC__)
|
||||
boost::thread::attributes thread_attrs;
|
||||
|
||||
if (afpacket_execute_strict_cpu_affinity) {
|
||||
|
@ -445,14 +443,6 @@ void start_af_packet_capture_for_interface(std::string capture_interface, int fa
|
|||
|
||||
packet_receiver_thread_group.add_thread(
|
||||
new boost::thread(thread_attrs, boost::bind(start_af_packet_capture, capture_interface, fanout, fanout_group_id)));
|
||||
#else
|
||||
bool fanout = true;
|
||||
|
||||
logger.error("Sorry but CPU affinity did not supported for your platform");
|
||||
|
||||
packet_receiver_thread_group.add_thread(
|
||||
new boost::thread(start_af_packet_capture, capture_interface, fanout, fanout_group_id));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Wait all processes for finish
|
||||
|
|
|
@ -8,20 +8,20 @@ class FastnetmonPlatformConfigurtion {
|
|||
/* Platform specific paths */
|
||||
std::string fastnetmon_version = "${FASTNETMON_APPLICATION_VERSION}";
|
||||
|
||||
std::string pid_path = "/var/run/fastnetmon.pid";
|
||||
std::string global_config_path = "/etc/fastnetmon.conf";
|
||||
std::string pid_path = "${FASTNETMON_PID_PATH}";
|
||||
std::string global_config_path = "${FASTNETMON_CONFIGURATION_PATH}";
|
||||
|
||||
std::string log_file_path = "/var/log/fastnetmon.log";
|
||||
std::string attack_details_folder = "/var/log/fastnetmon_attacks";
|
||||
std::string log_file_path = "${FASTNETMON_LOG_FILE_PATH}";
|
||||
std::string attack_details_folder = "${FASTNETMON_ATTACK_DETAILS_FOLDER}";
|
||||
|
||||
// Default path to notify script
|
||||
std::string notify_script_path = "/usr/local/bin/notify_about_attack.sh";
|
||||
std::string notify_script_path = "${FASTNETMON_NOTIFY_SCRIPT_PATH_DEFAULT}";
|
||||
|
||||
// Default path to file with networks for whitelising
|
||||
std::string white_list_path = "/etc/networks_whitelist";
|
||||
std::string white_list_path = "${FASTNETMON_NETWORK_WHITELIST_PATH}";
|
||||
|
||||
// Default path to file with all networks listing
|
||||
std::string networks_list_path = "/etc/networks_list";
|
||||
std::string networks_list_path = "${FASTNETMON_NETWORKS_LIST_PATH}";
|
||||
|
||||
/* Platform specific paths end */
|
||||
};
|
||||
|
|
|
@ -206,9 +206,7 @@ void receiver(std::string interface_for_listening) {
|
|||
|
||||
logger.info("Start new netmap thread %d", i);
|
||||
|
||||
// Well, we have thread attributes from Boost 1.50
|
||||
|
||||
#if defined(BOOST_THREAD_PLATFORM_PTHREAD) && BOOST_VERSION / 100 % 1000 >= 50 && !defined(__APPLE__) && defined(__GLIBC__)
|
||||
#if defined(BOOST_THREAD_PLATFORM_PTHREAD) && !defined(__APPLE__)
|
||||
/* Bind to certain core */
|
||||
boost::thread::attributes thread_attrs;
|
||||
|
||||
|
|
Loading…
Reference in New Issue