2014-08-07 22:45:11 +00:00
|
|
|
#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;
|
|
|
|
|
2014-08-08 00:21:07 +00:00
|
|
|
if (!Utils::readFile("root-topology-authority.secret",buf)) {
|
|
|
|
std::cerr << "Cannot read root-topology-authority.secret" << std::endl;
|
2014-08-07 22:45:11 +00:00
|
|
|
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)) {
|
2014-08-08 00:14:24 +00:00
|
|
|
std::cerr << "Cannot read supernodes/" << sn->first << std::endl;
|
2014-08-07 22:45:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
supernodes[sn->first] = buf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
topology["supernodes"] = supernodes.toString();
|
|
|
|
|
|
|
|
if (!topology.sign(topologyAuthority)) {
|
2014-08-08 00:14:24 +00:00
|
|
|
std::cerr << "Unable to sign!" << std::endl;
|
2014-08-07 22:45:11 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << topology.toString();
|
|
|
|
return 0;
|
|
|
|
}
|