summaryrefslogtreecommitdiff
path: root/root-topology
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-09-03 11:56:36 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-09-03 11:56:36 -0700
commitdcea212e40cbd75d009594938553a739c7e4fe29 (patch)
treeabd9e74aab02ddd9704e6210430b5f75adba9fbe /root-topology
parent644db7a04a778d71e19983517941f063710751ec (diff)
downloadinfinitytier-dcea212e40cbd75d009594938553a739c7e4fe29.tar.gz
infinitytier-dcea212e40cbd75d009594938553a739c7e4fe29.zip
Add noupdate flag in root topologies, add ability for mktopology to read from a template.
Diffstat (limited to 'root-topology')
-rw-r--r--root-topology/README.md11
-rw-r--r--root-topology/mktopology.cpp13
2 files changed, 24 insertions, 0 deletions
diff --git a/root-topology/README.md b/root-topology/README.md
index 93942fe6..41b9370c 100644
--- a/root-topology/README.md
+++ b/root-topology/README.md
@@ -1,5 +1,16 @@
This folder contains the source files to compile the signed network root topology dictionary. Users outside ZeroTier won't find this useful except for testing, since the root topology must be signed by the root topology authority (public identity in root-topology-authority.public) to be considered valid.
+Keys in the root topology dictionary are:
+
+ * **supernodes**: contains another Dictionary mapping supernode address to supernode definition
+ * **##########**: supernode address, contains supernode definition
+ * **id**: supernode identity (public) in string-serialized format
+ * **udp**: comma-delimited list of ip/port UDP addresses of node
+ * **tcp**: comma-delimited list of ip/port TCP addresses of node
+ * **desc**: human-readable description (optional)
+ * **dns**: DNS name (optional, not currently used for anything)
+ * **noupdate**: if the value of this is '1', do not auto-update from ZeroTier's servers
+
ZT_DEFAULT_ROOT_TOPOLOGY.c contains the current default value, and this URL is periodically checked for updates:
http://download.zerotier.com/net/topology/ROOT
diff --git a/root-topology/mktopology.cpp b/root-topology/mktopology.cpp
index d6a2be3c..2a551cf7 100644
--- a/root-topology/mktopology.cpp
+++ b/root-topology/mktopology.cpp
@@ -16,6 +16,7 @@ int main(int argc,char **argv)
{
std::string buf;
+ // Read root-topology-authority.secret signing authority, must be symlinked and online
if (!Utils::readFile("root-topology-authority.secret",buf)) {
std::cerr << "Cannot read root-topology-authority.secret" << std::endl;
return 1;
@@ -24,6 +25,14 @@ int main(int argc,char **argv)
Dictionary topology;
+ // Read template.dict to populate default fields in root topology
+ // if this file exists. Otherwise we just start empty.
+ buf.clear();
+ if (Utils::readFile("template.dict",buf))
+ topology.fromString(buf);
+
+ // Read all entries in supernodes/ that correspond to supernode entry dictionaries
+ // and add them to topology under supernodes/ subkey.
Dictionary supernodes;
std::map<std::string,bool> supernodeDictionaries(Utils::listDirectory("supernodes"));
for(std::map<std::string,bool>::iterator sn(supernodeDictionaries.begin());sn!=supernodeDictionaries.end();++sn) {
@@ -38,17 +47,21 @@ int main(int argc,char **argv)
}
topology["supernodes"] = supernodes.toString();
+ // Sign topology with root-topology-authority.secret
if (!topology.sign(topologyAuthority)) {
std::cerr << "Unable to sign!" << std::endl;
return 1;
}
+ // Test signature to make sure signing worked
Dictionary test(topology.toString());
if (!test.verify(topologyAuthority)) {
std::cerr << "Test verification of signed dictionary failed!" << std::endl;
return 1;
}
+ // Output to stdout
std::cout << topology.toString();
+
return 0;
}