Browse Source

Expose relay policy in node settings.

Adam Ierymenko 9 years ago
parent
commit
97d915b06c
3 changed files with 18 additions and 7 deletions
  1. 15 7
      include/ZeroTierOne.h
  2. 1 0
      node/Node.cpp
  3. 2 0
      service/ControlPlane.cpp

+ 15 - 7
include/ZeroTierOne.h

@@ -396,6 +396,16 @@ enum ZT_Event
 	ZT_EVENT_TRACE = 5
 };
 
+/**
+ * Node relay policy
+ */
+enum ZT_RelayPolicy
+{
+	ZT_RELAY_POLICY_NEVER = 0,
+	ZT_RELAY_POLICY_TRUSTED = 1,
+	ZT_RELAY_POLICY_ALWAYS = 2
+};
+
 /**
  * Current node status
  */
@@ -430,6 +440,11 @@ typedef struct
 	 */
 	const char *secretIdentity;
 
+	/**
+	 * Node relay policy
+	 */
+	ZT_RelayPolicy relayPolicy;
+
 	/**
 	 * True if some kind of connectivity appears available
 	 */
@@ -791,13 +806,6 @@ enum ZT_VirtualNetworkConfigOperation
 	ZT_VIRTUAL_NETWORK_CONFIG_OPERATION_DESTROY = 4
 };
 
-enum ZT_RelayPolicy
-{
-	ZT_RELAY_POLICY_NEVER = 0,
-	ZT_RELAY_POLICY_TRUSTED = 1,
-	ZT_RELAY_POLICY_ALWAYS = 2
-};
-
 /**
  * What trust hierarchy role does this peer have?
  */

+ 1 - 0
node/Node.cpp

@@ -384,6 +384,7 @@ void Node::status(ZT_NodeStatus *status) const
 	status->worldTimestamp = RR->topology->worldTimestamp();
 	status->publicIdentity = RR->publicIdentityStr.c_str();
 	status->secretIdentity = RR->secretIdentityStr.c_str();
+	status->relayPolicy = _relayPolicy;
 	status->online = _online ? 1 : 0;
 }
 

+ 2 - 0
service/ControlPlane.cpp

@@ -389,6 +389,7 @@ unsigned int ControlPlane::handleRequest(
 					"\t\"worldId\": %llu,\n"
 					"\t\"worldTimestamp\": %llu,\n"
 					"\t\"online\": %s,\n"
+					"\t\"relayPolicy\": \"%s\",\n"
 					"\t\"tcpFallbackActive\": %s,\n"
 					"\t\"versionMajor\": %d,\n"
 					"\t\"versionMinor\": %d,\n"
@@ -402,6 +403,7 @@ unsigned int ControlPlane::handleRequest(
 					status.worldId,
 					status.worldTimestamp,
 					(status.online) ? "true" : "false",
+					((status.relayPolicy == ZT_RELAY_POLICY_ALWAYS) ? "always" : ((status.relayPolicy == ZT_RELAY_POLICY_NEVER) ? "never" : "trusted")),
 					(_svc->tcpFallbackActive()) ? "true" : "false",
 					ZEROTIER_ONE_VERSION_MAJOR,
 					ZEROTIER_ONE_VERSION_MINOR,