summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-21 15:33:35 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-21 15:33:35 -0700
commit29ba34ab7c5a8568f9f4dd6d36320f1a44fcdc50 (patch)
tree20e34a0c47c5e6c5a86df739a55e8b34c16e86af
parent2436e22f46b97b281e5fcf861ba091c9cb70a76f (diff)
downloadinfinitytier-29ba34ab7c5a8568f9f4dd6d36320f1a44fcdc50.tar.gz
infinitytier-29ba34ab7c5a8568f9f4dd6d36320f1a44fcdc50.zip
Kill old testnet stuff, update main.cpp for new SocketManager abstraction.
-rw-r--r--main.cpp41
-rw-r--r--objects.mk3
-rw-r--r--root-topology/local-testnet/root-topology2
-rw-r--r--root-topology/local-testnet/supernodes/0b461c6c903
-rw-r--r--root-topology/local-testnet/supernodes/36944299f23
-rw-r--r--root-topology/local-testnet/supernodes/8fd313ab353
-rw-r--r--root-topology/local-testnet/supernodes/ccc0fa29603
-rwxr-xr-xtestnet/clean-local-testnet.sh7
-rwxr-xr-xtestnet/run-local-testnet.sh58
-rw-r--r--testnet/supernodes/sn0000/identity.public1
-rw-r--r--testnet/supernodes/sn0000/identity.secret1
-rw-r--r--testnet/supernodes/sn0001/identity.public1
-rw-r--r--testnet/supernodes/sn0001/identity.secret1
-rw-r--r--testnet/supernodes/sn0002/identity.public1
-rw-r--r--testnet/supernodes/sn0002/identity.secret1
-rw-r--r--testnet/supernodes/sn0003/identity.public1
-rw-r--r--testnet/supernodes/sn0003/identity.secret1
17 files changed, 20 insertions, 111 deletions
diff --git a/main.cpp b/main.cpp
index 069c82cf..26e20220 100644
--- a/main.cpp
+++ b/main.cpp
@@ -71,12 +71,12 @@
#include "node/CertificateOfMembership.hpp"
#include "node/EthernetTapFactory.hpp"
#include "node/RoutingTable.hpp"
+#include "node/SocketManager.hpp"
#include "control/NodeControlClient.hpp"
#include "control/NodeControlService.hpp"
-#include "testnet/TestEthernetTapFactory.hpp"
-#include "testnet/TestRoutingTable.hpp"
+#include "osnet/NativeSocketManager.hpp"
#ifdef __WINDOWS__
#include "osnet/WindowsEthernetTapFactory.hpp"
@@ -568,8 +568,7 @@ static void printHelp(const char *cn,FILE *out)
fprintf(out," -v - Show version"ZT_EOL_S);
fprintf(out," -p<port> - Port for UDP (default: 9993)"ZT_EOL_S);
fprintf(out," -t<port> - Port for TCP (default: disabled)"ZT_EOL_S);
- fprintf(out," -T<path> - Override root topology, do not authenticate or update"ZT_EOL_S);
- fprintf(out," -u - Do not require root, use dummy tap device"ZT_EOL_S);
+ //fprintf(out," -T<path> - Override root topology, do not authenticate or update"ZT_EOL_S);
#ifdef __UNIX_LIKE__
fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S);
#endif
@@ -626,7 +625,6 @@ int main(int argc,char **argv)
unsigned int tcpPort = 0;
std::string overrideRootTopology;
- bool userMode = false;
#ifdef __UNIX_LIKE__
bool runAsDaemon = false;
#endif
@@ -671,9 +669,6 @@ int main(int argc,char **argv)
return 1;
}
break;
- case 'u':
- userMode = true;
- break;
case 'v':
printf("%s"ZT_EOL_S,Node::versionString());
return 0;
@@ -750,7 +745,7 @@ int main(int argc,char **argv)
homeDir = ZT_DEFAULTS.defaultHomePath.c_str();
#ifdef __UNIX_LIKE__
- if ((!userMode)&&(getuid() != 0)) {
+ if (getuid() != 0) {
fprintf(stderr,"%s: must be run as root (uid 0)\n",argv[0]);
return 1;
}
@@ -782,7 +777,7 @@ int main(int argc,char **argv)
#ifdef __WINDOWS__
if (winRunFromCommandLine) {
// Running in "interactive" mode (mostly for debugging)
- if ((!userMode)&&(IsCurrentUserLocalAdministrator() != TRUE)) {
+ if (IsCurrentUserLocalAdministrator() != TRUE) {
fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]);
return 1;
}
@@ -806,6 +801,7 @@ int main(int argc,char **argv)
bool needsReset = false;
EthernetTapFactory *tapFactory = (EthernetTapFactory *)0;
RoutingTable *routingTable = (RoutingTable *)0;
+ SocketManager *socketManager = (SocketManager *)0;
NodeControlService *controlService = (NodeControlService *)0;
try {
@@ -814,15 +810,17 @@ int main(int argc,char **argv)
// succeed unless something is wrong with the filesystem.
std::string authToken(NodeControlClient::getAuthToken((std::string(homeDir) + ZT_PATH_SEPARATOR_S + "authtoken.secret").c_str(),true));
- if (userMode) {
- tapFactory = new TestEthernetTapFactory();
- routingTable = new TestRoutingTable();
- } else {
- tapFactory = ZTCreatePlatformEthernetTapFactory;
- routingTable = ZTCreatePlatformRoutingTable;
+ tapFactory = ZTCreatePlatformEthernetTapFactory;
+ routingTable = ZTCreatePlatformRoutingTable;
+
+ try {
+ socketManager = new NativeSocketManager(udpPort,tcpPort);
+ } catch ( ... ) {
+ fprintf(stderr,"%s: unable to bind to port: %u/UDP, %u/TCP (0 == disabled)"ZT_EOL_S,argv[0],udpPort,tcpPort);
+ throw;
}
- node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset,(overrideRootTopology.length() > 0) ? overrideRootTopology.c_str() : (const char *)0);
+ node = new Node(homeDir,tapFactory,routingTable,socketManager,needsReset,(overrideRootTopology.length() > 0) ? overrideRootTopology.c_str() : (const char *)0);
controlService = new NodeControlService(node,authToken.c_str());
switch(node->run()) {
@@ -832,11 +830,11 @@ int main(int argc,char **argv)
if (upgPath) {
if (!ZeroTierOneService::doStartUpgrade(std::string(upgPath))) {
exitCode = 3;
- fprintf(stderr,"%s: abnormal termination: unable to execute update at %s (doStartUpgrade failed)\n",argv[0],(upgPath) ? upgPath : "(unknown path)");
+ fprintf(stderr,"%s: abnormal termination: unable to execute update at %s (doStartUpgrade failed)"ZT_EOL_S,argv[0],(upgPath) ? upgPath : "(unknown path)");
}
} else {
exitCode = 3;
- fprintf(stderr,"%s: abnormal termination: unable to execute update at %s (no upgrade path provided)\n",argv[0],(upgPath) ? upgPath : "(unknown path)");
+ fprintf(stderr,"%s: abnormal termination: unable to execute update at %s (no upgrade path provided)"ZT_EOL_S,argv[0],(upgPath) ? upgPath : "(unknown path)");
}
} break;
#else // __UNIX_LIKE__
@@ -854,14 +852,14 @@ int main(int argc,char **argv)
::execl(upgPath,upgPath,(char *)0);
}
exitCode = 3;
- fprintf(stderr,"%s: abnormal termination: unable to execute update at %s\n",argv[0],(upgPath) ? upgPath : "(unknown path)");
+ fprintf(stderr,"%s: abnormal termination: unable to execute update at %s"ZT_EOL_S,argv[0],(upgPath) ? upgPath : "(unknown path)");
} break;
#endif // __WINDOWS__ / __UNIX_LIKE__
case Node::NODE_UNRECOVERABLE_ERROR: {
exitCode = 3;
const char *termReason = node->terminationMessage();
- fprintf(stderr,"%s: abnormal termination: %s\n",argv[0],(termReason) ? termReason : "(unknown reason)");
+ fprintf(stderr,"%s: abnormal termination: %s"ZT_EOL_S,argv[0],(termReason) ? termReason : "(unknown reason)");
} break;
default:
@@ -877,6 +875,7 @@ int main(int argc,char **argv)
delete controlService;
delete node; node = (Node *)0;
+ delete socketManager;
delete routingTable;
delete tapFactory;
diff --git a/objects.mk b/objects.mk
index a64c7e10..eefd302a 100644
--- a/objects.mk
+++ b/objects.mk
@@ -5,9 +5,6 @@ OBJS=\
control/NodeControlService.o \
ext/lz4/lz4.o \
osnet/NativeSocketManager.o \
- testnet/TestEthernetTap.o \
- testnet/TestEthernetTapFactory.o \
- testnet/TestRoutingTable.o \
node/C25519.o \
node/CertificateOfMembership.o \
node/Defaults.o \
diff --git a/root-topology/local-testnet/root-topology b/root-topology/local-testnet/root-topology
deleted file mode 100644
index 07e852ef..00000000
--- a/root-topology/local-testnet/root-topology
+++ /dev/null
@@ -1,2 +0,0 @@
-noupdate=1
-supernodes=0b461c6c90\=id\\\=0b461c6c90:0:f0695a1150937661bc5305c16e331c20e57654794ba1eb3d070449e40594e72d6febdb32b44ac6a366488143a6163486d8ce2494b83e9d0cb7c489c71ae7c2e7\\nudp\\\=127.0.0.1/20002\\ndesc\\\=sn0002\\n\n36944299f2\=id\\\=36944299f2:0:e74012a40b803644d98bbdd15c87d8a8598d3bba70ecf33e9299614cb9e32801dfb4fc3713fd88660fd1085ed4df6a63c9f433fca3f74a1a672358201ea045b6\\nudp\\\=127.0.0.1/20003\\ndesc\\\=sn0003\\n\n8fd313ab35\=id\\\=8fd313ab35:0:4ba3a7cc2ac53b04a73bd211b0856910dc0a4349b4c575d251ec87edc98f2b76cb3dc4784bbf3e2655c83cc691a25b93c6b05afa4e97f70a9ec5d63ca55c7733\\nudp\\\=127.0.0.1/20001\\ndesc\\\=sn0001\\n\nccc0fa2960\=id\\\=ccc0fa2960:0:0ced335940e712c4df8e1603615ace446fbc3587b28ecde54b87bb1e51c305206f58cc8268579fc22f9f49ac3d0aee36351b9509bee339b97b84774823a57046\\nudp\\\=127.0.0.1/20000\\ndesc\\\=sn0000\\n\n
diff --git a/root-topology/local-testnet/supernodes/0b461c6c90 b/root-topology/local-testnet/supernodes/0b461c6c90
deleted file mode 100644
index fb91b4b7..00000000
--- a/root-topology/local-testnet/supernodes/0b461c6c90
+++ /dev/null
@@ -1,3 +0,0 @@
-id=0b461c6c90:0:f0695a1150937661bc5305c16e331c20e57654794ba1eb3d070449e40594e72d6febdb32b44ac6a366488143a6163486d8ce2494b83e9d0cb7c489c71ae7c2e7
-udp=127.0.0.1/20002
-desc=sn0002
diff --git a/root-topology/local-testnet/supernodes/36944299f2 b/root-topology/local-testnet/supernodes/36944299f2
deleted file mode 100644
index 6a484270..00000000
--- a/root-topology/local-testnet/supernodes/36944299f2
+++ /dev/null
@@ -1,3 +0,0 @@
-id=36944299f2:0:e74012a40b803644d98bbdd15c87d8a8598d3bba70ecf33e9299614cb9e32801dfb4fc3713fd88660fd1085ed4df6a63c9f433fca3f74a1a672358201ea045b6
-udp=127.0.0.1/20003
-desc=sn0003
diff --git a/root-topology/local-testnet/supernodes/8fd313ab35 b/root-topology/local-testnet/supernodes/8fd313ab35
deleted file mode 100644
index 12041787..00000000
--- a/root-topology/local-testnet/supernodes/8fd313ab35
+++ /dev/null
@@ -1,3 +0,0 @@
-id=8fd313ab35:0:4ba3a7cc2ac53b04a73bd211b0856910dc0a4349b4c575d251ec87edc98f2b76cb3dc4784bbf3e2655c83cc691a25b93c6b05afa4e97f70a9ec5d63ca55c7733
-udp=127.0.0.1/20001
-desc=sn0001
diff --git a/root-topology/local-testnet/supernodes/ccc0fa2960 b/root-topology/local-testnet/supernodes/ccc0fa2960
deleted file mode 100644
index 371c975a..00000000
--- a/root-topology/local-testnet/supernodes/ccc0fa2960
+++ /dev/null
@@ -1,3 +0,0 @@
-id=ccc0fa2960:0:0ced335940e712c4df8e1603615ace446fbc3587b28ecde54b87bb1e51c305206f58cc8268579fc22f9f49ac3d0aee36351b9509bee339b97b84774823a57046
-udp=127.0.0.1/20000
-desc=sn0000
diff --git a/testnet/clean-local-testnet.sh b/testnet/clean-local-testnet.sh
deleted file mode 100755
index 1d6b7f0d..00000000
--- a/testnet/clean-local-testnet.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-
-export PATH=/bin:/usr/bin:/usr/local/bin
-
-rm -rfv local-testnet/n????
-find local-testnet -type f ! -name 'identity.*' -print0 | xargs -0 rm -fv
-rm -rfv local-testnet/sn????/networks.d
diff --git a/testnet/run-local-testnet.sh b/testnet/run-local-testnet.sh
deleted file mode 100755
index eb0a7053..00000000
--- a/testnet/run-local-testnet.sh
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/bin/bash
-
-export PATH=/bin:/usr/bin:/usr/local/bin
-
-#if [ ! -x ../zerotier-one ]; then
-# echo "$0: ../zerotier-one not found; build first"
-# exit 1
-#fi
-
-if [ $# -lt 1 ]; then
- echo "Usage: $0 <number of regular nodes to create>"
- exit 1
-fi
-
-if [ ! -d ./local-testnet ]; then
- echo "$0: cannot find local-testnet/ base for nodes"
- exit 1
-fi
-
-cd local-testnet
-supernodes=`echo sn????`
-cd ..
-
-create_nodes=$1
-node_num=0
-
-echo "Starting supernodes: $supernodes"
-echo
-
-for sn in $supernodes; do
- node_path=local-testnet/$sn
- node_port=2`echo $sn | cut -d n -f 2`
-
- echo zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path
- ../zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u "$node_path" &
-done
-
-echo
-echo "Starting $create_nodes regular nodes..."
-echo
-
-while [ $node_num -lt $create_nodes ]; do
- node_path=local-testnet/`printf n%.4d $node_num`
- node_port=`printf 3%.4d $node_num`
-
- mkdir -p $node_path
-
- echo zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u $node_path
- ../zerotier-one -T../root-topology/local-testnet/root-topology -p$node_port -u "$node_path" &
-
- node_num=`expr $node_num + 1`
-done
-
-echo
-echo "Nodes are now running. Waiting for all nodes to exit."
-echo
-
-wait
diff --git a/testnet/supernodes/sn0000/identity.public b/testnet/supernodes/sn0000/identity.public
deleted file mode 100644
index 041c7479..00000000
--- a/testnet/supernodes/sn0000/identity.public
+++ /dev/null
@@ -1 +0,0 @@
-ccc0fa2960:0:0ced335940e712c4df8e1603615ace446fbc3587b28ecde54b87bb1e51c305206f58cc8268579fc22f9f49ac3d0aee36351b9509bee339b97b84774823a57046 \ No newline at end of file
diff --git a/testnet/supernodes/sn0000/identity.secret b/testnet/supernodes/sn0000/identity.secret
deleted file mode 100644
index bc404424..00000000
--- a/testnet/supernodes/sn0000/identity.secret
+++ /dev/null
@@ -1 +0,0 @@
-ccc0fa2960:0:0ced335940e712c4df8e1603615ace446fbc3587b28ecde54b87bb1e51c305206f58cc8268579fc22f9f49ac3d0aee36351b9509bee339b97b84774823a57046:dcfb128a5563f26fc94cad1344d2a754853d035d29ca4cbf0e08a632a87a384b4e5dfb2747384b27c1e0260084de9f2f55d5d66c1fa5ab079350b39ffb4df634 \ No newline at end of file
diff --git a/testnet/supernodes/sn0001/identity.public b/testnet/supernodes/sn0001/identity.public
deleted file mode 100644
index e65fcb04..00000000
--- a/testnet/supernodes/sn0001/identity.public
+++ /dev/null
@@ -1 +0,0 @@
-8fd313ab35:0:4ba3a7cc2ac53b04a73bd211b0856910dc0a4349b4c575d251ec87edc98f2b76cb3dc4784bbf3e2655c83cc691a25b93c6b05afa4e97f70a9ec5d63ca55c7733 \ No newline at end of file
diff --git a/testnet/supernodes/sn0001/identity.secret b/testnet/supernodes/sn0001/identity.secret
deleted file mode 100644
index 5eb7b37d..00000000
--- a/testnet/supernodes/sn0001/identity.secret
+++ /dev/null
@@ -1 +0,0 @@
-8fd313ab35:0:4ba3a7cc2ac53b04a73bd211b0856910dc0a4349b4c575d251ec87edc98f2b76cb3dc4784bbf3e2655c83cc691a25b93c6b05afa4e97f70a9ec5d63ca55c7733:14ae15f13dd08e7e2b9862ce01d5816411b6906e3a57c60895498ece36da5c14550e5b389693dd7ec939cddf7ae322fb3e577bb73e296251f32e3ec27db2f015 \ No newline at end of file
diff --git a/testnet/supernodes/sn0002/identity.public b/testnet/supernodes/sn0002/identity.public
deleted file mode 100644
index 2cfe94c5..00000000
--- a/testnet/supernodes/sn0002/identity.public
+++ /dev/null
@@ -1 +0,0 @@
-0b461c6c90:0:f0695a1150937661bc5305c16e331c20e57654794ba1eb3d070449e40594e72d6febdb32b44ac6a366488143a6163486d8ce2494b83e9d0cb7c489c71ae7c2e7 \ No newline at end of file
diff --git a/testnet/supernodes/sn0002/identity.secret b/testnet/supernodes/sn0002/identity.secret
deleted file mode 100644
index 265b070a..00000000
--- a/testnet/supernodes/sn0002/identity.secret
+++ /dev/null
@@ -1 +0,0 @@
-0b461c6c90:0:f0695a1150937661bc5305c16e331c20e57654794ba1eb3d070449e40594e72d6febdb32b44ac6a366488143a6163486d8ce2494b83e9d0cb7c489c71ae7c2e7:bfaaa974483ff53b393b996e93cc7e76b1cb5050fa86c358eb710315965b1afc2d2e8dd62facf3f625c151ee63b1abf011aef75bd3a49d4f5b6f438f3ca77496 \ No newline at end of file
diff --git a/testnet/supernodes/sn0003/identity.public b/testnet/supernodes/sn0003/identity.public
deleted file mode 100644
index cf6df640..00000000
--- a/testnet/supernodes/sn0003/identity.public
+++ /dev/null
@@ -1 +0,0 @@
-36944299f2:0:e74012a40b803644d98bbdd15c87d8a8598d3bba70ecf33e9299614cb9e32801dfb4fc3713fd88660fd1085ed4df6a63c9f433fca3f74a1a672358201ea045b6 \ No newline at end of file
diff --git a/testnet/supernodes/sn0003/identity.secret b/testnet/supernodes/sn0003/identity.secret
deleted file mode 100644
index cadafae1..00000000
--- a/testnet/supernodes/sn0003/identity.secret
+++ /dev/null
@@ -1 +0,0 @@
-36944299f2:0:e74012a40b803644d98bbdd15c87d8a8598d3bba70ecf33e9299614cb9e32801dfb4fc3713fd88660fd1085ed4df6a63c9f433fca3f74a1a672358201ea045b6:c34960bc4f36694dcb629a27dca490cc0fda2776c88a50781cdb54ce9e84dbbe616051e6f04a8185ddf8ef1c8c74e62867ff4cdb029269160f723d400679a1c5 \ No newline at end of file