mirror of
https://github.com/ZeroTier/ZeroTierOne
synced 2025-07-16 10:03:14 -07:00
Rename topology/ to be more descriptive, and some more updates.
This commit is contained in:
parent
f0ebb0b0f1
commit
dd58006d65
12 changed files with 14 additions and 19 deletions
48
root-topology/mktopology.cpp
Normal file
48
root-topology/mktopology.cpp
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <map>
|
||||
|
||||
#include "../node/Utils.hpp"
|
||||
#include "../node/Identity.hpp"
|
||||
#include "../node/Dictionary.hpp"
|
||||
|
||||
using namespace ZeroTier;
|
||||
|
||||
int main(int argc,char **argv)
|
||||
{
|
||||
std::string buf;
|
||||
|
||||
if (!Utils::readFile("root-topology-authority.secret",buf)) {
|
||||
std::cerr << "Cannot read root-topology-authority.secret" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
Identity topologyAuthority(buf);
|
||||
|
||||
Dictionary topology;
|
||||
|
||||
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) {
|
||||
if ((sn->first.length() == 10)&&(!sn->second)) {
|
||||
buf.clear();
|
||||
if (!Utils::readFile((std::string("supernodes/")+sn->first).c_str(),buf)) {
|
||||
std::cerr << "Cannot read supernodes/" << sn->first << std::endl;
|
||||
return 1;
|
||||
}
|
||||
supernodes[sn->first] = buf;
|
||||
}
|
||||
}
|
||||
topology["supernodes"] = supernodes.toString();
|
||||
|
||||
if (!topology.sign(topologyAuthority)) {
|
||||
std::cerr << "Unable to sign!" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << topology.toString();
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue