blob: 630aad7ce87391403e99427dfc3ed778ed6ffb20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
/* Makes topology dictionary out of source dictionary and signs with
* 'topology.secret', which must be present (or symlinked) from where
* this is run. */
/* Just type 'make' and then run (Only tested on Linux) */
#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("topology.secret",buf)) {
std::cout << "Cannot read topology.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::cout << "Cannot read supernodes/" << sn->first << std::endl;
return 1;
}
supernodes[sn->first] = buf;
}
}
topology["supernodes"] = supernodes.toString();
if (!topology.sign(topologyAuthority)) {
std::cout << "Unable to sign!" << std::endl;
return 1;
}
std::cout << topology.toString();
return 0;
}
|