X-Git-Url: https://git.stg.codes/stg.git/blobdiff_plain/ed144772874a7495b39abdf3bd9dbb0fe1c22fe8..8c6fa3fbaccc22127280bf77a48fab5a3ee0716e:/projects/stargazer/traffcounter_impl.h?ds=inline diff --git a/projects/stargazer/traffcounter_impl.h b/projects/stargazer/traffcounter_impl.h index 7afada49..86d8c389 100644 --- a/projects/stargazer/traffcounter_impl.h +++ b/projects/stargazer/traffcounter_impl.h @@ -28,13 +28,6 @@ #ifndef TRAFFCOUNTER_IMPL_H #define TRAFFCOUNTER_IMPL_H -#include - -#include -#include -#include -#include - #include "stg/traffcounter.h" #include "stg/os_int.h" #include "stg/logger.h" @@ -45,6 +38,13 @@ #include "eventloop.h" #include "user_impl.h" +#include +#include +#include +#include + +#include + #define PROTOMAX (5) class USERS_IMPL; @@ -73,19 +73,6 @@ PACKET_EXTRA_DATA() lenD(0) {} -PACKET_EXTRA_DATA(const PACKET_EXTRA_DATA & pp) - : flushTime(pp.flushTime), - updateTime(pp.updateTime), - userU(pp.userU), - userUPresent(pp.userUPresent), - userD(pp.userD), - userDPresent(pp.userDPresent), - dirU(pp.dirU), - dirD(pp.dirD), - lenU(pp.lenU), - lenD(pp.lenD) -{} - time_t flushTime; // Last flush time time_t updateTime; // Last update time USER_IMPL * userU; // Uploader @@ -147,7 +134,7 @@ private: //----------------------------------------------------------------------------- class ADD_USER_NONIFIER: public NOTIFIER_BASE { public: - ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : + explicit ADD_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : NOTIFIER_BASE(), traffCnt(t) {} @@ -163,7 +150,7 @@ private: //----------------------------------------------------------------------------- class DEL_USER_NONIFIER: public NOTIFIER_BASE { public: - DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : + explicit DEL_USER_NONIFIER(TRAFFCOUNTER_IMPL & t) : NOTIFIER_BASE(), traffCnt(t) {} @@ -186,8 +173,6 @@ public: TRAFFCOUNTER_IMPL(USERS_IMPL * users, const std::string & rulesFileName); ~TRAFFCOUNTER_IMPL(); - void SetRulesFile(const std::string & rulesFileName); - int Reload(); int Start(); int Stop(); @@ -198,10 +183,12 @@ public: size_t RulesCount() const { return rules.size(); } private: + TRAFFCOUNTER_IMPL(const TRAFFCOUNTER_IMPL &); + TRAFFCOUNTER_IMPL & operator=(const TRAFFCOUNTER_IMPL &); + bool ParseAddress(const char * ta, RULE * rule) const; uint32_t CalcMask(uint32_t msk) const; void FreeRules(); - void PrintRule(RULE rule) const; bool ReadRules(bool test = false); static void * Run(void * data); @@ -218,15 +205,18 @@ private: void UnSetUserNotifiers(USER_IMPL * user); typedef std::list::iterator rule_iter; - typedef std::map::iterator pp_iter; - typedef std::multimap::iterator ip2p_iter; - typedef std::multimap::const_iterator ip2p_citer; std::list rules; - std::map packets; // Packets tree + typedef std::map Packets; + typedef Packets::iterator pp_iter; + typedef std::multimap Index; + typedef Index::iterator ip2p_iter; + typedef Index::const_iterator ip2p_citer; + + Packets packets; // Packets tree - std::multimap ip2packets; // IP-to-Packet index + Index ip2packets; // IP-to-Packet index std::string dirName[DIR_NUM + 1]; @@ -235,6 +225,7 @@ private: std::string monitorDir; bool monitoring; + time_t touchTimeP; USERS_IMPL * users;