summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-06 15:56:18 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2015-10-06 15:56:18 -0700
commit7394ec6f6ab38c48e84edf3bf2fdb46e6966fa35 (patch)
treefe93e7aab1ccfffaa9299452b2b395b4e1723367
parent3593fb3462f277cca9241563ac0b97ade1582c91 (diff)
downloadinfinitytier-7394ec6f6ab38c48e84edf3bf2fdb46e6966fa35.tar.gz
infinitytier-7394ec6f6ab38c48e84edf3bf2fdb46e6966fa35.zip
Prep in controller code to run tests.
-rw-r--r--controller/SqliteNetworkController.cpp7
-rw-r--r--controller/SqliteNetworkController.hpp6
-rw-r--r--service/OneService.cpp12
3 files changed, 19 insertions, 6 deletions
diff --git a/controller/SqliteNetworkController.cpp b/controller/SqliteNetworkController.cpp
index 3aa84330..334ccc75 100644
--- a/controller/SqliteNetworkController.cpp
+++ b/controller/SqliteNetworkController.cpp
@@ -44,12 +44,15 @@
#include "../ext/json-parser/json.h"
#include "SqliteNetworkController.hpp"
+
+#include "../node/Node.hpp"
#include "../node/Utils.hpp"
#include "../node/CertificateOfMembership.hpp"
#include "../node/NetworkConfig.hpp"
#include "../node/InetAddress.hpp"
#include "../node/MAC.hpp"
#include "../node/Address.hpp"
+
#include "../osdep/OSUtils.hpp"
// Include ZT_NETCONF_SCHEMA_SQL constant to init database
@@ -117,8 +120,10 @@ struct NetworkRecord {
} // anonymous namespace
-SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
+SqliteNetworkController::SqliteNetworkController(Node *node,const char *dbPath,const char *circuitTestPath) :
+ _node(node),
_dbPath(dbPath),
+ _circuitTestPath(circuitTestPath),
_db((sqlite3 *)0)
{
if (sqlite3_open_v2(dbPath,&_db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,(const char *)0) != SQLITE_OK)
diff --git a/controller/SqliteNetworkController.hpp b/controller/SqliteNetworkController.hpp
index f0b61c40..68529e39 100644
--- a/controller/SqliteNetworkController.hpp
+++ b/controller/SqliteNetworkController.hpp
@@ -45,10 +45,12 @@
namespace ZeroTier {
+class Node;
+
class SqliteNetworkController : public NetworkController
{
public:
- SqliteNetworkController(const char *dbPath);
+ SqliteNetworkController(Node *node,const char *dbPath,const char *circuitTestPath);
virtual ~SqliteNetworkController();
virtual NetworkController::ResultCode doNetworkConfigRequest(
@@ -104,7 +106,9 @@ private:
const Dictionary &metaData,
Dictionary &netconf);
+ Node *_node;
std::string _dbPath;
+ std::string _circuitTestPath;
std::string _instanceId;
// A circular buffer last log
diff --git a/service/OneService.cpp b/service/OneService.cpp
index 4b374cd7..071a2cbc 100644
--- a/service/OneService.cpp
+++ b/service/OneService.cpp
@@ -422,7 +422,7 @@ public:
_homePath((hp) ? hp : "."),
_tcpFallbackResolver(ZT_TCP_FALLBACK_RELAY),
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
- _controller((_homePath + ZT_PATH_SEPARATOR_S + ZT_CONTROLLER_DB_PATH).c_str()),
+ _controller((SqliteNetworkController *)0),
#endif
_phy(this,false,true),
_overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""),
@@ -515,6 +515,9 @@ public:
_phy.close(_v4UpnpUdpSocket);
delete _upnpClient;
#endif
+#ifdef ZT_ENABLE_NETWORK_CONTROLLER
+ delete _controller;
+#endif
}
virtual ReasonForTermination run()
@@ -551,14 +554,15 @@ public:
((_overrideRootTopology.length() > 0) ? _overrideRootTopology.c_str() : (const char *)0));
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
- _node->setNetconfMaster((void *)&_controller);
+ _controller = new SqliteNetworkController(_node,(_homePath + ZT_PATH_SEPARATOR_S + ZT_CONTROLLER_DB_PATH).c_str(),(_homePath + ZT_PATH_SEPARATOR_S + "circuitTestResults.d").c_str());
+ _node->setNetconfMaster((void *)_controller);
#endif
_controlPlane = new ControlPlane(this,_node,(_homePath + ZT_PATH_SEPARATOR_S + "ui").c_str());
_controlPlane->addAuthToken(authToken.c_str());
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
- _controlPlane->setController(&_controller);
+ _controlPlane->setController(_controller);
#endif
{ // Remember networks from previous session
@@ -1322,7 +1326,7 @@ private:
const std::string _homePath;
BackgroundResolver _tcpFallbackResolver;
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
- SqliteNetworkController _controller;
+ SqliteNetworkController *_controller;
#endif
Phy<OneServiceImpl *> _phy;
std::string _overrideRootTopology;