From 67aa23530b7e051709002b521aa6e93cb6350918 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Fri, 3 Oct 2014 11:59:50 -0700 Subject: [PATCH] More work on adding testnet and user-mode capabilities for local network simulation. --- main.cpp | 37 +++++++++++-- {testnet => node}/Condition.hpp | 8 +-- node/EthernetTap.hpp | 15 ++++++ node/Node.cpp | 23 ++++++-- node/Node.hpp | 4 +- objects.mk | 3 ++ osnet/LinuxEthernetTap.cpp | 5 ++ osnet/LinuxEthernetTap.hpp | 1 + osnet/OSXEthernetTap.cpp | 5 ++ osnet/OSXEthernetTap.hpp | 1 + osnet/WindowsEthernetTap.cpp | 5 ++ osnet/WindowsEthernetTap.hpp | 1 + .../{testnet => local-testnet}/root-topology | 0 .../supernodes/0b461c6c90 | 0 .../supernodes/36944299f2 | 0 .../supernodes/8fd313ab35 | 0 .../supernodes/ccc0fa2960 | 0 .../{testnet => local-testnet}/template.dict | 0 testnet/TestEthernetTap.cpp | 53 +++++++++++++++++-- testnet/TestEthernetTap.hpp | 26 +++------ testnet/TestEthernetTapFactory.hpp | 3 +- testnet/TestRoutingTable.cpp | 50 +++++++++++++++++ testnet/TestRoutingTable.hpp | 50 +++++++++++++++++ .../sn0000/identity.public | 0 .../sn0000/identity.secret | 0 .../sn0001/identity.public | 0 .../sn0001/identity.secret | 0 .../sn0002/identity.public | 0 .../sn0002/identity.secret | 0 .../sn0003/identity.public | 0 .../sn0003/identity.secret | 0 31 files changed, 251 insertions(+), 39 deletions(-) rename {testnet => node}/Condition.hpp (95%) rename root-topology/{testnet => local-testnet}/root-topology (100%) rename root-topology/{testnet => local-testnet}/supernodes/0b461c6c90 (100%) rename root-topology/{testnet => local-testnet}/supernodes/36944299f2 (100%) rename root-topology/{testnet => local-testnet}/supernodes/8fd313ab35 (100%) rename root-topology/{testnet => local-testnet}/supernodes/ccc0fa2960 (100%) rename root-topology/{testnet => local-testnet}/template.dict (100%) create mode 100644 testnet/TestRoutingTable.cpp create mode 100644 testnet/TestRoutingTable.hpp rename testnet/{nodes => local-testnet}/sn0000/identity.public (100%) rename testnet/{nodes => local-testnet}/sn0000/identity.secret (100%) rename testnet/{nodes => local-testnet}/sn0001/identity.public (100%) rename testnet/{nodes => local-testnet}/sn0001/identity.secret (100%) rename testnet/{nodes => local-testnet}/sn0002/identity.public (100%) rename testnet/{nodes => local-testnet}/sn0002/identity.secret (100%) rename testnet/{nodes => local-testnet}/sn0003/identity.public (100%) rename testnet/{nodes => local-testnet}/sn0003/identity.secret (100%) diff --git a/main.cpp b/main.cpp index e6fc11272..52f1eed07 100644 --- a/main.cpp +++ b/main.cpp @@ -75,6 +75,9 @@ #include "control/NodeControlClient.hpp" #include "control/NodeControlService.hpp" +#include "testnet/TestEthernetTapFactory.hpp" +#include "testnet/TestRoutingTable.hpp" + #ifdef __WINDOWS__ #include "osnet/WindowsEthernetTapFactory.hpp" #include "osnet/WindowsRoutingTable.hpp" @@ -564,6 +567,8 @@ static void printHelp(const char *cn,FILE *out) fprintf(out," -v - Show version"ZT_EOL_S); fprintf(out," -p - Port for UDP (default: 9993)"ZT_EOL_S); fprintf(out," -t - Port for TCP (default: disabled)"ZT_EOL_S); + fprintf(out," -T - 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); #ifdef __UNIX_LIKE__ fprintf(out," -d - Fork and run as daemon (Unix-ish OSes)"ZT_EOL_S); #endif @@ -619,6 +624,8 @@ int main(int argc,char **argv) unsigned int udpPort = ZT_DEFAULT_UDP_PORT; unsigned int tcpPort = 0; + std::string overrideRootTopology; + bool userMode = false; #ifdef __UNIX_LIKE__ bool runAsDaemon = false; #endif @@ -652,6 +659,20 @@ int main(int argc,char **argv) runAsDaemon = true; break; #endif + case 'T': + if (argv[i][2]) { + if (!Utils::readFile(argv[i] + 2,overrideRootTopology)) { + fprintf(stderr,"%s: cannot read root topology from %s"ZT_EOL_S,argv[0],argv[i] + 2); + return 1; + } + } else { + printHelp(argv[0],stdout); + return 1; + } + break; + case 'u': + userMode = true; + break; case 'v': printf("%s"ZT_EOL_S,Node::versionString()); return 0; @@ -728,7 +749,7 @@ int main(int argc,char **argv) homeDir = ZT_DEFAULTS.defaultHomePath.c_str(); #ifdef __UNIX_LIKE__ - if (getuid() != 0) { + if ((!userMode)&&(getuid() != 0)) { fprintf(stderr,"%s: must be run as root (uid 0)\n",argv[0]); return 1; } @@ -758,17 +779,18 @@ int main(int argc,char **argv) #endif // __UNIX_LIKE__ #ifdef __WINDOWS__ - _winPokeAHole(); if (winRunFromCommandLine) { // Running in "interactive" mode (mostly for debugging) - if (IsCurrentUserLocalAdministrator() != TRUE) { + if ((!userMode)&&(IsCurrentUserLocalAdministrator() != TRUE)) { fprintf(stderr,"%s: must be run as a local administrator."ZT_EOL_S,argv[0]); return 1; } + _winPokeAHole(); SetConsoleCtrlHandler(&_winConsoleCtrlHandler,TRUE); // continues on to ordinary command line execution code below... } else { // Running from service manager + _winPokeAHole(); ZeroTierOneService zt1Service; if (CServiceBase::Run(zt1Service) == TRUE) { return 0; @@ -791,8 +813,13 @@ 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)); - tapFactory = ZTCreatePlatformEthernetTapFactory; - routingTable = ZTCreatePlatformRoutingTable; + if (userMode) { + tapFactory = new TestEthernetTapFactory(); + routingTable = new TestRoutingTable(); + } else { + tapFactory = ZTCreatePlatformEthernetTapFactory; + routingTable = ZTCreatePlatformRoutingTable; + } node = new Node(homeDir,tapFactory,routingTable,udpPort,tcpPort,needsReset); controlService = new NodeControlService(node,authToken.c_str()); diff --git a/testnet/Condition.hpp b/node/Condition.hpp similarity index 95% rename from testnet/Condition.hpp rename to node/Condition.hpp index 89d3a5315..3895f4df7 100644 --- a/testnet/Condition.hpp +++ b/node/Condition.hpp @@ -28,15 +28,15 @@ #ifndef ZT_CONDITION_HPP #define ZT_CONDITION_HPP -#include "../node/Constants.hpp" -#include "../node/NonCopyable.hpp" +#include "Constants.hpp" +#include "NonCopyable.hpp" #ifdef __WINDOWS__ #include #include -#include "../node/Utils.hpp" +#include "Utils.hpp" namespace ZeroTier { @@ -83,7 +83,7 @@ private: #include #include #include -#include "../node/Utils.hpp" +#include "Utils.hpp" namespace ZeroTier { diff --git a/node/EthernetTap.hpp b/node/EthernetTap.hpp index 0980d2c09..132e5c208 100644 --- a/node/EthernetTap.hpp +++ b/node/EthernetTap.hpp @@ -152,6 +152,21 @@ public: */ virtual bool updateMulticastGroups(std::set &groups) = 0; + /** + * Inject a packet as if it was sent by the host, if supported + * + * This is for testing and is typically not supported by real TAP devices. + * It's implemented by TestEthernetTap in testnet. + * + * @param from Source MAC + * @param to Destination MAC + * @param etherType Ethernet frame type + * @param data Packet data + * @param len Packet length + * @return False if not supported or packet too large + */ + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) = 0; + protected: const char *_implName; MAC _mac; diff --git a/node/Node.cpp b/node/Node.cpp index 6682ad25e..fd1daab3f 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -93,6 +93,7 @@ struct _NodeImpl volatile bool running; volatile bool resynchronize; volatile bool disableRootTopologyUpdates; + std::string overrideRootTopology; // This function performs final node tear-down inline Node::ReasonForTermination terminate() @@ -223,8 +224,8 @@ Node::Node( RoutingTable *rt, unsigned int udpPort, unsigned int tcpPort, - bool resetIdentity) - throw() : + bool resetIdentity, + const char *overrideRootTopology) throw() : _impl(new _NodeImpl) { _NodeImpl *impl = (_NodeImpl *)_impl; @@ -260,7 +261,13 @@ Node::Node( impl->started = false; impl->running = false; impl->resynchronize = false; - impl->disableRootTopologyUpdates = false; + + if (overrideRootTopology) { + impl->disableRootTopologyUpdates = true; + impl->overrideRootTopology = overrideRootTopology; + } else { + impl->disableRootTopologyUpdates = false; + } } Node::~Node() @@ -403,7 +410,7 @@ Node::ReasonForTermination Node::run() #endif // Initialize root topology from defaults or root-toplogy file in home path on disk - { + if (impl->overrideRootTopology.length() == 0) { std::string rootTopologyPath(RR->homePath + ZT_PATH_SEPARATOR_S + "root-topology"); std::string rootTopology; if (!Utils::readFile(rootTopologyPath.c_str(),rootTopology)) @@ -427,6 +434,14 @@ Node::ReasonForTermination Node::run() } catch ( ... ) { return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"invalid root-topology format"); } + } else { + try { + Dictionary rt(impl->overrideRootTopology); + RR->topology->setSupernodes(Dictionary(rt.get("supernodes",""))); + impl->disableRootTopologyUpdates = true; + } catch ( ... ) { + return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"invalid root-topology format"); + } } } catch (std::bad_alloc &exc) { return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"memory allocation failure"); diff --git a/node/Node.hpp b/node/Node.hpp index 323423492..858a37372 100644 --- a/node/Node.hpp +++ b/node/Node.hpp @@ -88,6 +88,7 @@ public: * @param udpPort UDP port or 0 to disable * @param tcpPort TCP port or 0 to disable * @param resetIdentity If true, delete identity before starting and regenerate + * @param overrideRootTopology Override root topology with this dictionary (in string serialized format) and do not update (default: NULL for none) */ Node( const char *hp, @@ -95,7 +96,8 @@ public: RoutingTable *rt, unsigned int udpPort, unsigned int tcpPort, - bool resetIdentity) throw(); + bool resetIdentity, + const char *overrideRootTopology = (const char *)0) throw(); ~Node(); diff --git a/objects.mk b/objects.mk index 9f0492154..8c6867448 100644 --- a/objects.mk +++ b/objects.mk @@ -4,6 +4,9 @@ OBJS=\ control/NodeControlClient.o \ control/NodeControlService.o \ ext/lz4/lz4.o \ + testnet/TestEthernetTap.o \ + testnet/TestEthernetTapFactory.o \ + testnet/TestRoutingTable.o \ node/C25519.o \ node/CertificateOfMembership.o \ node/Defaults.o \ diff --git a/osnet/LinuxEthernetTap.cpp b/osnet/LinuxEthernetTap.cpp index 1bd066c3e..955048e75 100644 --- a/osnet/LinuxEthernetTap.cpp +++ b/osnet/LinuxEthernetTap.cpp @@ -361,6 +361,11 @@ bool LinuxEthernetTap::updateMulticastGroups(std::set &groups) return changed; } +bool LinuxEthernetTap::injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) +{ + return false; +} + void LinuxEthernetTap::threadMain() throw() { diff --git a/osnet/LinuxEthernetTap.hpp b/osnet/LinuxEthernetTap.hpp index 0dfb504b8..b34a64ef8 100644 --- a/osnet/LinuxEthernetTap.hpp +++ b/osnet/LinuxEthernetTap.hpp @@ -65,6 +65,7 @@ public: virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); virtual bool updateMulticastGroups(std::set &groups); + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); void threadMain() throw(); diff --git a/osnet/OSXEthernetTap.cpp b/osnet/OSXEthernetTap.cpp index 6164358d4..950877dbf 100644 --- a/osnet/OSXEthernetTap.cpp +++ b/osnet/OSXEthernetTap.cpp @@ -576,6 +576,11 @@ bool OSXEthernetTap::updateMulticastGroups(std::set &groups) return changed; } +bool OSXEthernetTap::injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) +{ + return false; +} + void OSXEthernetTap::threadMain() throw() { diff --git a/osnet/OSXEthernetTap.hpp b/osnet/OSXEthernetTap.hpp index 3ac8df84b..c9ee316ce 100644 --- a/osnet/OSXEthernetTap.hpp +++ b/osnet/OSXEthernetTap.hpp @@ -69,6 +69,7 @@ public: virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); virtual bool updateMulticastGroups(std::set &groups); + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); void threadMain() throw(); diff --git a/osnet/WindowsEthernetTap.cpp b/osnet/WindowsEthernetTap.cpp index fb9780719..e6c49f943 100644 --- a/osnet/WindowsEthernetTap.cpp +++ b/osnet/WindowsEthernetTap.cpp @@ -527,6 +527,11 @@ bool WindowsEthernetTap::updateMulticastGroups(std::set &groups) return changed; } +bool WindowsEthernetTap::injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) +{ + return false; +} + void WindowsEthernetTap::threadMain() throw() { diff --git a/osnet/WindowsEthernetTap.hpp b/osnet/WindowsEthernetTap.hpp index e5f5e4b26..55e18c80e 100644 --- a/osnet/WindowsEthernetTap.hpp +++ b/osnet/WindowsEthernetTap.hpp @@ -71,6 +71,7 @@ public: virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); virtual bool updateMulticastGroups(std::set &groups); + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); inline const NET_LUID &luid() const { return _deviceLuid; } inline const GUID &guid() const { return _deviceGuid; } diff --git a/root-topology/testnet/root-topology b/root-topology/local-testnet/root-topology similarity index 100% rename from root-topology/testnet/root-topology rename to root-topology/local-testnet/root-topology diff --git a/root-topology/testnet/supernodes/0b461c6c90 b/root-topology/local-testnet/supernodes/0b461c6c90 similarity index 100% rename from root-topology/testnet/supernodes/0b461c6c90 rename to root-topology/local-testnet/supernodes/0b461c6c90 diff --git a/root-topology/testnet/supernodes/36944299f2 b/root-topology/local-testnet/supernodes/36944299f2 similarity index 100% rename from root-topology/testnet/supernodes/36944299f2 rename to root-topology/local-testnet/supernodes/36944299f2 diff --git a/root-topology/testnet/supernodes/8fd313ab35 b/root-topology/local-testnet/supernodes/8fd313ab35 similarity index 100% rename from root-topology/testnet/supernodes/8fd313ab35 rename to root-topology/local-testnet/supernodes/8fd313ab35 diff --git a/root-topology/testnet/supernodes/ccc0fa2960 b/root-topology/local-testnet/supernodes/ccc0fa2960 similarity index 100% rename from root-topology/testnet/supernodes/ccc0fa2960 rename to root-topology/local-testnet/supernodes/ccc0fa2960 diff --git a/root-topology/testnet/template.dict b/root-topology/local-testnet/template.dict similarity index 100% rename from root-topology/testnet/template.dict rename to root-topology/local-testnet/template.dict diff --git a/testnet/TestEthernetTap.cpp b/testnet/TestEthernetTap.cpp index 421d6650c..f3273d00f 100644 --- a/testnet/TestEthernetTap.cpp +++ b/testnet/TestEthernetTap.cpp @@ -27,10 +27,23 @@ #include "TestEthernetTap.hpp" #include "TestEthernetTapFactory.hpp" + +#include "../node/Constants.hpp" #include "../node/Utils.hpp" +#include +#include + +#ifdef __WINDOWS__ +#include +#else +#include +#endif + namespace ZeroTier { +static Mutex printLock; + TestEthernetTap::TestEthernetTap( TestEthernetTapFactory *parent, const MAC &mac, @@ -47,9 +60,19 @@ TestEthernetTap::TestEthernetTap( _arg(arg), _enabled(true) { + static volatile unsigned int testTapCounter = 0; + char tmp[64]; - Utils::snprintf(tmp,sizeof(tmp),"%.16llx",(unsigned long long)nwid); + int pid = 0; +#ifdef __UNIX_LIKE__ + pid = (int)getpid(); +#endif +#ifdef __WINDOWS__ + pid = (int)_getpid(); +#endif + Utils::snprintf(tmp,sizeof(tmp),"test%dtap%d",pid,testTapCounter++); _dev = tmp; + _thread = Thread::start(this); } @@ -57,7 +80,7 @@ TestEthernetTap::~TestEthernetTap() { { Mutex::Lock _l(_pq_m); - _pq.push(TestFrame()); // 0-length frame = exit + _pq.push(TestFrame()); // 0 length frame = exit } _pq_c.signal(); Thread::join(_thread); @@ -90,9 +113,9 @@ std::set TestEthernetTap::ips() const void TestEthernetTap::put(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) { - static Mutex printLock; Mutex::Lock _l(printLock); - fprintf(stderr,"%s << %s %.4x %s"ZT_EOL_S,to.toString().c_str(),from.toString().c_str(),etherType,std::string((const char *)data,len).c_str()); + fprintf(stdout,"[%s] %s << %s %.4x %s"ZT_EOL_S,_dev.c_str(),to.toString().c_str(),from.toString().c_str(),etherType,std::string((const char *)data,len).c_str()); + fflush(stdout); } std::string TestEthernetTap::deviceName() const @@ -109,6 +132,26 @@ bool TestEthernetTap::updateMulticastGroups(std::set &groups) return false; } +bool TestEthernetTap::injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len) +{ + if ((len == 0)||(len > 2800)) + return false; + + { + Mutex::Lock _l(_pq_m); + _pq.push(TestFrame(from,to,data,etherType & 0xffff,len)); + } + _pq_c.signal(); + + { + Mutex::Lock _l(printLock); + fprintf(stdout,"[%s] %s >> %s %.4x %s"ZT_EOL_S,_dev.c_str(),from.toString().c_str(),to.toString().c_str(),etherType,std::string((const char *)data,len).c_str()); + fflush(stdout); + } + + return true; +} + void TestEthernetTap::threadMain() throw() { @@ -126,7 +169,7 @@ void TestEthernetTap::threadMain() } if ((tf.len > 0)&&(_enabled)) - _handler(_arg,tf.from,tf.to,ZT_TEST_ETHERNET_ETHERTYPE,Buffer<4096>(tf.data,tf.len)); + _handler(_arg,tf.from,tf.to,tf.etherType,Buffer<4096>(tf.data,tf.len)); _pq_c.wait(); } diff --git a/testnet/TestEthernetTap.hpp b/testnet/TestEthernetTap.hpp index c1e9c720a..93eb4c5bb 100644 --- a/testnet/TestEthernetTap.hpp +++ b/testnet/TestEthernetTap.hpp @@ -36,15 +36,13 @@ #include #include +#include "../node/Constants.hpp" +#include "../node/EthernetTap.hpp" #include "../node/AtomicCounter.hpp" #include "../node/SharedPtr.hpp" -#include "../node/EthernetTap.hpp" #include "../node/Thread.hpp" #include "../node/Mutex.hpp" -#include "Condition.hpp" - -// Ethernet frame type to use on fake testnet -#define ZT_TEST_ETHERNET_ETHERTYPE 0xdead +#include "../node/Condition.hpp" namespace ZeroTier { @@ -57,16 +55,18 @@ class TestEthernetTap : public EthernetTap private: struct TestFrame { - TestFrame() : len(0) {} - TestFrame(const MAC &f,const MAC &t,const void *d,unsigned int l) : + TestFrame() : etherType(0),len(0) {} + TestFrame(const MAC &f,const MAC &t,const void *d,unsigned int et,unsigned int l) : from(f), to(t), + etherType(et), len(l) { memcpy(data,d,l); } MAC from; MAC to; + unsigned int etherType; unsigned int len; char data[4096]; }; @@ -94,21 +94,11 @@ public: virtual std::string deviceName() const; virtual void setFriendlyName(const char *friendlyName); virtual bool updateMulticastGroups(std::set &groups); + virtual bool injectPacketFromHost(const MAC &from,const MAC &to,unsigned int etherType,const void *data,unsigned int len); void threadMain() throw(); - inline void sendFromHost(const MAC &from,const MAC &to,const void *data,unsigned int len) - { - if (!len) - return; - { - Mutex::Lock _l(_pq_m); - _pq.push(TestFrame(from,to,data,len)); - } - _pq_c.signal(); - } - private: TestEthernetTapFactory *_parent; diff --git a/testnet/TestEthernetTapFactory.hpp b/testnet/TestEthernetTapFactory.hpp index caceec067..5327b844a 100644 --- a/testnet/TestEthernetTapFactory.hpp +++ b/testnet/TestEthernetTapFactory.hpp @@ -37,11 +37,10 @@ #include "../node/Mutex.hpp" #include "../node/MAC.hpp" #include "../node/CMWC4096.hpp" +#include "TestEthernetTap.hpp" namespace ZeroTier { -class TestEthernetTap; - class TestEthernetTapFactory : public EthernetTapFactory { public: diff --git a/testnet/TestRoutingTable.cpp b/testnet/TestRoutingTable.cpp new file mode 100644 index 000000000..8c132693e --- /dev/null +++ b/testnet/TestRoutingTable.cpp @@ -0,0 +1,50 @@ +/* + * ZeroTier One - Global Peer to Peer Ethernet + * Copyright (C) 2011-2014 ZeroTier Networks LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +#include "TestRoutingTable.hpp" + +namespace ZeroTier { + +TestRoutingTable::TestRoutingTable() +{ +} + +TestRoutingTable::~TestRoutingTable() +{ +} + +std::vector TestRoutingTable::get(bool includeLinkLocal,bool includeLoopback) const +{ + return std::vector(); +} + +RoutingTable::Entry TestRoutingTable::set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric) +{ + return RoutingTable::Entry(); +} + +} // namespace ZeroTier diff --git a/testnet/TestRoutingTable.hpp b/testnet/TestRoutingTable.hpp new file mode 100644 index 000000000..983902019 --- /dev/null +++ b/testnet/TestRoutingTable.hpp @@ -0,0 +1,50 @@ +/* + * ZeroTier One - Global Peer to Peer Ethernet + * Copyright (C) 2011-2014 ZeroTier Networks LLC + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * -- + * + * ZeroTier may be used and distributed under the terms of the GPLv3, which + * are available at: http://www.gnu.org/licenses/gpl-3.0.html + * + * If you would like to embed ZeroTier into a commercial application or + * redistribute it in a modified binary form, please contact ZeroTier Networks + * LLC. Start here: http://www.zerotier.com/ + */ + +#ifndef ZT_TESTROUTINGTABLE_HPP +#define ZT_TESTROUTINGTABLE_HPP + +#include "../node/RoutingTable.hpp" + +namespace ZeroTier { + +/** + * Dummy routing table -- right now this just does nothing + */ +class TestRoutingTable : public RoutingTable +{ +public: + TestRoutingTable(); + virtual ~TestRoutingTable(); + + virtual std::vector get(bool includeLinkLocal = false,bool includeLoopback = false) const; + virtual RoutingTable::Entry set(const InetAddress &destination,const InetAddress &gateway,const char *device,int metric); +}; + +} // namespace ZeroTier + +#endif diff --git a/testnet/nodes/sn0000/identity.public b/testnet/local-testnet/sn0000/identity.public similarity index 100% rename from testnet/nodes/sn0000/identity.public rename to testnet/local-testnet/sn0000/identity.public diff --git a/testnet/nodes/sn0000/identity.secret b/testnet/local-testnet/sn0000/identity.secret similarity index 100% rename from testnet/nodes/sn0000/identity.secret rename to testnet/local-testnet/sn0000/identity.secret diff --git a/testnet/nodes/sn0001/identity.public b/testnet/local-testnet/sn0001/identity.public similarity index 100% rename from testnet/nodes/sn0001/identity.public rename to testnet/local-testnet/sn0001/identity.public diff --git a/testnet/nodes/sn0001/identity.secret b/testnet/local-testnet/sn0001/identity.secret similarity index 100% rename from testnet/nodes/sn0001/identity.secret rename to testnet/local-testnet/sn0001/identity.secret diff --git a/testnet/nodes/sn0002/identity.public b/testnet/local-testnet/sn0002/identity.public similarity index 100% rename from testnet/nodes/sn0002/identity.public rename to testnet/local-testnet/sn0002/identity.public diff --git a/testnet/nodes/sn0002/identity.secret b/testnet/local-testnet/sn0002/identity.secret similarity index 100% rename from testnet/nodes/sn0002/identity.secret rename to testnet/local-testnet/sn0002/identity.secret diff --git a/testnet/nodes/sn0003/identity.public b/testnet/local-testnet/sn0003/identity.public similarity index 100% rename from testnet/nodes/sn0003/identity.public rename to testnet/local-testnet/sn0003/identity.public diff --git a/testnet/nodes/sn0003/identity.secret b/testnet/local-testnet/sn0003/identity.secret similarity index 100% rename from testnet/nodes/sn0003/identity.secret rename to testnet/local-testnet/sn0003/identity.secret