Wire up externally specified NetworkConfigMaster

This commit is contained in:
Adam Ierymenko 2015-03-13 13:53:15 -07:00
parent 61d89bd118
commit 278c8fd9f1
6 changed files with 18 additions and 9 deletions

View File

@ -78,6 +78,10 @@
#include "osnet/NativeSocketManager.hpp"
#ifdef ZT_ENABLE_NETCONF_MASTER
#include "netconf/SqliteNetworkConfigMaster.hpp"
#endif // ZT_ENABLE_NETCONF_MASTER
#ifdef __WINDOWS__
#include "osnet/WindowsEthernetTapFactory.hpp"
#include "osnet/WindowsRoutingTable.hpp"
@ -810,6 +814,7 @@ int main(int argc,char **argv)
RoutingTable *routingTable = (RoutingTable *)0;
SocketManager *socketManager = (SocketManager *)0;
NodeControlService *controlService = (NodeControlService *)0;
NetworkConfigMaster *netconfMaster = (NetworkConfigMaster *)0;
try {
// Get or create authtoken.secret -- note that if this fails, authentication
@ -827,7 +832,7 @@ int main(int argc,char **argv)
throw;
}
node = new Node(homeDir,tapFactory,routingTable,socketManager,needsReset,(overrideRootTopology.length() > 0) ? overrideRootTopology.c_str() : (const char *)0);
node = new Node(homeDir,tapFactory,routingTable,socketManager,netconfMaster,needsReset,(overrideRootTopology.length() > 0) ? overrideRootTopology.c_str() : (const char *)0);
controlService = new NodeControlService(node,authToken.c_str());
switch(node->run()) {

View File

@ -47,6 +47,7 @@ class SqliteNetworkConfigMaster : public NetworkConfigMaster
public:
SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath);
virtual ~SqliteNetworkConfigMaster();
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
const InetAddress &fromAddr,
uint64_t packetId,

View File

@ -1,7 +1,7 @@
CREATE TABLE Config (
k varchar(16) PRIMARY KEY NOT NULL,
v varchar(1024) NOT NULL
) WITHOUT ROWID;
);
CREATE TABLE IpAssignment (
networkId char(16) NOT NULL,
@ -30,8 +30,7 @@ CREATE TABLE Member (
nodeId char(10) NOT NULL,
cachedNetconf blob(4096),
cachedNetconfRevision integer(32),
cachedNetconfTimestamp integer(32),
clientReportedTimestamp integer(32),
clientReportedRevision integer(32),
authorized integer(1) NOT NULL DEFAULT(0),
activeBridge integer(1) NOT NULL DEFAULT(0)
);
@ -62,7 +61,7 @@ CREATE TABLE Network (
multicastLimit integer(8) NOT NULL DEFAULT(32),
creationTime integer(32) NOT NULL DEFAULT(0),
revision integer(32) NOT NULL DEFAULT(0)
) WITHOUT ROWID;
);
CREATE TABLE Node (
id char(10) PRIMARY KEY NOT NULL,
@ -70,7 +69,7 @@ CREATE TABLE Node (
lastAt varchar(64),
lastSeen integer(32) NOT NULL DEFAULT(0),
firstSeen integer(32) NOT NULL DEFAULT(0)
) WITHOUT ROWID;
);
CREATE TABLE Rule (
networkId char(16) NOT NULL,

View File

@ -108,7 +108,6 @@ struct _NodeImpl
delete renv.mc; renv.mc = (Multicaster *)0;
delete renv.antiRec; renv.antiRec = (AntiRecursion *)0;
delete renv.sw; renv.sw = (Switch *)0; // order matters less from here down
delete renv.netconfMaster; renv.netconfMaster = (NetworkConfigMaster *)0;
delete renv.http; renv.http = (HttpClient *)0;
delete renv.prng; renv.prng = (CMWC4096 *)0;
delete renv.log; renv.log = (Logger *)0; // but stop logging last of all
@ -129,6 +128,7 @@ Node::Node(
EthernetTapFactory *tf,
RoutingTable *rt,
SocketManager *sm,
NetworkConfigMaster *nm,
bool resetIdentity,
const char *overrideRootTopology) throw() :
_impl(new _NodeImpl)
@ -142,6 +142,7 @@ Node::Node(
impl->renv.tapFactory = tf;
impl->renv.routingTable = rt;
impl->renv.sm = sm;
impl->renv.netconfMaster = nm;
if (resetIdentity) {
// Forget identity and peer database, peer keys, etc.

View File

@ -37,6 +37,7 @@ namespace ZeroTier {
class EthernetTapFactory;
class RoutingTable;
class SocketManager;
class NetworkConfigMaster;
/**
* A ZeroTier One node
@ -87,6 +88,7 @@ public:
* @param tf Ethernet tap factory for platform network stack
* @param rt Routing table interface for platform network stack
* @param sm Socket manager for physical network I/O
* @param nm Network configuration master or NULL for none
* @param resetIdentity If true, delete identity before starting and regenerate
* @param overrideRootTopology Override root topology with this dictionary (in string serialized format) and do not update (default: NULL for none)
*/
@ -95,6 +97,7 @@ public:
EthernetTapFactory *tf,
RoutingTable *rt,
SocketManager *sm,
NetworkConfigMaster *nm,
bool resetIdentity,
const char *overrideRootTopology = (const char *)0) throw();

View File

@ -75,10 +75,10 @@ public:
tapFactory((EthernetTapFactory *)0),
routingTable((RoutingTable *)0),
sm((SocketManager *)0),
netconfMaster((NetworkConfigMaster *)0),
log((Logger *)0),
prng((CMWC4096 *)0),
http((HttpClient *)0),
netconfMaster((NetworkConfigMaster *)0),
sw((Switch *)0),
mc((Multicaster *)0),
antiRec((AntiRecursion *)0),
@ -112,6 +112,7 @@ public:
EthernetTapFactory *tapFactory;
RoutingTable *routingTable;
SocketManager *sm;
NetworkConfigMaster *netconfMaster;
/*
* Order matters a bit here. These are constructed in this order
@ -124,7 +125,6 @@ public:
Logger *log; // null if logging is disabled
CMWC4096 *prng;
HttpClient *http;
NetworkConfigMaster *netconfMaster;
Switch *sw;
Multicaster *mc;
AntiRecursion *antiRec;