mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-05 03:53:44 +02:00
Wire up externally specified NetworkConfigMaster
This commit is contained in:
parent
61d89bd118
commit
278c8fd9f1
6 changed files with 18 additions and 9 deletions
7
main.cpp
7
main.cpp
|
@ -78,6 +78,10 @@
|
||||||
|
|
||||||
#include "osnet/NativeSocketManager.hpp"
|
#include "osnet/NativeSocketManager.hpp"
|
||||||
|
|
||||||
|
#ifdef ZT_ENABLE_NETCONF_MASTER
|
||||||
|
#include "netconf/SqliteNetworkConfigMaster.hpp"
|
||||||
|
#endif // ZT_ENABLE_NETCONF_MASTER
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include "osnet/WindowsEthernetTapFactory.hpp"
|
#include "osnet/WindowsEthernetTapFactory.hpp"
|
||||||
#include "osnet/WindowsRoutingTable.hpp"
|
#include "osnet/WindowsRoutingTable.hpp"
|
||||||
|
@ -810,6 +814,7 @@ int main(int argc,char **argv)
|
||||||
RoutingTable *routingTable = (RoutingTable *)0;
|
RoutingTable *routingTable = (RoutingTable *)0;
|
||||||
SocketManager *socketManager = (SocketManager *)0;
|
SocketManager *socketManager = (SocketManager *)0;
|
||||||
NodeControlService *controlService = (NodeControlService *)0;
|
NodeControlService *controlService = (NodeControlService *)0;
|
||||||
|
NetworkConfigMaster *netconfMaster = (NetworkConfigMaster *)0;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Get or create authtoken.secret -- note that if this fails, authentication
|
// Get or create authtoken.secret -- note that if this fails, authentication
|
||||||
|
@ -827,7 +832,7 @@ int main(int argc,char **argv)
|
||||||
throw;
|
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());
|
controlService = new NodeControlService(node,authToken.c_str());
|
||||||
|
|
||||||
switch(node->run()) {
|
switch(node->run()) {
|
||||||
|
|
|
@ -47,6 +47,7 @@ class SqliteNetworkConfigMaster : public NetworkConfigMaster
|
||||||
public:
|
public:
|
||||||
SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath);
|
SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath);
|
||||||
virtual ~SqliteNetworkConfigMaster();
|
virtual ~SqliteNetworkConfigMaster();
|
||||||
|
|
||||||
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
|
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
|
||||||
const InetAddress &fromAddr,
|
const InetAddress &fromAddr,
|
||||||
uint64_t packetId,
|
uint64_t packetId,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
CREATE TABLE Config (
|
CREATE TABLE Config (
|
||||||
k varchar(16) PRIMARY KEY NOT NULL,
|
k varchar(16) PRIMARY KEY NOT NULL,
|
||||||
v varchar(1024) NOT NULL
|
v varchar(1024) NOT NULL
|
||||||
) WITHOUT ROWID;
|
);
|
||||||
|
|
||||||
CREATE TABLE IpAssignment (
|
CREATE TABLE IpAssignment (
|
||||||
networkId char(16) NOT NULL,
|
networkId char(16) NOT NULL,
|
||||||
|
@ -30,8 +30,7 @@ CREATE TABLE Member (
|
||||||
nodeId char(10) NOT NULL,
|
nodeId char(10) NOT NULL,
|
||||||
cachedNetconf blob(4096),
|
cachedNetconf blob(4096),
|
||||||
cachedNetconfRevision integer(32),
|
cachedNetconfRevision integer(32),
|
||||||
cachedNetconfTimestamp integer(32),
|
clientReportedRevision integer(32),
|
||||||
clientReportedTimestamp integer(32),
|
|
||||||
authorized integer(1) NOT NULL DEFAULT(0),
|
authorized integer(1) NOT NULL DEFAULT(0),
|
||||||
activeBridge 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),
|
multicastLimit integer(8) NOT NULL DEFAULT(32),
|
||||||
creationTime integer(32) NOT NULL DEFAULT(0),
|
creationTime integer(32) NOT NULL DEFAULT(0),
|
||||||
revision integer(32) NOT NULL DEFAULT(0)
|
revision integer(32) NOT NULL DEFAULT(0)
|
||||||
) WITHOUT ROWID;
|
);
|
||||||
|
|
||||||
CREATE TABLE Node (
|
CREATE TABLE Node (
|
||||||
id char(10) PRIMARY KEY NOT NULL,
|
id char(10) PRIMARY KEY NOT NULL,
|
||||||
|
@ -70,7 +69,7 @@ CREATE TABLE Node (
|
||||||
lastAt varchar(64),
|
lastAt varchar(64),
|
||||||
lastSeen integer(32) NOT NULL DEFAULT(0),
|
lastSeen integer(32) NOT NULL DEFAULT(0),
|
||||||
firstSeen integer(32) NOT NULL DEFAULT(0)
|
firstSeen integer(32) NOT NULL DEFAULT(0)
|
||||||
) WITHOUT ROWID;
|
);
|
||||||
|
|
||||||
CREATE TABLE Rule (
|
CREATE TABLE Rule (
|
||||||
networkId char(16) NOT NULL,
|
networkId char(16) NOT NULL,
|
||||||
|
|
|
@ -108,7 +108,6 @@ struct _NodeImpl
|
||||||
delete renv.mc; renv.mc = (Multicaster *)0;
|
delete renv.mc; renv.mc = (Multicaster *)0;
|
||||||
delete renv.antiRec; renv.antiRec = (AntiRecursion *)0;
|
delete renv.antiRec; renv.antiRec = (AntiRecursion *)0;
|
||||||
delete renv.sw; renv.sw = (Switch *)0; // order matters less from here down
|
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.http; renv.http = (HttpClient *)0;
|
||||||
delete renv.prng; renv.prng = (CMWC4096 *)0;
|
delete renv.prng; renv.prng = (CMWC4096 *)0;
|
||||||
delete renv.log; renv.log = (Logger *)0; // but stop logging last of all
|
delete renv.log; renv.log = (Logger *)0; // but stop logging last of all
|
||||||
|
@ -129,6 +128,7 @@ Node::Node(
|
||||||
EthernetTapFactory *tf,
|
EthernetTapFactory *tf,
|
||||||
RoutingTable *rt,
|
RoutingTable *rt,
|
||||||
SocketManager *sm,
|
SocketManager *sm,
|
||||||
|
NetworkConfigMaster *nm,
|
||||||
bool resetIdentity,
|
bool resetIdentity,
|
||||||
const char *overrideRootTopology) throw() :
|
const char *overrideRootTopology) throw() :
|
||||||
_impl(new _NodeImpl)
|
_impl(new _NodeImpl)
|
||||||
|
@ -142,6 +142,7 @@ Node::Node(
|
||||||
impl->renv.tapFactory = tf;
|
impl->renv.tapFactory = tf;
|
||||||
impl->renv.routingTable = rt;
|
impl->renv.routingTable = rt;
|
||||||
impl->renv.sm = sm;
|
impl->renv.sm = sm;
|
||||||
|
impl->renv.netconfMaster = nm;
|
||||||
|
|
||||||
if (resetIdentity) {
|
if (resetIdentity) {
|
||||||
// Forget identity and peer database, peer keys, etc.
|
// Forget identity and peer database, peer keys, etc.
|
||||||
|
|
|
@ -37,6 +37,7 @@ namespace ZeroTier {
|
||||||
class EthernetTapFactory;
|
class EthernetTapFactory;
|
||||||
class RoutingTable;
|
class RoutingTable;
|
||||||
class SocketManager;
|
class SocketManager;
|
||||||
|
class NetworkConfigMaster;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ZeroTier One node
|
* A ZeroTier One node
|
||||||
|
@ -87,6 +88,7 @@ public:
|
||||||
* @param tf Ethernet tap factory for platform network stack
|
* @param tf Ethernet tap factory for platform network stack
|
||||||
* @param rt Routing table interface for platform network stack
|
* @param rt Routing table interface for platform network stack
|
||||||
* @param sm Socket manager for physical network I/O
|
* @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 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)
|
* @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,
|
EthernetTapFactory *tf,
|
||||||
RoutingTable *rt,
|
RoutingTable *rt,
|
||||||
SocketManager *sm,
|
SocketManager *sm,
|
||||||
|
NetworkConfigMaster *nm,
|
||||||
bool resetIdentity,
|
bool resetIdentity,
|
||||||
const char *overrideRootTopology = (const char *)0) throw();
|
const char *overrideRootTopology = (const char *)0) throw();
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,10 @@ public:
|
||||||
tapFactory((EthernetTapFactory *)0),
|
tapFactory((EthernetTapFactory *)0),
|
||||||
routingTable((RoutingTable *)0),
|
routingTable((RoutingTable *)0),
|
||||||
sm((SocketManager *)0),
|
sm((SocketManager *)0),
|
||||||
|
netconfMaster((NetworkConfigMaster *)0),
|
||||||
log((Logger *)0),
|
log((Logger *)0),
|
||||||
prng((CMWC4096 *)0),
|
prng((CMWC4096 *)0),
|
||||||
http((HttpClient *)0),
|
http((HttpClient *)0),
|
||||||
netconfMaster((NetworkConfigMaster *)0),
|
|
||||||
sw((Switch *)0),
|
sw((Switch *)0),
|
||||||
mc((Multicaster *)0),
|
mc((Multicaster *)0),
|
||||||
antiRec((AntiRecursion *)0),
|
antiRec((AntiRecursion *)0),
|
||||||
|
@ -112,6 +112,7 @@ public:
|
||||||
EthernetTapFactory *tapFactory;
|
EthernetTapFactory *tapFactory;
|
||||||
RoutingTable *routingTable;
|
RoutingTable *routingTable;
|
||||||
SocketManager *sm;
|
SocketManager *sm;
|
||||||
|
NetworkConfigMaster *netconfMaster;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Order matters a bit here. These are constructed in this order
|
* Order matters a bit here. These are constructed in this order
|
||||||
|
@ -124,7 +125,6 @@ public:
|
||||||
Logger *log; // null if logging is disabled
|
Logger *log; // null if logging is disabled
|
||||||
CMWC4096 *prng;
|
CMWC4096 *prng;
|
||||||
HttpClient *http;
|
HttpClient *http;
|
||||||
NetworkConfigMaster *netconfMaster;
|
|
||||||
Switch *sw;
|
Switch *sw;
|
||||||
Multicaster *mc;
|
Multicaster *mc;
|
||||||
AntiRecursion *antiRec;
|
AntiRecursion *antiRec;
|
||||||
|
|
Loading…
Add table
Reference in a new issue