diff options
author | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-16 16:12:10 -0700 |
---|---|---|
committer | Adam Ierymenko <adam.ierymenko@gmail.com> | 2015-04-16 16:12:10 -0700 |
commit | 1f5700191f852f84fe211f0a881f03b40cd7d371 (patch) | |
tree | 35c6cd85ce5af4eaae6ba95386dd5c0ce80c7402 /service/ControlPlane.cpp | |
parent | c4c5fa63d152fc30463babf82bff3cf1dfdb2eda (diff) | |
download | infinitytier-1f5700191f852f84fe211f0a881f03b40cd7d371.tar.gz infinitytier-1f5700191f852f84fe211f0a881f03b40cd7d371.zip |
zerotier-cli suspiciously working... that didn't hurt *too* badly.
Diffstat (limited to 'service/ControlPlane.cpp')
-rw-r--r-- | service/ControlPlane.cpp | 68 |
1 files changed, 30 insertions, 38 deletions
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;i<nws->networkCount;++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;i<nws->networkCount;++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;i<nws->networkCount;++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;i<nws->networkCount;++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 { |