From 926ecf964047f7ab23ee2c086d826688c5228c96 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 5 Dec 2017 14:50:59 -0800 Subject: [PATCH] docs --- controller/EmbeddedNetworkController.cpp | 2 +- controller/FileDB.cpp | 9 +++++++-- controller/README.md | 8 +++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index 018f22158..c490055ca 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1097,7 +1097,7 @@ void EmbeddedNetworkController::handleRemoteTrace(const ZT_RemoteTrace &rt) } const int64_t now = OSUtils::now(); - OSUtils::ztsnprintf(id,sizeof(id),"%.10llx-%.10llx-%.16llx-%.8lx",_signingId.address().toInt(),rt.origin,now,++idCounter); + OSUtils::ztsnprintf(id,sizeof(id),"%.10llx-%.16llx-%.10llx-%.4x",_signingId.address().toInt(),now,rt.origin,(unsigned int)(idCounter++ & 0xffff)); d["id"] = id; d["objtype"] = "trace"; d["ts"] = now; diff --git a/controller/FileDB.cpp b/controller/FileDB.cpp index 728cec6b5..3f8564fae 100644 --- a/controller/FileDB.cpp +++ b/controller/FileDB.cpp @@ -27,6 +27,9 @@ FileDB::FileDB(EmbeddedNetworkController *const nc,const Address &myAddress,cons { OSUtils::mkdir(_path.c_str()); OSUtils::lockDownFile(_path.c_str(),true); + OSUtils::mkdir((_path + ZT_PATH_SEPARATOR + "network").c_str()); + OSUtils::mkdir((_path + ZT_PATH_SEPARATOR + "network" + ZT_PATH_SEPARATOR_S + "member").c_str()); + OSUtils::mkdir((_path + ZT_PATH_SEPARATOR + "trace").c_str()); std::vector networks(OSUtils::listDirectory(_networksPath.c_str(),false)); std::string buf; @@ -106,8 +109,10 @@ void FileDB::save(nlohmann::json *orig,nlohmann::json &record) } } else if (objtype == "trace") { const std::string id = rec["id"]; - OSUtils::ztsnprintf(p1,sizeof(p1),"%s" ZT_PATH_SEPARATOR_S "trace" ZT_PATH_SEPARATOR_S "%s.json",_path.c_str(),id.c_str()); - OSUtils::writeFile(p1,OSUtils::jsonDump(rec,-1)); + if (id.length() > 0) { + OSUtils::ztsnprintf(p1,sizeof(p1),"%s" ZT_PATH_SEPARATOR_S "trace" ZT_PATH_SEPARATOR_S "%s.json",_path.c_str(),id.c_str()); + OSUtils::writeFile(p1,OSUtils::jsonDump(rec,-1)); + } } } catch ( ... ) {} // drop invalid records missing fields } diff --git a/controller/README.md b/controller/README.md index a684ed9c8..4521f22b2 100644 --- a/controller/README.md +++ b/controller/README.md @@ -1,7 +1,7 @@ Network Controller Microservice ====== -Every ZeroTier virtual network has a *network controller*. This is our reference implementation and is the same one we use to power our own hosted services at [my.zerotier.com](https://my.zerotier.com/). Network controllers act as configuration servers and certificate authorities for the members of networks. Controllers are located on the network by simply parsing out the first 10 digits of a network's 16-digit network ID: these are the address of the controller. +Every ZeroTier virtual network has a *network controller*. This is our reference controller implementation and is the same one we use to power our own hosted services at [my.zerotier.com](https://my.zerotier.com/). Network controllers act as configuration servers and certificate authorities for the members of networks. Controllers are located on the network by simply parsing out the first 10 digits of a network's 16-digit network ID: these are the address of the controller. As of ZeroTier One version 1.2.0 this code is included in normal builds for desktop, laptop, and server (Linux, etc.) targets, allowing any device to create virtual networks without having to be rebuilt from source with special flags to enable this feature. While this does offer a convenient way to create ad-hoc networks or experiment, we recommend running a dedicated controller somewhere secure and stable for any "serious" use case. @@ -29,6 +29,12 @@ Since ZeroTier nodes are mobile and do not need static IPs, implementing high av ZeroTier network controllers can easily be run in Docker or other container systems. Since containers do not need to actually join networks, extra privilege options like "--device=/dev/net/tun --privileged" are not needed. You'll just need to map the local JSON API port of the running controller and allow it to access the Internet (over UDP/9993 at a minimum) so things can reach and query it. +### About the RethinkDB Connector + +The default controller stores its data in the filesystem. There is also a direct RethinkDB connector that can be built on Linux with `make central-controller`. + +This is designed for use with ZeroTier Central. You are free to build it and use it but don't be surprised if it changes without warning. It shouldn't be considered stable for external use. + ### Network Controller API The controller API is hosted via the same JSON API endpoint that ZeroTier One uses for local control (usually at 127.0.0.1 port 9993). All controller options are routed under the `/controller` base path.