summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-08-07 18:45:11 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-08-07 18:45:11 -0400
commit117f977ce3cfcc20fd63814b2997cbb507495d72 (patch)
treeed522a26999525c9b47cfe47ad3eec8f8ba02db8
parentd8e5d9d6e80d92af31f0017d6f16f41f6de6b869 (diff)
downloadinfinitytier-117f977ce3cfcc20fd63814b2997cbb507495d72.tar.gz
infinitytier-117f977ce3cfcc20fd63814b2997cbb507495d72.zip
mktopology for making new signed topology root server dictionaries
-rwxr-xr-x.gitignore1
-rw-r--r--topology/Makefile5
-rw-r--r--topology/mktopology.cpp54
-rw-r--r--topology/topology.public1
4 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index 96b31582..a9fbc0b3 100755
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,4 @@
.qmake.stash
*.autosave
/ZeroTier One.dmg
+/topology/topology.secret
diff --git a/topology/Makefile b/topology/Makefile
new file mode 100644
index 00000000..abd4081e
--- /dev/null
+++ b/topology/Makefile
@@ -0,0 +1,5 @@
+all:
+ g++ -o mktopology mktopology.cpp ../node/Utils.cpp ../node/Identity.cpp ../node/C25519.cpp ../node/Salsa20.cpp ../node/Dictionary.cpp ../node/SHA512.cpp
+
+clean:
+ rm -f *.o mktopology
diff --git a/topology/mktopology.cpp b/topology/mktopology.cpp
new file mode 100644
index 00000000..630aad7c
--- /dev/null
+++ b/topology/mktopology.cpp
@@ -0,0 +1,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;
+}
diff --git a/topology/topology.public b/topology/topology.public
new file mode 100644
index 00000000..7897b616
--- /dev/null
+++ b/topology/topology.public
@@ -0,0 +1 @@
+77792b1c02:0:b5c361e8e9c2154e82c3e902fdfc337468b092a7c4d8dc685c37eb10ee4f3c17cc0bb1d024167e8cb0824d12263428373582da3d0a9a14b36e4546c317e811e6 \ No newline at end of file