Browse Source

Allow relay policy setting in local.conf

Adam Ierymenko 8 years ago
parent
commit
d159e5ca44
1 changed files with 12 additions and 1 deletions
  1. 12 1
      service/OneService.cpp

+ 12 - 1
service/OneService.cpp

@@ -883,7 +883,7 @@ public:
 				json &virt = _localConfig["virtual"];
 				if (virt.is_object()) {
 					for(json::iterator v(virt.begin());v!=virt.end();++v) {
-						std::string nstr = v.key();
+						const std::string nstr = v.key();
 						if ((nstr.length() == ZT_ADDRESS_LENGTH_HEX)&&(v.value().is_object())) {
 							const Address ztaddr(nstr.c_str());
 							if (ztaddr)
@@ -891,6 +891,17 @@ public:
 						}
 					}
 				}
+
+				// Set any other local config stuff
+				json &settings = _localConfig["settings"];
+				if (settings.is_object()) {
+					const std::string rp(_jS(settings["relayPolicy"],""));
+					if (rp == "always")
+						_node->setRelayPolicy(ZT_RELAY_POLICY_ALWAYS);
+					else if (rp == "never")
+						_node->setRelayPolicy(ZT_RELAY_POLICY_NEVER);
+					else _node->setRelayPolicy(ZT_RELAY_POLICY_TRUSTED);
+				}
 			}
 
 			_controller = new EmbeddedNetworkController(_node,(_homePath + ZT_PATH_SEPARATOR_S + ZT_CONTROLLER_DB_PATH).c_str());