Prep in controller code to run tests.

This commit is contained in:
Adam Ierymenko 2015-10-06 15:56:18 -07:00
parent 3593fb3462
commit 7394ec6f6a
3 changed files with 19 additions and 6 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 : ""),
@ -514,6 +514,9 @@ public:
#ifdef ZT_USE_MINIUPNPC
_phy.close(_v4UpnpUdpSocket);
delete _upnpClient;
#endif
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
delete _controller;
#endif
}
@ -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;