summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2016-11-18 13:48:49 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2016-11-18 13:48:49 -0800
commit673c0c811ea443c217b3a4ca17eeaed3ab596501 (patch)
tree895d71285505546a1dffedb9ca37c32a491535eb /node/Node.cpp
parent6e1da35c121c9a01ee4a487462660a5d7d3503a2 (diff)
downloadinfinitytier-673c0c811ea443c217b3a4ca17eeaed3ab596501.tar.gz
infinitytier-673c0c811ea443c217b3a4ca17eeaed3ab596501.zip
Wire through upstream stuff and add setRole().
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index ec719668..3d15f5bc 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -412,7 +412,7 @@ ZT_PeerList *Node::peers() const
p->versionRev = -1;
}
p->latency = pi->second->latency();
- p->role = RR->topology->isRoot(pi->second->identity()) ? ZT_PEER_ROLE_ROOT : ZT_PEER_ROLE_LEAF;
+ p->role = RR->topology->isRoot(pi->second->identity()) ? ZT_PEER_ROLE_ROOT : (RR->topology->isUpstream(pi->second->identity()) ? ZT_PEER_ROLE_UPSTREAM : ZT_PEER_ROLE_LEAF);
std::vector< std::pair< SharedPtr<Path>,bool > > paths(pi->second->paths(_now));
SharedPtr<Path> bestp(pi->second->getBestPath(_now,false));
@@ -484,6 +484,11 @@ void Node::clearLocalInterfaceAddresses()
_directPaths.clear();
}
+void Node::setRole(uint64_t ztAddress,ZT_PeerRole role)
+{
+ RR->topology->setUpstream(Address(ztAddress),(role == ZT_PEER_ROLE_UPSTREAM));
+}
+
void Node::setNetconfMaster(void *networkControllerInstance)
{
RR->localNetworkController = reinterpret_cast<NetworkController *>(networkControllerInstance);
@@ -1007,6 +1012,13 @@ void ZT_Node_clearLocalInterfaceAddresses(ZT_Node *node)
} catch ( ... ) {}
}
+void ZT_Node_setRole(ZT_Node *node,uint64_t ztAddress,ZT_PeerRole role)
+{
+ try {
+ reinterpret_cast<ZeroTier::Node *>(node)->setRole(ztAddress,role);
+ } catch ( ... ) {}
+}
+
void ZT_Node_setNetconfMaster(ZT_Node *node,void *networkControllerInstance)
{
try {