From 5c7cd53f13650c5dc2ef117f0ae70d5760a2214e Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 24 Oct 2014 08:48:44 -0700 Subject: [PATCH] Testnet sort of works! spins up supernodes. --- make-mac.mk | 20 +++++++++----------- testnet.cpp | 15 ++++++++------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/make-mac.mk b/make-mac.mk index 2eced36f9..0ca12c7b2 100644 --- a/make-mac.mk +++ b/make-mac.mk @@ -5,24 +5,29 @@ INCLUDES= DEFS= LIBS= +include objects.mk +OBJS+=osnet/BSDRoutingTable.o osnet/OSXEthernetTap.o osnet/OSXEthernetTapFactory.o +TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o + # Disable codesign since open source users will not have ZeroTier's certs CODESIGN=echo CODESIGN_CERT= ifeq ($(ZT_OFFICIAL_RELEASE),1) + # For use by ZeroTier Networks -- sign with developer cert ZT_AUTO_UPDATE=1 DEFS+=-DZT_OFFICIAL_RELEASE CODESIGN=codesign CODESIGN_CERT="Developer ID Application: ZeroTier Networks LLC (8ZD9JUCZ4V)" endif + ifeq ($(ZT_AUTO_UPDATE),1) DEFS+=-DZT_AUTO_UPDATE endif -# Enable SSE-optimized Salsa20 +# Enable SSE-optimized Salsa20 -- all Intel macs support SSE2 DEFS+=-DZT_SALSA20_SSE -# "make debug" is a shortcut for this ifeq ($(ZT_DEBUG),1) # DEFS+=-DZT_TRACE -DZT_LOG_STDOUT CFLAGS=-Wall -g -pthread $(INCLUDES) $(DEFS) @@ -37,10 +42,6 @@ endif CXXFLAGS=$(CFLAGS) -fno-rtti -include objects.mk -OBJS+=osnet/BSDRoutingTable.o osnet/OSXEthernetTap.o osnet/OSXEthernetTapFactory.o -TESTNET_OBJS=testnet/SimNet.o testnet/SimNetSocketManager.o testnet/TestEthernetTap.o testnet/TestEthernetTapFactory.o testnet/TestRoutingTable.o - all: one one: $(OBJS) main.o @@ -53,7 +54,7 @@ selftest: $(OBJS) sefltest.o $(CXX) $(CXXFLAGS) -o zerotier-selftest selftest.o $(OBJS) $(LIBS) $(STRIP) zerotier-selftest -testnet: $(OBJS) $(TESTNET_OBJS) testnet.o +testnet: $(TESTNET_OBJS) $(OBJS) testnet.o $(CXX) $(CXXFLAGS) -o zerotier-testnet testnet.o $(OBJS) $(TESTNET_OBJS) $(LIBS) $(STRIP) zerotier-testnet @@ -67,10 +68,7 @@ mac-ui: FORCE $(CODESIGN) -vvv "build-ZeroTierUI-release/ZeroTier One.app" clean: - rm -rf *.dSYM testnet.o selftest.o build-* $(OBJS) $(TEST_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg" - -debug: FORCE - make -j 4 ZT_DEBUG=1 + rm -rf *.dSYM testnet.o selftest.o build-* $(OBJS) $(TESTNET_OBJS) zerotier-* ZeroTierOneInstaller-* "ZeroTier One.zip" "ZeroTier One.dmg" # For our use -- builds official signed binary, packages in installer and download DMG official: FORCE diff --git a/testnet.cpp b/testnet.cpp index df70e40e0..2dae87b93 100644 --- a/testnet.cpp +++ b/testnet.cpp @@ -40,6 +40,7 @@ #include "node/Identity.hpp" #include "node/Thread.hpp" #include "node/CMWC4096.hpp" +#include "node/Dictionary.hpp" #include "testnet/SimNet.hpp" #include "testnet/SimNetSocketManager.hpp" @@ -136,9 +137,9 @@ static Identity makeNodeHome(bool super) mkdir(path.c_str(),0700); #endif - if (!Utils::writeFile((path + ZT_PATH_SEPARATOR_S + "identity.secret"),id.toString(true))) + if (!Utils::writeFile((path + ZT_PATH_SEPARATOR_S + "identity.secret").c_str(),id.toString(true))) return Identity(); - if (!Utils::writeFile((path + ZT_PATH_SEPARATOR_S + "identity.public"),id.toString(false))) + if (!Utils::writeFile((path + ZT_PATH_SEPARATOR_S + "identity.public").c_str(),id.toString(false))) return Identity(); return id; @@ -180,8 +181,8 @@ static std::vector
initSupernodes() for(std::vector< std::pair >::iterator i(snids.begin());i!=snids.end();++i) { SimNode *n = new SimNode(net,(basePath + ZT_PATH_SEPARATOR_S + "S" + i->first.address().toString()),rootTopology.c_str(),true,i->second); - nodes[id.address()] = n; - newNodes.push_back(id.address()); + nodes[i->first.address()] = n; + newNodes.push_back(i->first.address()); } return newNodes; @@ -221,7 +222,7 @@ static void doHelp(const std::vector &cmd) printf("---------- listnetworks
"ZT_EOL_S); printf("---------- listpeers
"ZT_EOL_S); printf("---------- alltoall"ZT_EOL_S); - printf("---------- quit"ZT_EOL_S) + printf("---------- quit"ZT_EOL_S); } static void doMKSN(const std::vector &cmd) @@ -231,7 +232,7 @@ static void doMKSN(const std::vector &cmd) return; } if (nodes.size() > 0) { - printf("---------- mksn error: mksn can only be called once (network already exists)"ZT_EOL_S,(unsigned int)nodes.size()); + printf("---------- mksn error: mksn can only be called once (network already exists)"ZT_EOL_S); return; } @@ -304,7 +305,7 @@ int main(int argc,char **argv) printf(ZT_EOL_S); { - printf("---------- scanning '%s' for existing network..."ZT_EOL_S); + printf("---------- scanning '%s' for existing network..."ZT_EOL_S,basePath.c_str()); std::vector
snodes(initSupernodes()); if (snodes.empty()) { printf("---------- no existing network found; use 'mksn' to create one."ZT_EOL_S);