mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Prep in controller code to run tests.
This commit is contained in:
parent
3593fb3462
commit
7394ec6f6a
3 changed files with 19 additions and 6 deletions
|
@ -44,12 +44,15 @@
|
||||||
#include "../ext/json-parser/json.h"
|
#include "../ext/json-parser/json.h"
|
||||||
|
|
||||||
#include "SqliteNetworkController.hpp"
|
#include "SqliteNetworkController.hpp"
|
||||||
|
|
||||||
|
#include "../node/Node.hpp"
|
||||||
#include "../node/Utils.hpp"
|
#include "../node/Utils.hpp"
|
||||||
#include "../node/CertificateOfMembership.hpp"
|
#include "../node/CertificateOfMembership.hpp"
|
||||||
#include "../node/NetworkConfig.hpp"
|
#include "../node/NetworkConfig.hpp"
|
||||||
#include "../node/InetAddress.hpp"
|
#include "../node/InetAddress.hpp"
|
||||||
#include "../node/MAC.hpp"
|
#include "../node/MAC.hpp"
|
||||||
#include "../node/Address.hpp"
|
#include "../node/Address.hpp"
|
||||||
|
|
||||||
#include "../osdep/OSUtils.hpp"
|
#include "../osdep/OSUtils.hpp"
|
||||||
|
|
||||||
// Include ZT_NETCONF_SCHEMA_SQL constant to init database
|
// Include ZT_NETCONF_SCHEMA_SQL constant to init database
|
||||||
|
@ -117,8 +120,10 @@ struct NetworkRecord {
|
||||||
|
|
||||||
} // anonymous namespace
|
} // anonymous namespace
|
||||||
|
|
||||||
SqliteNetworkController::SqliteNetworkController(const char *dbPath) :
|
SqliteNetworkController::SqliteNetworkController(Node *node,const char *dbPath,const char *circuitTestPath) :
|
||||||
|
_node(node),
|
||||||
_dbPath(dbPath),
|
_dbPath(dbPath),
|
||||||
|
_circuitTestPath(circuitTestPath),
|
||||||
_db((sqlite3 *)0)
|
_db((sqlite3 *)0)
|
||||||
{
|
{
|
||||||
if (sqlite3_open_v2(dbPath,&_db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,(const char *)0) != SQLITE_OK)
|
if (sqlite3_open_v2(dbPath,&_db,SQLITE_OPEN_READWRITE|SQLITE_OPEN_CREATE,(const char *)0) != SQLITE_OK)
|
||||||
|
|
|
@ -45,10 +45,12 @@
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
|
class Node;
|
||||||
|
|
||||||
class SqliteNetworkController : public NetworkController
|
class SqliteNetworkController : public NetworkController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SqliteNetworkController(const char *dbPath);
|
SqliteNetworkController(Node *node,const char *dbPath,const char *circuitTestPath);
|
||||||
virtual ~SqliteNetworkController();
|
virtual ~SqliteNetworkController();
|
||||||
|
|
||||||
virtual NetworkController::ResultCode doNetworkConfigRequest(
|
virtual NetworkController::ResultCode doNetworkConfigRequest(
|
||||||
|
@ -104,7 +106,9 @@ private:
|
||||||
const Dictionary &metaData,
|
const Dictionary &metaData,
|
||||||
Dictionary &netconf);
|
Dictionary &netconf);
|
||||||
|
|
||||||
|
Node *_node;
|
||||||
std::string _dbPath;
|
std::string _dbPath;
|
||||||
|
std::string _circuitTestPath;
|
||||||
std::string _instanceId;
|
std::string _instanceId;
|
||||||
|
|
||||||
// A circular buffer last log
|
// A circular buffer last log
|
||||||
|
|
|
@ -422,7 +422,7 @@ public:
|
||||||
_homePath((hp) ? hp : "."),
|
_homePath((hp) ? hp : "."),
|
||||||
_tcpFallbackResolver(ZT_TCP_FALLBACK_RELAY),
|
_tcpFallbackResolver(ZT_TCP_FALLBACK_RELAY),
|
||||||
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
_controller((_homePath + ZT_PATH_SEPARATOR_S + ZT_CONTROLLER_DB_PATH).c_str()),
|
_controller((SqliteNetworkController *)0),
|
||||||
#endif
|
#endif
|
||||||
_phy(this,false,true),
|
_phy(this,false,true),
|
||||||
_overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""),
|
_overrideRootTopology((overrideRootTopology) ? overrideRootTopology : ""),
|
||||||
|
@ -514,6 +514,9 @@ public:
|
||||||
#ifdef ZT_USE_MINIUPNPC
|
#ifdef ZT_USE_MINIUPNPC
|
||||||
_phy.close(_v4UpnpUdpSocket);
|
_phy.close(_v4UpnpUdpSocket);
|
||||||
delete _upnpClient;
|
delete _upnpClient;
|
||||||
|
#endif
|
||||||
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
|
delete _controller;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -551,14 +554,15 @@ public:
|
||||||
((_overrideRootTopology.length() > 0) ? _overrideRootTopology.c_str() : (const char *)0));
|
((_overrideRootTopology.length() > 0) ? _overrideRootTopology.c_str() : (const char *)0));
|
||||||
|
|
||||||
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
#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
|
#endif
|
||||||
|
|
||||||
_controlPlane = new ControlPlane(this,_node,(_homePath + ZT_PATH_SEPARATOR_S + "ui").c_str());
|
_controlPlane = new ControlPlane(this,_node,(_homePath + ZT_PATH_SEPARATOR_S + "ui").c_str());
|
||||||
_controlPlane->addAuthToken(authToken.c_str());
|
_controlPlane->addAuthToken(authToken.c_str());
|
||||||
|
|
||||||
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
_controlPlane->setController(&_controller);
|
_controlPlane->setController(_controller);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
{ // Remember networks from previous session
|
{ // Remember networks from previous session
|
||||||
|
@ -1322,7 +1326,7 @@ private:
|
||||||
const std::string _homePath;
|
const std::string _homePath;
|
||||||
BackgroundResolver _tcpFallbackResolver;
|
BackgroundResolver _tcpFallbackResolver;
|
||||||
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
SqliteNetworkController _controller;
|
SqliteNetworkController *_controller;
|
||||||
#endif
|
#endif
|
||||||
Phy<OneServiceImpl *> _phy;
|
Phy<OneServiceImpl *> _phy;
|
||||||
std::string _overrideRootTopology;
|
std::string _overrideRootTopology;
|
||||||
|
|
Loading…
Add table
Reference in a new issue