mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-08-21 13:54:15 -07:00
Add noupdate flag in root topologies, add ability for mktopology to read from a template.
This commit is contained in:
parent
644db7a04a
commit
dcea212e40
3 changed files with 43 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue