summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp23
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");