mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-02 23:40:50 +00:00
Rename netconf to controller and NetworkConfigMaster to NetworkController for consistency.
This commit is contained in:
parent
871473255b
commit
6369c264e2
@ -27,8 +27,6 @@ You *only* need an account on our site if you want to use the control panel foun
|
|||||||
|
|
||||||
Public networks, as the name implies, can be joined without getting authorization from anyone. All you need is their 16-digit network ID. A public network called [Earth](https://www.zerotier.com/earth.html) (8056c2e21c000001) exists for everyone, but be sure your device is adequately secured and up to date before joining.
|
Public networks, as the name implies, can be joined without getting authorization from anyone. All you need is their 16-digit network ID. A public network called [Earth](https://www.zerotier.com/earth.html) (8056c2e21c000001) exists for everyone, but be sure your device is adequately secured and up to date before joining.
|
||||||
|
|
||||||
Alternatively, you can run your own network configuration controller. This lets you run any network for free. To do this, start with the netconf-service/ subfolder of this project. You'll need to do a bit of system administration work and manually populate a Redis database, but it's not terribly hard if you're into that kind of thing.
|
|
||||||
|
|
||||||
More products and services will be forthcoming.
|
More products and services will be forthcoming.
|
||||||
|
|
||||||
### Basic Troubleshooting
|
### Basic Troubleshooting
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
Network Configuration Master
|
Network Controller Implementation
|
||||||
======
|
======
|
||||||
|
|
||||||
This folder contains code implementing the node/NetworkConfigMaster.hpp interface to allow ZeroTier nodes to create and manage virtual networks.
|
This folder contains code implementing the node/NetworkController.hpp interface to allow ZeroTier nodes to create and manage virtual networks.
|
||||||
|
|
||||||
The standard implementation uses SQLite3 with the attached schema. A separate service (not included here yet) is used to administrate that database and configure networks.
|
The standard implementation uses SQLite3 with the attached schema. A separate service (not included here yet) is used to administrate that database and configure networks.
|
||||||
|
|
@ -37,7 +37,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include "SqliteNetworkConfigMaster.hpp"
|
#include "SqliteNetworkController.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"
|
||||||
@ -53,16 +53,16 @@
|
|||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
SqliteNetworkConfigMaster::SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath) :
|
SqliteNetworkController::SqliteNetworkController(const Identity &signingId,const char *dbPath) :
|
||||||
_signingId(signingId),
|
_signingId(signingId),
|
||||||
_dbPath(dbPath),
|
_dbPath(dbPath),
|
||||||
_db((sqlite3 *)0)
|
_db((sqlite3 *)0)
|
||||||
{
|
{
|
||||||
if (!_signingId.hasPrivate())
|
if (!_signingId.hasPrivate())
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster signing identity must have a private key");
|
throw std::runtime_error("SqliteNetworkController signing identity must have a private key");
|
||||||
|
|
||||||
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)
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster cannot open database file");
|
throw std::runtime_error("SqliteNetworkController cannot open database file");
|
||||||
sqlite3_busy_timeout(_db,10000);
|
sqlite3_busy_timeout(_db,10000);
|
||||||
|
|
||||||
sqlite3_stmt *s = (sqlite3_stmt *)0;
|
sqlite3_stmt *s = (sqlite3_stmt *)0;
|
||||||
@ -75,18 +75,18 @@ SqliteNetworkConfigMaster::SqliteNetworkConfigMaster(const Identity &signingId,c
|
|||||||
|
|
||||||
if (schemaVersion == -1234) {
|
if (schemaVersion == -1234) {
|
||||||
sqlite3_close(_db);
|
sqlite3_close(_db);
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster schemaVersion not found in Config table (init failure?)");
|
throw std::runtime_error("SqliteNetworkController schemaVersion not found in Config table (init failure?)");
|
||||||
} else if (schemaVersion != ZT_NETCONF_SQLITE_SCHEMA_VERSION) {
|
} else if (schemaVersion != ZT_NETCONF_SQLITE_SCHEMA_VERSION) {
|
||||||
// Note -- this will eventually run auto-upgrades so this isn't how it'll work going forward
|
// Note -- this will eventually run auto-upgrades so this isn't how it'll work going forward
|
||||||
sqlite3_close(_db);
|
sqlite3_close(_db);
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster database schema version mismatch");
|
throw std::runtime_error("SqliteNetworkController database schema version mismatch");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Prepare statement will fail if Config table doesn't exist, which means our DB
|
// Prepare statement will fail if Config table doesn't exist, which means our DB
|
||||||
// needs to be initialized.
|
// needs to be initialized.
|
||||||
if (sqlite3_exec(_db,ZT_NETCONF_SCHEMA_SQL"INSERT INTO Config (k,v) VALUES ('schemaVersion',"ZT_NETCONF_SQLITE_SCHEMA_VERSION_STR");",0,0,0) != SQLITE_OK) {
|
if (sqlite3_exec(_db,ZT_NETCONF_SCHEMA_SQL"INSERT INTO Config (k,v) VALUES ('schemaVersion',"ZT_NETCONF_SQLITE_SCHEMA_VERSION_STR");",0,0,0) != SQLITE_OK) {
|
||||||
sqlite3_close(_db);
|
sqlite3_close(_db);
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster cannot initialize database and/or insert schemaVersion into Config table");
|
throw std::runtime_error("SqliteNetworkController cannot initialize database and/or insert schemaVersion into Config table");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,11 +109,11 @@ SqliteNetworkConfigMaster::SqliteNetworkConfigMaster(const Identity &signingId,c
|
|||||||
||(sqlite3_prepare_v2(_db,"UPDATE Member SET 'cachedNetconf' = ?,'cachedNetconfRevision' = ? WHERE rowid = ?",-1,&_sCacheNetconf,(const char **)0) != SQLITE_OK)
|
||(sqlite3_prepare_v2(_db,"UPDATE Member SET 'cachedNetconf' = ?,'cachedNetconfRevision' = ? WHERE rowid = ?",-1,&_sCacheNetconf,(const char **)0) != SQLITE_OK)
|
||||||
) {
|
) {
|
||||||
sqlite3_close(_db);
|
sqlite3_close(_db);
|
||||||
throw std::runtime_error("SqliteNetworkConfigMaster unable to initialize one or more prepared statements");
|
throw std::runtime_error("SqliteNetworkController unable to initialize one or more prepared statements");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SqliteNetworkConfigMaster::~SqliteNetworkConfigMaster()
|
SqliteNetworkController::~SqliteNetworkController()
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
if (_db) {
|
if (_db) {
|
||||||
@ -137,7 +137,7 @@ SqliteNetworkConfigMaster::~SqliteNetworkConfigMaster()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigRequest(const InetAddress &fromAddr,const Identity &identity,uint64_t nwid,const Dictionary &metaData,uint64_t haveRevision,Dictionary &netconf)
|
NetworkController::ResultCode SqliteNetworkController::doNetworkConfigRequest(const InetAddress &fromAddr,const Identity &identity,uint64_t nwid,const Dictionary &metaData,uint64_t haveRevision,Dictionary &netconf)
|
||||||
{
|
{
|
||||||
Mutex::Lock _l(_lock);
|
Mutex::Lock _l(_lock);
|
||||||
|
|
||||||
@ -195,10 +195,10 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
sqlite3_step(_sUpdateNode2);
|
sqlite3_step(_sUpdateNode2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED;
|
return NetworkController::NETCONF_QUERY_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
} catch ( ... ) { // identity stored in database is not valid or is NULL
|
} catch ( ... ) { // identity stored in database is not valid or is NULL
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED;
|
return NetworkController::NETCONF_QUERY_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
std::string idstr(identity.toString(false));
|
std::string idstr(identity.toString(false));
|
||||||
@ -215,7 +215,7 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
sqlite3_bind_text(_sCreateNode,5,lastSeen,-1,SQLITE_STATIC);
|
sqlite3_bind_text(_sCreateNode,5,lastSeen,-1,SQLITE_STATIC);
|
||||||
if (sqlite3_step(_sCreateNode) != SQLITE_DONE) {
|
if (sqlite3_step(_sCreateNode) != SQLITE_DONE) {
|
||||||
netconf["error"] = "unable to create new node record";
|
netconf["error"] = "unable to create new node record";
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_INTERNAL_SERVER_ERROR;
|
return NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -236,7 +236,7 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
network.revision = (uint64_t)sqlite3_column_int64(_sGetNetworkById,7);
|
network.revision = (uint64_t)sqlite3_column_int64(_sGetNetworkById,7);
|
||||||
}
|
}
|
||||||
if (!foundNetwork)
|
if (!foundNetwork)
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_OBJECT_NOT_FOUND;
|
return NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND;
|
||||||
|
|
||||||
// Fetch Member record
|
// Fetch Member record
|
||||||
|
|
||||||
@ -269,14 +269,14 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
sqlite3_bind_int(_sCreateMember,3,(member.authorized ? 0 : 1));
|
sqlite3_bind_int(_sCreateMember,3,(member.authorized ? 0 : 1));
|
||||||
if ( (sqlite3_step(_sCreateMember) != SQLITE_DONE) && ((member.rowid = (int64_t)sqlite3_last_insert_rowid(_db)) > 0) ) {
|
if ( (sqlite3_step(_sCreateMember) != SQLITE_DONE) && ((member.rowid = (int64_t)sqlite3_last_insert_rowid(_db)) > 0) ) {
|
||||||
netconf["error"] = "unable to create new member record";
|
netconf["error"] = "unable to create new member record";
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_INTERNAL_SERVER_ERROR;
|
return NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check member authorization
|
// Check member authorization
|
||||||
|
|
||||||
if (!member.authorized)
|
if (!member.authorized)
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED;
|
return NetworkController::NETCONF_QUERY_ACCESS_DENIED;
|
||||||
|
|
||||||
// Update client's currently reported haveRevision in Member record
|
// Update client's currently reported haveRevision in Member record
|
||||||
|
|
||||||
@ -290,7 +290,7 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
// If netconf is unchanged from client reported revision, just tell client they're up to date
|
// If netconf is unchanged from client reported revision, just tell client they're up to date
|
||||||
|
|
||||||
if ((haveRevision > 0)&&(haveRevision == network.revision))
|
if ((haveRevision > 0)&&(haveRevision == network.revision))
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_OK_BUT_NOT_NEWER;
|
return NetworkController::NETCONF_QUERY_OK_BUT_NOT_NEWER;
|
||||||
|
|
||||||
// Generate or retrieve cached netconf
|
// Generate or retrieve cached netconf
|
||||||
|
|
||||||
@ -473,7 +473,7 @@ NetworkConfigMaster::ResultCode SqliteNetworkConfigMaster::doNetworkConfigReques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NetworkConfigMaster::NETCONF_QUERY_OK;
|
return NetworkController::NETCONF_QUERY_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ZeroTier
|
} // namespace ZeroTier
|
@ -25,8 +25,8 @@
|
|||||||
* LLC. Start here: http://www.zerotier.com/
|
* LLC. Start here: http://www.zerotier.com/
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef ZT_SQLITENETWORKCONFIGMASTER_HPP
|
#ifndef ZT_SQLITENETWORKCONTROLLER_HPP
|
||||||
#define ZT_SQLITENETWORKCONFIGMASTER_HPP
|
#define ZT_SQLITENETWORKCONTROLLER_HPP
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
@ -37,22 +37,22 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "../node/Constants.hpp"
|
#include "../node/Constants.hpp"
|
||||||
#include "../node/NetworkConfigMaster.hpp"
|
#include "../node/NetworkController.hpp"
|
||||||
#include "../node/Mutex.hpp"
|
#include "../node/Mutex.hpp"
|
||||||
#include "../node/NonCopyable.hpp"
|
#include "../node/NonCopyable.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
class SqliteNetworkConfigMaster : public NetworkConfigMaster
|
class SqliteNetworkController : public NetworkController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class DBC;
|
class DBC;
|
||||||
friend class SqliteNetworkConfigMaster::DBC;
|
friend class SqliteNetworkController::DBC;
|
||||||
|
|
||||||
SqliteNetworkConfigMaster(const Identity &signingId,const char *dbPath);
|
SqliteNetworkController(const Identity &signingId,const char *dbPath);
|
||||||
virtual ~SqliteNetworkConfigMaster();
|
virtual ~SqliteNetworkController();
|
||||||
|
|
||||||
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
|
virtual NetworkController::ResultCode doNetworkConfigRequest(
|
||||||
const InetAddress &fromAddr,
|
const InetAddress &fromAddr,
|
||||||
const Identity &identity,
|
const Identity &identity,
|
||||||
uint64_t nwid,
|
uint64_t nwid,
|
||||||
@ -90,16 +90,16 @@ public:
|
|||||||
*
|
*
|
||||||
* This acts as both a contextual lock of the master's Mutex and a pointer
|
* This acts as both a contextual lock of the master's Mutex and a pointer
|
||||||
* to the Sqlite3 database instance. Dereferencing this with * yields the
|
* to the Sqlite3 database instance. Dereferencing this with * yields the
|
||||||
* sqlite3* pointer. Create on parent with DBC(SqliteNetworkConfigMaster &).
|
* sqlite3* pointer. Create on parent with DBC(SqliteNetworkController &).
|
||||||
*/
|
*/
|
||||||
class DBC : NonCopyable
|
class DBC : NonCopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DBC(SqliteNetworkConfigMaster &nc) : _p(&nc) { nc._lock.lock(); }
|
DBC(SqliteNetworkController &nc) : _p(&nc) { nc._lock.lock(); }
|
||||||
~DBC() { _p->_lock.unlock(); }
|
~DBC() { _p->_lock.unlock(); }
|
||||||
inline sqlite3 *operator*() const throw() { return _p->_db; }
|
inline sqlite3 *operator*() const throw() { return _p->_db; }
|
||||||
private:
|
private:
|
||||||
SqliteNetworkConfigMaster *const _p;
|
SqliteNetworkController *const _p;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
8
controller/schema2c.sh
Executable file
8
controller/schema2c.sh
Executable file
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Run this file to package the .sql file into a .c file whenever the SQL changes.
|
||||||
|
|
||||||
|
rm -f schema.sql.c
|
||||||
|
echo '#define ZT_NETCONF_SCHEMA_SQL \' >schema.sql.c
|
||||||
|
cat schema.sql | sed 's/"/\\"/g' | sed 's/^/"/' | sed 's/$/\\n"\\/' >>schema.sql.c
|
||||||
|
echo '""' >>schema.sql.c
|
@ -7,7 +7,6 @@ LIBS=
|
|||||||
|
|
||||||
include objects.mk
|
include objects.mk
|
||||||
OBJS+=osdep/BSDEthernetTap.o
|
OBJS+=osdep/BSDEthernetTap.o
|
||||||
TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o
|
|
||||||
|
|
||||||
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
|
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
|
||||||
MACHINE=$(shell uname -m)
|
MACHINE=$(shell uname -m)
|
||||||
@ -30,13 +29,6 @@ ifeq ($(MACHINE),x86)
|
|||||||
DEFS+=-DZT_SALSA20_SSE
|
DEFS+=-DZT_SALSA20_SSE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
|
|
||||||
ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
|
|
||||||
DEFS+=-DZT_ENABLE_NETCONF_MASTER
|
|
||||||
LIBS+=-lsqlite3
|
|
||||||
OBJS+=netconf/SqliteNetworkConfigMaster.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
# "make official" is a shortcut for this
|
# "make official" is a shortcut for this
|
||||||
ifeq ($(ZT_OFFICIAL_RELEASE),1)
|
ifeq ($(ZT_OFFICIAL_RELEASE),1)
|
||||||
ZT_AUTO_UPDATE=1
|
ZT_AUTO_UPDATE=1
|
||||||
@ -65,8 +57,8 @@ CXXFLAGS=$(CFLAGS) -fno-rtti
|
|||||||
|
|
||||||
all: one
|
all: one
|
||||||
|
|
||||||
one: $(OBJS) main.o
|
one: $(OBJS) one.o
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
|
||||||
$(STRIP) zerotier-one
|
$(STRIP) zerotier-one
|
||||||
ln -sf zerotier-one zerotier-cli
|
ln -sf zerotier-one zerotier-cli
|
||||||
ln -sf zerotier-one zerotier-idtool
|
ln -sf zerotier-one zerotier-idtool
|
||||||
@ -75,16 +67,12 @@ selftest: $(OBJS) selftest.o
|
|||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
|
||||||
$(STRIP) zerotier-selftest
|
$(STRIP) zerotier-selftest
|
||||||
|
|
||||||
testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
|
|
||||||
$(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
|
|
||||||
$(STRIP) zerotier-testnet
|
|
||||||
|
|
||||||
# No installer on FreeBSD yet
|
# No installer on FreeBSD yet
|
||||||
#installer: one FORCE
|
#installer: one FORCE
|
||||||
# ./buildinstaller.sh
|
# ./buildinstaller.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o netconf/*.o node/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o build-* zerotier-* ZeroTierOneInstaller-*
|
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o build-* zerotier-* ZeroTierOneInstaller-*
|
||||||
|
|
||||||
debug: FORCE
|
debug: FORCE
|
||||||
make -j 4 ZT_DEBUG=1
|
make -j 4 ZT_DEBUG=1
|
||||||
|
@ -8,7 +8,6 @@ LIBS=
|
|||||||
|
|
||||||
include objects.mk
|
include objects.mk
|
||||||
OBJS+=osdep/LinuxEthernetTap.o
|
OBJS+=osdep/LinuxEthernetTap.o
|
||||||
TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o
|
|
||||||
|
|
||||||
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
|
# Enable SSE-optimized Salsa20 on x86 and x86_64 machines
|
||||||
MACHINE=$(shell uname -m)
|
MACHINE=$(shell uname -m)
|
||||||
@ -31,13 +30,6 @@ ifeq ($(MACHINE),x86)
|
|||||||
DEFS+=-DZT_SALSA20_SSE
|
DEFS+=-DZT_SALSA20_SSE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
|
|
||||||
ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
|
|
||||||
DEFS+=-DZT_ENABLE_NETCONF_MASTER
|
|
||||||
LIBS+=-lsqlite3
|
|
||||||
OBJS+=netconf/SqliteNetworkConfigMaster.o
|
|
||||||
endif
|
|
||||||
|
|
||||||
# "make official" is a shortcut for this
|
# "make official" is a shortcut for this
|
||||||
ifeq ($(ZT_OFFICIAL_RELEASE),1)
|
ifeq ($(ZT_OFFICIAL_RELEASE),1)
|
||||||
ZT_AUTO_UPDATE=1
|
ZT_AUTO_UPDATE=1
|
||||||
@ -71,8 +63,8 @@ CXXFLAGS=$(CFLAGS) -fno-rtti
|
|||||||
|
|
||||||
all: one
|
all: one
|
||||||
|
|
||||||
one: $(OBJS) main.o
|
one: $(OBJS) one.o
|
||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one main.o $(OBJS) $(LIBS)
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-one $(OBJS) one.o $(LIBS)
|
||||||
$(STRIP) zerotier-one
|
$(STRIP) zerotier-one
|
||||||
ln -sf zerotier-one zerotier-cli
|
ln -sf zerotier-one zerotier-cli
|
||||||
ln -sf zerotier-one zerotier-idtool
|
ln -sf zerotier-one zerotier-idtool
|
||||||
@ -81,15 +73,11 @@ selftest: $(OBJS) selftest.o
|
|||||||
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS)
|
||||||
$(STRIP) zerotier-selftest
|
$(STRIP) zerotier-selftest
|
||||||
|
|
||||||
testnet: $(TESTNET_OBJS) $(OBJS) testnet.o
|
|
||||||
$(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS)
|
|
||||||
$(STRIP) zerotier-testnet
|
|
||||||
|
|
||||||
installer: one FORCE
|
installer: one FORCE
|
||||||
./buildinstaller.sh
|
./buildinstaller.sh
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.o netconf/*.o node/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
|
rm -rf *.o node/*.o controller/*.o osdep/*.o service/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* build-* ZeroTierOneInstaller-* *.deb *.rpm
|
||||||
|
|
||||||
debug: FORCE
|
debug: FORCE
|
||||||
make -j 4 ZT_DEBUG=1
|
make -j 4 ZT_DEBUG=1
|
||||||
|
11
make-mac.mk
11
make-mac.mk
@ -26,12 +26,11 @@ ifeq ($(ZT_AUTO_UPDATE),1)
|
|||||||
DEFS+=-DZT_AUTO_UPDATE
|
DEFS+=-DZT_AUTO_UPDATE
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Build with ZT_ENABLE_NETCONF_MASTER=1 to build with NetworkConfigMaster enabled
|
# Build with ZT_ENABLE_NETWORK_CONTROLLER=1 to build with the Sqlite network controller
|
||||||
ifeq ($(ZT_ENABLE_NETCONF_MASTER),1)
|
ifeq ($(ZT_ENABLE_NETWORK_CONTROLLER),1)
|
||||||
DEFS+=-DZT_ENABLE_NETCONF_MASTER
|
DEFS+=-DZT_ENABLE_NETWORK_CONTROLLER
|
||||||
LIBS+=-L/usr/local/lib -lsqlite3
|
LIBS+=-L/usr/local/lib -lsqlite3
|
||||||
ARCH_FLAGS=-arch x86_64
|
OBJS+=controller/SqliteNetworkController.o
|
||||||
OBJS+=netconf/SqliteNetworkConfigMaster.o
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# Enable SSE-optimized Salsa20 -- all Intel macs support SSE2
|
# Enable SSE-optimized Salsa20 -- all Intel macs support SSE2
|
||||||
@ -77,7 +76,7 @@ selftest: $(OBJS) selftest.o
|
|||||||
# $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
|
# $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app"
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf *.dSYM build-* *.pkg *.dmg *.o netconf/*.o service/*.o node/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* ZeroTierOneInstaller-*
|
rm -rf *.dSYM build-* *.pkg *.dmg *.o node/*.o controller/*.o service/*.o osdep/*.o ext/http-parser/*.o ext/lz4/*.o zerotier-* ZeroTierOneInstaller-*
|
||||||
|
|
||||||
# For our use -- builds official signed binary, packages in installer and download DMG
|
# For our use -- builds official signed binary, packages in installer and download DMG
|
||||||
official: FORCE
|
official: FORCE
|
||||||
|
@ -1,8 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Run this file to package the .sql file into a .c file whenever the SQL changes.
|
|
||||||
|
|
||||||
rm -f netconf-schema.sql.c
|
|
||||||
echo '#define ZT_NETCONF_SCHEMA_SQL \' >netconf-schema.sql.c
|
|
||||||
cat netconf-schema.sql | sed 's/"/\\"/g' | sed 's/^/"/' | sed 's/$/\\n"\\/' >>netconf-schema.sql.c
|
|
||||||
echo '""' >>netconf-schema.sql.c
|
|
@ -38,7 +38,7 @@
|
|||||||
#include "Topology.hpp"
|
#include "Topology.hpp"
|
||||||
#include "Switch.hpp"
|
#include "Switch.hpp"
|
||||||
#include "Peer.hpp"
|
#include "Peer.hpp"
|
||||||
#include "NetworkConfigMaster.hpp"
|
#include "NetworkController.hpp"
|
||||||
#include "SelfAwareness.hpp"
|
#include "SelfAwareness.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
@ -361,14 +361,14 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,const SharedPtr<Peer> &p
|
|||||||
if (dict.length()) {
|
if (dict.length()) {
|
||||||
if (nw->setConfiguration(Dictionary(dict)) == 2) { // 2 == accepted and actually new
|
if (nw->setConfiguration(Dictionary(dict)) == 2) { // 2 == accepted and actually new
|
||||||
/* If this configuration was indeed new, we do another
|
/* If this configuration was indeed new, we do another
|
||||||
* netconf request with its revision. We do this in
|
* controller request with its revision. We do this in
|
||||||
* order to (a) tell the netconf server we got it (it
|
* order to (a) tell the network controller we got it (it
|
||||||
* won't send a duplicate if ts == current), and (b)
|
* won't send a duplicate if ts == current), and (b)
|
||||||
* get another one if the netconf is changing rapidly
|
* get another one if the controller is changing rapidly
|
||||||
* until we finally have the final version.
|
* until we finally have the final version.
|
||||||
*
|
*
|
||||||
* Note that we don't do this for netconf masters with
|
* Note that we don't do this for network controllers with
|
||||||
* versions <= 1.0.3, since those regenerate a new netconf
|
* versions <= 1.0.3, since those regenerate a new controller
|
||||||
* with a new revision every time. In that case this double
|
* with a new revision every time. In that case this double
|
||||||
* confirmation would create a race condition. */
|
* confirmation would create a race condition. */
|
||||||
const SharedPtr<NetworkConfig> nc(nw->config2());
|
const SharedPtr<NetworkConfig> nc(nw->config2());
|
||||||
@ -672,10 +672,10 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
const uint64_t pid = packetId();
|
const uint64_t pid = packetId();
|
||||||
peer->received(RR,_remoteAddress,_linkDesperation,h,pid,Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP);
|
peer->received(RR,_remoteAddress,_linkDesperation,h,pid,Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP);
|
||||||
|
|
||||||
if (RR->netconfMaster) {
|
if (RR->localNetworkController) {
|
||||||
Dictionary netconf;
|
Dictionary netconf;
|
||||||
switch(RR->netconfMaster->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,peer->identity(),nwid,metaData,haveRevision,netconf)) {
|
switch(RR->localNetworkController->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,peer->identity(),nwid,metaData,haveRevision,netconf)) {
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_OK: {
|
case NetworkController::NETCONF_QUERY_OK: {
|
||||||
const std::string netconfStr(netconf.toString());
|
const std::string netconfStr(netconf.toString());
|
||||||
if (netconfStr.length() > 0xffff) { // sanity check since field ix 16-bit
|
if (netconfStr.length() > 0xffff) { // sanity check since field ix 16-bit
|
||||||
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: netconf size %u is too large",(unsigned int)netconfStr.length());
|
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: netconf size %u is too large",(unsigned int)netconfStr.length());
|
||||||
@ -694,9 +694,9 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_OK_BUT_NOT_NEWER: // nothing to do -- netconf has not changed
|
case NetworkController::NETCONF_QUERY_OK_BUT_NOT_NEWER: // nothing to do -- netconf has not changed
|
||||||
break;
|
break;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_OBJECT_NOT_FOUND: {
|
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: {
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
||||||
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append(pid);
|
outp.append(pid);
|
||||||
@ -705,7 +705,7 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
outp.armor(peer->key(),true);
|
outp.armor(peer->key(),true);
|
||||||
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
|
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
|
||||||
} break;
|
} break;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED: {
|
case NetworkController::NETCONF_QUERY_ACCESS_DENIED: {
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
||||||
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append(pid);
|
outp.append(pid);
|
||||||
@ -714,11 +714,11 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
outp.armor(peer->key(),true);
|
outp.armor(peer->key(),true);
|
||||||
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
|
RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation);
|
||||||
} break;
|
} break;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
|
case NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
|
||||||
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: %s",netconf.get("error","(unknown)").c_str());
|
TRACE("NETWORK_CONFIG_REQUEST failed: internal error: %s",netconf.get("error","(unknown)").c_str());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkConfigMaster::doNetworkConfigRequest()");
|
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkController::doNetworkConfigRequest()");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
#include "Switch.hpp"
|
#include "Switch.hpp"
|
||||||
#include "Packet.hpp"
|
#include "Packet.hpp"
|
||||||
#include "Buffer.hpp"
|
#include "Buffer.hpp"
|
||||||
#include "NetworkConfigMaster.hpp"
|
#include "NetworkController.hpp"
|
||||||
|
|
||||||
namespace ZeroTier {
|
namespace ZeroTier {
|
||||||
|
|
||||||
@ -243,21 +243,21 @@ int Network::setConfiguration(const Dictionary &conf,bool saveToDisk)
|
|||||||
|
|
||||||
void Network::requestConfiguration()
|
void Network::requestConfiguration()
|
||||||
{
|
{
|
||||||
if (_id == ZT_TEST_NETWORK_ID) // pseudo-network-ID, no netconf master
|
if (_id == ZT_TEST_NETWORK_ID) // pseudo-network-ID, uses locally generated static config
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (controller() == RR->identity.address()) {
|
if (controller() == RR->identity.address()) {
|
||||||
if (RR->netconfMaster) {
|
if (RR->localNetworkController) {
|
||||||
SharedPtr<NetworkConfig> nconf(config2());
|
SharedPtr<NetworkConfig> nconf(config2());
|
||||||
Dictionary newconf;
|
Dictionary newconf;
|
||||||
switch(RR->netconfMaster->doNetworkConfigRequest(InetAddress(),RR->identity,_id,Dictionary(),(nconf) ? nconf->revision() : (uint64_t)0,newconf)) {
|
switch(RR->localNetworkController->doNetworkConfigRequest(InetAddress(),RR->identity,_id,Dictionary(),(nconf) ? nconf->revision() : (uint64_t)0,newconf)) {
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_OK:
|
case NetworkController::NETCONF_QUERY_OK:
|
||||||
this->setConfiguration(newconf,true);
|
this->setConfiguration(newconf,true);
|
||||||
return;
|
return;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_OBJECT_NOT_FOUND:
|
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND:
|
||||||
this->setNotFound();
|
this->setNotFound();
|
||||||
return;
|
return;
|
||||||
case NetworkConfigMaster::NETCONF_QUERY_ACCESS_DENIED:
|
case NetworkController::NETCONF_QUERY_ACCESS_DENIED:
|
||||||
this->setAccessDenied();
|
this->setAccessDenied();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
@ -269,7 +269,7 @@ void Network::requestConfiguration()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("requesting netconf for network %.16llx from netconf master %s",(unsigned long long)_id,controller().toString().c_str());
|
TRACE("requesting netconf for network %.16llx from controller %s",(unsigned long long)_id,controller().toString().c_str());
|
||||||
Packet outp(controller(),RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
|
Packet outp(controller(),RR->identity.address(),Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append((uint64_t)_id);
|
outp.append((uint64_t)_id);
|
||||||
outp.append((uint16_t)0); // no meta-data
|
outp.append((uint16_t)0); // no meta-data
|
||||||
@ -304,7 +304,7 @@ void Network::addMembershipCertificate(const CertificateOfMembership &cert,bool
|
|||||||
SharedPtr<Peer> signer(RR->topology->getPeer(cert.signedBy()));
|
SharedPtr<Peer> signer(RR->topology->getPeer(cert.signedBy()));
|
||||||
|
|
||||||
if (!signer) {
|
if (!signer) {
|
||||||
// This would be rather odd, since this is our netconf master... could happen
|
// This would be rather odd, since this is our controller... could happen
|
||||||
// if we get packets before we've gotten config.
|
// if we get packets before we've gotten config.
|
||||||
RR->sw->requestWhois(cert.signedBy());
|
RR->sw->requestWhois(cert.signedBy());
|
||||||
return;
|
return;
|
||||||
|
@ -88,7 +88,7 @@ public:
|
|||||||
inline uint64_t id() const throw() { return _id; }
|
inline uint64_t id() const throw() { return _id; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Address of network's netconf master (most significant 40 bits of ID)
|
* @return Address of network's controller (most significant 40 bits of ID)
|
||||||
*/
|
*/
|
||||||
inline Address controller() throw() { return Address(_id >> 24); }
|
inline Address controller() throw() { return Address(_id >> 24); }
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ public:
|
|||||||
int setConfiguration(const Dictionary &conf,bool saveToDisk = true);
|
int setConfiguration(const Dictionary &conf,bool saveToDisk = true);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set netconf failure to 'access denied' -- called in IncomingPacket when netconf master reports this
|
* Set netconf failure to 'access denied' -- called in IncomingPacket when controller reports this
|
||||||
*/
|
*/
|
||||||
inline void setAccessDenied()
|
inline void setAccessDenied()
|
||||||
{
|
{
|
||||||
@ -157,7 +157,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set netconf failure to 'not found' -- called by PacketDecider when netconf master reports this
|
* Set netconf failure to 'not found' -- called by PacketDecider when controller reports this
|
||||||
*/
|
*/
|
||||||
inline void setNotFound()
|
inline void setNotFound()
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ void NetworkConfig::_fromDictionary(const Dictionary &d)
|
|||||||
throw std::invalid_argument("configuration contains zero network ID");
|
throw std::invalid_argument("configuration contains zero network ID");
|
||||||
|
|
||||||
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
|
_timestamp = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_TIMESTAMP).c_str());
|
||||||
_revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older netconf masters don't send this, so default to 1
|
_revision = Utils::hexStrToU64(d.get(ZT_NETWORKCONFIG_DICT_KEY_REVISION,"1").c_str()); // older controllers don't send this, so default to 1
|
||||||
|
|
||||||
memset(_etWhitelist,0,sizeof(_etWhitelist));
|
memset(_etWhitelist,0,sizeof(_etWhitelist));
|
||||||
std::vector<std::string> ets(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES).c_str(),",","",""));
|
std::vector<std::string> ets(Utils::split(d.get(ZT_NETWORKCONFIG_DICT_KEY_ALLOWED_ETHERNET_TYPES).c_str(),",","",""));
|
||||||
|
@ -68,9 +68,9 @@ namespace ZeroTier {
|
|||||||
#define ZT_NETWORKCONFIG_DICT_KEY_RELAYS "rl"
|
#define ZT_NETWORKCONFIG_DICT_KEY_RELAYS "rl"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Network configuration received from netconf master nodes
|
* Network configuration received from network controller nodes
|
||||||
*
|
*
|
||||||
* This is an immutable value object created from a dictionary received from netconf master.
|
* This is an immutable value object created from a dictionary received from controller.
|
||||||
*/
|
*/
|
||||||
class NetworkConfig
|
class NetworkConfig
|
||||||
{
|
{
|
||||||
@ -102,10 +102,10 @@ public:
|
|||||||
* Create an instance of a NetworkConfig for the test network ID
|
* Create an instance of a NetworkConfig for the test network ID
|
||||||
*
|
*
|
||||||
* The test network ID is defined as ZT_TEST_NETWORK_ID. This is a
|
* The test network ID is defined as ZT_TEST_NETWORK_ID. This is a
|
||||||
* "fake" network with no real netconf master and default options.
|
* "fake" network with no real controller and default options.
|
||||||
*
|
*
|
||||||
* @param self This node's ZT address
|
* @param self This node's ZT address
|
||||||
* @return Configured instance of netconf for test network ID
|
* @return Configuration for test network ID
|
||||||
*/
|
*/
|
||||||
static SharedPtr<NetworkConfig> createTestNetworkConfig(const Address &self);
|
static SharedPtr<NetworkConfig> createTestNetworkConfig(const Address &self);
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ class RuntimeEnvironment;
|
|||||||
/**
|
/**
|
||||||
* Interface for network configuration (netconf) master implementations
|
* Interface for network configuration (netconf) master implementations
|
||||||
*/
|
*/
|
||||||
class NetworkConfigMaster
|
class NetworkController
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
@ -58,8 +58,8 @@ public:
|
|||||||
NETCONF_QUERY_INTERNAL_SERVER_ERROR = 4
|
NETCONF_QUERY_INTERNAL_SERVER_ERROR = 4
|
||||||
};
|
};
|
||||||
|
|
||||||
NetworkConfigMaster() {}
|
NetworkController() {}
|
||||||
virtual ~NetworkConfigMaster() {}
|
virtual ~NetworkController() {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handle a network config request, sending replies if necessary
|
* Handle a network config request, sending replies if necessary
|
||||||
@ -78,7 +78,7 @@ public:
|
|||||||
* @param result Dictionary to receive resulting signed netconf on success
|
* @param result Dictionary to receive resulting signed netconf on success
|
||||||
* @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
|
* @return Returns NETCONF_QUERY_OK if result dictionary is valid, or an error code on error
|
||||||
*/
|
*/
|
||||||
virtual NetworkConfigMaster::ResultCode doNetworkConfigRequest(
|
virtual NetworkController::ResultCode doNetworkConfigRequest(
|
||||||
const InetAddress &fromAddr,
|
const InetAddress &fromAddr,
|
||||||
const Identity &identity,
|
const Identity &identity,
|
||||||
uint64_t nwid,
|
uint64_t nwid,
|
@ -30,7 +30,7 @@
|
|||||||
#include "Constants.hpp"
|
#include "Constants.hpp"
|
||||||
#include "Node.hpp"
|
#include "Node.hpp"
|
||||||
#include "RuntimeEnvironment.hpp"
|
#include "RuntimeEnvironment.hpp"
|
||||||
#include "NetworkConfigMaster.hpp"
|
#include "NetworkController.hpp"
|
||||||
#include "CMWC4096.hpp"
|
#include "CMWC4096.hpp"
|
||||||
#include "Switch.hpp"
|
#include "Switch.hpp"
|
||||||
#include "Multicaster.hpp"
|
#include "Multicaster.hpp"
|
||||||
@ -407,9 +407,9 @@ void Node::freeQueryResult(void *qr)
|
|||||||
::free(qr);
|
::free(qr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::setNetconfMaster(void *networkConfigMasterInstance)
|
void Node::setNetconfMaster(void *networkControllerInstance)
|
||||||
{
|
{
|
||||||
RR->netconfMaster = reinterpret_cast<NetworkConfigMaster *>(networkConfigMasterInstance);
|
RR->localNetworkController = reinterpret_cast<NetworkController *>(networkControllerInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************/
|
/****************************************************************************/
|
||||||
@ -654,10 +654,10 @@ void ZT1_Node_freeQueryResult(ZT1_Node *node,void *qr)
|
|||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZT1_Node_setNetconfMaster(ZT1_Node *node,void *networkConfigMasterInstance)
|
void ZT1_Node_setNetconfMaster(ZT1_Node *node,void *networkControllerInstance)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
reinterpret_cast<ZeroTier::Node *>(node)->setNetconfMaster(networkConfigMasterInstance);
|
reinterpret_cast<ZeroTier::Node *>(node)->setNetconfMaster(networkControllerInstance);
|
||||||
} catch ( ... ) {}
|
} catch ( ... ) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ public:
|
|||||||
ZT1_VirtualNetworkConfig *networkConfig(uint64_t nwid) const;
|
ZT1_VirtualNetworkConfig *networkConfig(uint64_t nwid) const;
|
||||||
ZT1_VirtualNetworkList *networks() const;
|
ZT1_VirtualNetworkList *networks() const;
|
||||||
void freeQueryResult(void *qr);
|
void freeQueryResult(void *qr);
|
||||||
void setNetconfMaster(void *networkConfigMasterInstance);
|
void setNetconfMaster(void *networkControllerInstance);
|
||||||
|
|
||||||
// Internal functions ------------------------------------------------------
|
// Internal functions ------------------------------------------------------
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ class CMWC4096;
|
|||||||
class Node;
|
class Node;
|
||||||
class Multicaster;
|
class Multicaster;
|
||||||
class AntiRecursion;
|
class AntiRecursion;
|
||||||
class NetworkConfigMaster;
|
class NetworkController;
|
||||||
class SelfAwareness;
|
class SelfAwareness;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +54,7 @@ public:
|
|||||||
RuntimeEnvironment(Node *n) :
|
RuntimeEnvironment(Node *n) :
|
||||||
node(n),
|
node(n),
|
||||||
identity(),
|
identity(),
|
||||||
netconfMaster((NetworkConfigMaster *)0),
|
localNetworkController((NetworkController *)0),
|
||||||
prng((CMWC4096 *)0),
|
prng((CMWC4096 *)0),
|
||||||
sw((Switch *)0),
|
sw((Switch *)0),
|
||||||
mc((Multicaster *)0),
|
mc((Multicaster *)0),
|
||||||
@ -72,8 +72,8 @@ public:
|
|||||||
std::string publicIdentityStr;
|
std::string publicIdentityStr;
|
||||||
std::string secretIdentityStr;
|
std::string secretIdentityStr;
|
||||||
|
|
||||||
// This is set externally to an instance of this base class if netconf functionality is enabled
|
// This is set externally to an instance of this base class
|
||||||
NetworkConfigMaster *netconfMaster;
|
NetworkController *localNetworkController;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Order matters a bit here. These are constructed in this order
|
* Order matters a bit here. These are constructed in this order
|
||||||
|
16
selftest.cpp
16
selftest.cpp
@ -59,9 +59,9 @@
|
|||||||
#include "osdep/Phy.hpp"
|
#include "osdep/Phy.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ZT_ENABLE_NETCONF_MASTER
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
#include "netconf/SqliteNetworkConfigMaster.hpp"
|
#include "controller/SqliteNetworkController.hpp"
|
||||||
#endif // ZT_ENABLE_NETCONF_MASTER
|
#endif // ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
|
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
@ -726,14 +726,14 @@ static int testPhy()
|
|||||||
|
|
||||||
static int testSqliteNetconfMaster()
|
static int testSqliteNetconfMaster()
|
||||||
{
|
{
|
||||||
#ifdef ZT_ENABLE_NETCONF_MASTER
|
#ifdef ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
try {
|
try {
|
||||||
std::cout << "[netconf] Generating signing identity..." << std::endl;
|
std::cout << "[network-controller] Generating signing identity..." << std::endl;
|
||||||
Identity signingId;
|
Identity signingId;
|
||||||
signingId.generate();
|
signingId.generate();
|
||||||
|
|
||||||
std::cout << "[netconf] Creating database..." << std::endl;
|
std::cout << "[network-controller] Creating database..." << std::endl;
|
||||||
SqliteNetworkConfigMaster netconf(signingId,"netconf-test.db");
|
SqliteNetworkController controller(signingId,"network-controller-test.db");
|
||||||
} catch (std::runtime_error &exc) {
|
} catch (std::runtime_error &exc) {
|
||||||
std::cout << "FAIL! (unexpected exception: " << exc.what() << ")" << std::endl;
|
std::cout << "FAIL! (unexpected exception: " << exc.what() << ")" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
@ -741,7 +741,7 @@ static int testSqliteNetconfMaster()
|
|||||||
std::cout << "FAIL! (unexpected exception: ...)" << std::endl;
|
std::cout << "FAIL! (unexpected exception: ...)" << std::endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
#endif // ZT_ENABLE_NETCONF_MASTER
|
#endif // ZT_ENABLE_NETWORK_CONTROLLER
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user