diff options
| author | Grant Limberg <grant.limberg@zerotier.com> | 2016-11-30 10:21:19 -0800 |
|---|---|---|
| committer | Grant Limberg <grant.limberg@zerotier.com> | 2016-11-30 10:21:19 -0800 |
| commit | 32478845b2df919d7546a889e49d276ea416a1f3 (patch) | |
| tree | 57e4d52862e90222a540a733935d237a03fdbe52 /service/ControlPlane.cpp | |
| parent | a39f6e9b4c3ccba677f58f3c0aafe9e6186c3031 (diff) | |
| parent | 44f0e3097ee081b50628821b6db2b740489a89c6 (diff) | |
| download | infinitytier-32478845b2df919d7546a889e49d276ea416a1f3.tar.gz infinitytier-32478845b2df919d7546a889e49d276ea416a1f3.zip | |
Merge branch 'dev' into systemtray
Diffstat (limited to 'service/ControlPlane.cpp')
| -rw-r--r-- | service/ControlPlane.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/service/ControlPlane.cpp b/service/ControlPlane.cpp index 07304fc9..3bdfdf1b 100644 --- a/service/ControlPlane.cpp +++ b/service/ControlPlane.cpp @@ -123,6 +123,7 @@ static void _jsonAppend(unsigned int depth,std::string &buf,const ZT_VirtualNetw Utils::snprintf(json,sizeof(json), "%s{\n" + "%s\t\"id\": \"%.16llx\",\n" "%s\t\"nwid\": \"%.16llx\",\n" "%s\t\"mac\": \"%.2x:%.2x:%.2x:%.2x:%.2x:%.2x\",\n" "%s\t\"name\": \"%s\",\n" @@ -143,6 +144,7 @@ static void _jsonAppend(unsigned int depth,std::string &buf,const ZT_VirtualNetw "%s}", prefix, prefix,nc->nwid, + prefix,nc->nwid, prefix,(unsigned int)((nc->mac >> 40) & 0xff),(unsigned int)((nc->mac >> 32) & 0xff),(unsigned int)((nc->mac >> 24) & 0xff),(unsigned int)((nc->mac >> 16) & 0xff),(unsigned int)((nc->mac >> 8) & 0xff),(unsigned int)(nc->mac & 0xff), prefix,_jsonEscape(nc->name).c_str(), prefix,nstatus, @@ -214,9 +216,9 @@ static void _jsonAppend(unsigned int depth,std::string &buf,const ZT_Peer *peer) const char *prole = ""; switch(peer->role) { - case ZT_PEER_ROLE_LEAF: prole = "LEAF"; break; + case ZT_PEER_ROLE_LEAF: prole = "LEAF"; break; case ZT_PEER_ROLE_UPSTREAM: prole = "UPSTREAM"; break; - case ZT_PEER_ROLE_ROOT: prole = "ROOT"; break; + case ZT_PEER_ROLE_ROOT: prole = "ROOT"; break; } Utils::snprintf(json,sizeof(json), @@ -389,6 +391,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 +405,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, @@ -411,7 +415,7 @@ unsigned int ControlPlane::handleRequest( ((clusterJson.length() > 0) ? clusterJson.c_str() : "null")); responseBody = json; scode = 200; - } else if (ps[0] == "config") { + } else if (ps[0] == "settings") { responseContentType = "application/json"; responseBody = "{}"; // TODO scode = 200; @@ -497,7 +501,7 @@ unsigned int ControlPlane::handleRequest( if (isAuth) { - if (ps[0] == "config") { + if (ps[0] == "settings") { // TODO } else if (ps[0] == "network") { if (ps.size() == 2) { @@ -513,11 +517,11 @@ unsigned int ControlPlane::handleRequest( try { nlohmann::json j(nlohmann::json::parse(body)); if (j.is_object()) { - auto allowManaged = j["allowManaged"]; + nlohmann::json &allowManaged = j["allowManaged"]; if (allowManaged.is_boolean()) localSettings.allowManaged = (bool)allowManaged; - auto allowGlobal = j["allowGlobal"]; + nlohmann::json &allowGlobal = j["allowGlobal"]; if (allowGlobal.is_boolean()) localSettings.allowGlobal = (bool)allowGlobal; - auto allowDefault = j["allowDefault"]; + nlohmann::json &allowDefault = j["allowDefault"]; if (allowDefault.is_boolean()) localSettings.allowDefault = (bool)allowDefault; } } catch ( ... ) { @@ -548,9 +552,7 @@ unsigned int ControlPlane::handleRequest( if (isAuth) { - if (ps[0] == "config") { - // TODO - } else if (ps[0] == "network") { + if (ps[0] == "network") { ZT_VirtualNetworkList *nws = _node->networks(); if (nws) { if (ps.size() == 2) { |
