From 1f5700191f852f84fe211f0a881f03b40cd7d371 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 16 Apr 2015 16:12:10 -0700 Subject: zerotier-cli suspiciously working... that didn't hurt *too* badly. --- service/ControlPlane.cpp | 68 +++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 38 deletions(-) (limited to 'service') diff --git a/service/ControlPlane.cpp b/service/ControlPlane.cpp index 4d57fbda..1b5113d0 100644 --- a/service/ControlPlane.cpp +++ b/service/ControlPlane.cpp @@ -438,26 +438,22 @@ unsigned int ControlPlane::handleRequest( if (ps[0] == "config") { // TODO } else if (ps[0] == "network") { - if ((ps.size() > 1)&&(ps[1] == "controller")) { - // TODO - } else { - if (ps.size() == 2) { - uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str()); - _node->join(wantnw); // does nothing if we are a member - ZT1_VirtualNetworkList *nws = _node->networks(); - if (nws) { - for(unsigned long i=0;inetworkCount;++i) { - if (nws->networks[i].nwid == wantnw) { - responseContentType = "application/json"; - _jsonAppend(0,responseBody,&(nws->networks[i]),_svc->portDeviceName(nws->networks[i].nwid)); - responseBody.push_back('\n'); - scode = 200; - break; - } + if (ps.size() == 2) { + uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str()); + _node->join(wantnw); // does nothing if we are a member + ZT1_VirtualNetworkList *nws = _node->networks(); + if (nws) { + for(unsigned long i=0;inetworkCount;++i) { + if (nws->networks[i].nwid == wantnw) { + responseContentType = "application/json"; + _jsonAppend(0,responseBody,&(nws->networks[i]),_svc->portDeviceName(nws->networks[i].nwid)); + responseBody.push_back('\n'); + scode = 200; + break; } - _node->freeQueryResult((void *)nws); - } else scode = 500; - } // else 404 + } + _node->freeQueryResult((void *)nws); + } else scode = 500; } } // else 404 } else scode = 401; // isAuth == false @@ -468,26 +464,22 @@ unsigned int ControlPlane::handleRequest( if (ps[0] == "config") { // TODO } else if (ps[0] == "network") { - if ((ps.size() > 1)&&(ps[1] == "controller")) { - // TODO - } else { - ZT1_VirtualNetworkList *nws = _node->networks(); - if (nws) { - if (ps.size() == 2) { - uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str()); - for(unsigned long i=0;inetworkCount;++i) { - if (nws->networks[i].nwid == wantnw) { - _node->leave(wantnw); - responseBody = "true"; - responseContentType = "application/json"; - scode = 200; - break; - } + ZT1_VirtualNetworkList *nws = _node->networks(); + if (nws) { + if (ps.size() == 2) { + uint64_t wantnw = Utils::hexStrToU64(ps[1].c_str()); + for(unsigned long i=0;inetworkCount;++i) { + if (nws->networks[i].nwid == wantnw) { + _node->leave(wantnw); + responseBody = "true"; + responseContentType = "application/json"; + scode = 200; + break; } - } // else 404 - _node->freeQueryResult((void *)nws); - } else scode = 500; - } + } + } // else 404 + _node->freeQueryResult((void *)nws); + } else scode = 500; } // else 404 } else { -- cgit v1.2.3