diff options
| author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 11:59:50 -0700 |
|---|---|---|
| committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2014-10-03 11:59:50 -0700 |
| commit | 67aa23530b7e051709002b521aa6e93cb6350918 (patch) | |
| tree | 35d9c8dbd1125279596949479b6e915908c3b358 /node/Node.cpp | |
| parent | 2a58c3fb98c3ff06cf7f5255a13ba4d128f3ce49 (diff) | |
| download | infinitytier-67aa23530b7e051709002b521aa6e93cb6350918.tar.gz infinitytier-67aa23530b7e051709002b521aa6e93cb6350918.zip | |
More work on adding testnet and user-mode capabilities for local network simulation.
Diffstat (limited to 'node/Node.cpp')
| -rw-r--r-- | node/Node.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/node/Node.cpp b/node/Node.cpp index 6682ad25..fd1daab3 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"); |
