summaryrefslogtreecommitdiff
path: root/node
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-28 14:17:39 -0700
committerAdam Ierymenko <adam.ierymenko@gmail.com>2014-10-28 14:17:39 -0700
commit3d85a615fb9a50e193eac5320522be409408a3c3 (patch)
tree5c5fbce351cca376d78cf5f0d439345e8d92d262 /node
parentf873881a0ddf2043758b3e7925c95168600f42da (diff)
downloadinfinitytier-3d85a615fb9a50e193eac5320522be409408a3c3.tar.gz
infinitytier-3d85a615fb9a50e193eac5320522be409408a3c3.zip
NULL dereference on still-initializing node bug fix in status query commands, and doc updates.
Diffstat (limited to 'node')
-rw-r--r--node/Node.cpp23
1 files changed, 19 insertions, 4 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 7ca435ae..0758535e 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -702,9 +702,9 @@ bool Node::online()
throw()
{
_NodeImpl *impl = (_NodeImpl *)_impl;
- if (!impl->running)
- return false;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+ if ((!RR)||(!RR->initialized))
+ return false;
uint64_t now = Utils::now();
uint64_t since = RR->timeOfLastResynchronize;
std::vector< SharedPtr<Peer> > snp(RR->topology->supernodePeers());
@@ -753,7 +753,8 @@ void Node::join(uint64_t nwid)
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
- RR->nc->join(nwid);
+ if ((RR)&&(RR->initialized))
+ RR->nc->join(nwid);
}
void Node::leave(uint64_t nwid)
@@ -761,7 +762,8 @@ void Node::leave(uint64_t nwid)
{
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
- RR->nc->leave(nwid);
+ if ((RR)&&(RR->initialized))
+ RR->nc->leave(nwid);
}
struct GatherPeerStatistics
@@ -785,6 +787,9 @@ void Node::status(ZT1_Node_Status *status)
memset(status,0,sizeof(ZT1_Node_Status));
+ if ((!RR)||(!RR->initialized))
+ return;
+
Utils::scopy(status->publicIdentity,sizeof(status->publicIdentity),RR->identity.toString(false).c_str());
RR->identity.address().toString(status->address,sizeof(status->address));
status->rawAddress = RR->identity.address().toInt();
@@ -807,6 +812,7 @@ void Node::status(ZT1_Node_Status *status)
status->online = online();
status->running = impl->running;
+ status->initialized = true;
}
struct CollectPeersAndPaths
@@ -824,6 +830,9 @@ ZT1_Node_PeerList *Node::listPeers()
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+ if ((!RR)||(!RR->initialized))
+ return (ZT1_Node_PeerList *)0;
+
CollectPeersAndPaths pp;
RR->topology->eachPeer<CollectPeersAndPaths &>(pp);
std::sort(pp.data.begin(),pp.data.end(),SortPeersAndPathsInAscendingAddressOrder());
@@ -910,6 +919,9 @@ ZT1_Node_Network *Node::getNetworkStatus(uint64_t nwid)
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+ if ((!RR)||(!RR->initialized))
+ return (ZT1_Node_Network *)0;
+
SharedPtr<Network> network(RR->nc->network(nwid));
if (!network)
return (ZT1_Node_Network *)0;
@@ -950,6 +962,9 @@ ZT1_Node_NetworkList *Node::listNetworks()
_NodeImpl *impl = (_NodeImpl *)_impl;
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
+ if ((!RR)||(!RR->initialized))
+ return (ZT1_Node_NetworkList *)0;
+
std::vector< SharedPtr<Network> > networks(RR->nc->networks());
std::vector< SharedPtr<NetworkConfig> > nconfs(networks.size());
std::vector< std::set<InetAddress> > ipsv(networks.size());