summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index 59794854..51f1b5c0 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -71,7 +71,8 @@ Node::Node(
_prngStreamPtr(0),
_now(now),
_lastPingCheck(0),
- _lastHousekeepingRun(0)
+ _lastHousekeepingRun(0),
+ _relayPolicy(ZT_RELAY_POLICY_TRUSTED)
{
_online = false;
@@ -118,6 +119,9 @@ Node::Node(
throw;
}
+ if (RR->topology->amRoot())
+ _relayPolicy = ZT_RELAY_POLICY_ALWAYS;
+
postEvent(ZT_EVENT_UP);
}
@@ -131,6 +135,7 @@ Node::~Node()
delete RR->topology;
delete RR->mc;
delete RR->sw;
+
#ifdef ZT_ENABLE_CLUSTER
delete RR->cluster;
#endif
@@ -319,6 +324,12 @@ ZT_ResultCode Node::processBackgroundTasks(uint64_t now,volatile uint64_t *nextB
return ZT_RESULT_OK;
}
+ZT_ResultCode Node::setRelayPolicy(enum ZT_RelayPolicy rp)
+{
+ _relayPolicy = rp;
+ return ZT_RESULT_OK;
+}
+
ZT_ResultCode Node::join(uint64_t nwid,void *uptr)
{
Mutex::Lock _l(_networks_m);
@@ -824,6 +835,15 @@ enum ZT_ResultCode ZT_Node_processBackgroundTasks(ZT_Node *node,uint64_t now,vol
}
}
+enum ZT_ResultCode ZT_Node_setRelayPolicy(ZT_Node *node,enum ZT_RelayPolicy rp)
+{
+ try {
+ return reinterpret_cast<ZeroTier::Node *>(node)->setRelayPolicy(rp);
+ } catch ( ... ) {
+ return ZT_RESULT_FATAL_ERROR_INTERNAL;
+ }
+}
+
enum ZT_ResultCode ZT_Node_join(ZT_Node *node,uint64_t nwid,void *uptr)
{
try {