diff options
Diffstat (limited to 'controller/SqliteNetworkController.hpp')
-rw-r--r-- | controller/SqliteNetworkController.hpp | 44 |
1 files changed, 14 insertions, 30 deletions
diff --git a/controller/SqliteNetworkController.hpp b/controller/SqliteNetworkController.hpp index 0e2bb63e..11be9db4 100644 --- a/controller/SqliteNetworkController.hpp +++ b/controller/SqliteNetworkController.hpp @@ -44,8 +44,8 @@ // Number of in-memory last log entries to maintain per user #define ZT_SQLITENETWORKCONTROLLER_IN_MEMORY_LOG_SIZE 32 -// How long do circuit tests "live"? This is just to prevent buildup in memory. -#define ZT_SQLITENETWORKCONTROLLER_CIRCUIT_TEST_TIMEOUT 300000 +// How long do circuit tests last before they're forgotten? +#define ZT_SQLITENETWORKCONTROLLER_CIRCUIT_TEST_TIMEOUT 60000 namespace ZeroTier { @@ -123,37 +123,16 @@ private: std::string _circuitTestPath; std::string _instanceId; - // A circular buffer last log - struct _LLEntry + // Circuit tests outstanding + struct _CircuitTestEntry { - _LLEntry() - { - for(long i=0;i<ZT_SQLITENETWORKCONTROLLER_IN_MEMORY_LOG_SIZE;++i) - this->l[i].ts = 0; - this->lastRequestTime = 0; - this->totalRequests = 0; - } - - // Circular buffer of last log entries - struct { - uint64_t ts; // timestamp or 0 if circular buffer entry unused - char version[64]; - InetAddress fromAddr; - bool authorized; - } l[ZT_SQLITENETWORKCONTROLLER_IN_MEMORY_LOG_SIZE]; - - // Time of last request whether successful or not - uint64_t lastRequestTime; - - // Total requests by this address / network ID pair (also serves mod IN_MEMORY_LOG_SIZE as circular buffer ptr) - uint64_t totalRequests; + ZT_CircuitTest *test; + std::string jsonResults; }; + std::map< uint64_t,_CircuitTestEntry > _circuitTests; - // Last log entries by address and network ID pair - std::map< std::pair<Address,uint64_t>,_LLEntry > _lastLog; - - // Circuit tests outstanding - std::map< uint64_t,ZT_CircuitTest * > _circuitTests; + // Last request time by address, for rate limitation + std::map< std::pair<uint64_t,uint64_t>,uint64_t > _lastRequestTime; sqlite3 *_db; @@ -162,6 +141,11 @@ private: sqlite3_stmt *_sCreateMember; sqlite3_stmt *_sGetNodeIdentity; sqlite3_stmt *_sCreateOrReplaceNode; + sqlite3_stmt *_sGetMaxNodeHistoryNetworkVisitCounter; + sqlite3_stmt *_sAddNodeHistoryEntry; + sqlite3_stmt *_sDeleteOldNodeHistoryEntries; + sqlite3_stmt *_sGetActiveNodesOnNetwork; + sqlite3_stmt *_sGetNodeHistory; sqlite3_stmt *_sGetEtherTypesFromRuleTable; sqlite3_stmt *_sGetActiveBridges; sqlite3_stmt *_sGetIpAssignmentsForNode; |