summaryrefslogtreecommitdiff
path: root/controller/SqliteNetworkController.hpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-09-26 13:47:55 -0700
committerGrant Limberg <glimberg@gmail.com>2015-09-26 13:47:55 -0700
commite8cdff3eafd8096da22122eabddf57a09fe2bb90 (patch)
treed231aa6d9ccccc8ced6e1ead606ce16ff551cab9 /controller/SqliteNetworkController.hpp
parent53d98343b7b444508259f6f1643e8d6724fb11e9 (diff)
parentf69454ec9879a0b0a424f743ca144d1123ef7e99 (diff)
downloadinfinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.tar.gz
infinitytier-e8cdff3eafd8096da22122eabddf57a09fe2bb90.zip
Merge branch 'adamierymenko-dev' into android-jni-dev
also update for changed function calls that now accept a local address # Conflicts: # include/ZeroTierOne.h # java/CMakeLists.txt # java/jni/Android.mk # java/jni/ZT1_jnicache.cpp # java/jni/ZT1_jnilookup.h # java/jni/ZT1_jniutils.cpp # java/jni/com_zerotierone_sdk_Node.cpp
Diffstat (limited to 'controller/SqliteNetworkController.hpp')
-rw-r--r--controller/SqliteNetworkController.hpp46
1 files changed, 40 insertions, 6 deletions
diff --git a/controller/SqliteNetworkController.hpp b/controller/SqliteNetworkController.hpp
index adfe0991..f0b61c40 100644
--- a/controller/SqliteNetworkController.hpp
+++ b/controller/SqliteNetworkController.hpp
@@ -40,6 +40,9 @@
#include "../node/NetworkController.hpp"
#include "../node/Mutex.hpp"
+// Number of in-memory last log entries to maintain per user
+#define ZT_SQLITENETWORKCONTROLLER_IN_MEMORY_LOG_SIZE 32
+
namespace ZeroTier {
class SqliteNetworkController : public NetworkController
@@ -54,7 +57,6 @@ public:
const Identity &identity,
uint64_t nwid,
const Dictionary &metaData,
- uint64_t haveRevision,
Dictionary &netconf);
unsigned int handleControlPlaneHttpGET(
@@ -94,11 +96,45 @@ private:
const std::string &body,
std::string &responseBody,
std::string &responseContentType);
+ NetworkController::ResultCode _doNetworkConfigRequest(
+ const InetAddress &fromAddr,
+ const Identity &signingId,
+ const Identity &identity,
+ uint64_t nwid,
+ const Dictionary &metaData,
+ Dictionary &netconf);
std::string _dbPath;
std::string _instanceId;
- std::map< std::pair<Address,uint64_t>,uint64_t > _lastRequestTime;
+ // A circular buffer last log
+ struct _LLEntry
+ {
+ _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;
+ };
+
+ // Last log entries by address and network ID pair
+ std::map< std::pair<Address,uint64_t>,_LLEntry > _lastLog;
sqlite3 *_db;
@@ -106,7 +142,7 @@ private:
sqlite3_stmt *_sGetMember;
sqlite3_stmt *_sCreateMember;
sqlite3_stmt *_sGetNodeIdentity;
- sqlite3_stmt *_sCreateNode;
+ sqlite3_stmt *_sCreateOrReplaceNode;
sqlite3_stmt *_sUpdateNode;
sqlite3_stmt *_sUpdateNode2;
sqlite3_stmt *_sGetEtherTypesFromRuleTable;
@@ -137,6 +173,7 @@ private:
sqlite3_stmt *_sUpdateMemberAuthorized;
sqlite3_stmt *_sUpdateMemberActiveBridge;
sqlite3_stmt *_sDeleteMember;
+ sqlite3_stmt *_sDeleteAllNetworkMembers;
sqlite3_stmt *_sDeleteNetwork;
sqlite3_stmt *_sGetGateways;
sqlite3_stmt *_sDeleteGateways;
@@ -144,9 +181,6 @@ private:
sqlite3_stmt *_sIncrementMemberRevisionCounter;
sqlite3_stmt *_sGetConfig;
sqlite3_stmt *_sSetConfig;
- sqlite3_stmt *_sPutLog;
- sqlite3_stmt *_sGetMemberLog;
- sqlite3_stmt *_sGetRecentMemberLog;
Mutex _lock;
};