Merge branch 'dev' into ctl

This commit is contained in:
Grant Limberg 2023-05-22 16:27:59 -07:00 committed by GitHub
commit 321b4996df
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 36 additions and 36 deletions

View file

@ -855,7 +855,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
httplib::Server &s,
const std::function<void(const httplib::Request&, httplib::Response&, std::string)> setContent)
{
s.Get("/controller/network", [&](const httplib::Request &req, httplib::Response &res) {
s.Get("/controller/network", [&, setContent](const httplib::Request &req, httplib::Response &res) {
std::set<uint64_t> networkIds;
_db.networks(networkIds);
char tmp[64];
@ -869,7 +869,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
setContent(req, res, out.dump());
});
s.Get("/controller/network/([0-9a-fA-F]{16})", [&](const httplib::Request &req, httplib::Response &res) {
s.Get("/controller/network/([0-9a-fA-F]{16})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1];
uint64_t nwid = Utils::hexStrToU64(networkID.str().c_str());
json network;
@ -881,7 +881,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
setContent(req, res, network.dump());
});
auto createNewNetwork = [&](const httplib::Request &req, httplib::Response &res) {
auto createNewNetwork = [&, setContent](const httplib::Request &req, httplib::Response &res) {
fprintf(stderr, "creating new network (new style)\n");
uint64_t nwid = 0;
uint64_t nwidPrefix = (Utils::hexStrToU64(_signingIdAddressString.c_str()) << 24) & 0xffffffffff000000ULL;
@ -905,7 +905,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
s.Put("/controller/network", createNewNetwork);
s.Post("/controller/network", createNewNetwork);
auto createNewNetworkOldAndBusted = [&](const httplib::Request &req, httplib::Response &res) {
auto createNewNetworkOldAndBusted = [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto inID = req.matches[1].str();
if (inID != _signingIdAddressString) {
@ -934,7 +934,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
s.Put("/controller/network/([0-9a-fA-F]{10})______", createNewNetworkOldAndBusted);
s.Post("/controller/network/([0-9a-fA-F]{10})______", createNewNetworkOldAndBusted);
s.Delete("/controller/network/([0-9a-fA-F]{16})", [&](const httplib::Request &req, httplib::Response &res) {
s.Delete("/controller/network/([0-9a-fA-F]{16})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1].str();
uint64_t nwid = Utils::hexStrToU64(networkID.c_str());
@ -948,7 +948,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
setContent(req, res, network.dump());
});
s.Get("/controller/network/([0-9a-fA-F]{16})/member", [&](const httplib::Request &req, httplib::Response &res) {
s.Get("/controller/network/([0-9a-fA-F]{16})/member", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1];
uint64_t nwid = Utils::hexStrToU64(networkID.str().c_str());
json network;
@ -961,7 +961,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
std::vector<json> memTmp;
if (_db.get(nwid, network, memTmp)) {
for (auto m = memTmp.begin(); m != memTmp.end(); ++m) {
int revision = OSUtils::jsonInt((*m)["revsision"], 0);
int revision = OSUtils::jsonInt((*m)["revision"], 0);
std::string id = OSUtils::jsonString((*m)["id"], "");
if (id.length() == 10) {
json tmp = json::object();
@ -974,7 +974,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
setContent(req, res, out.dump());
});
s.Get("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res) {
s.Get("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1];
auto memberID = req.matches[2];
uint64_t nwid = Utils::hexStrToU64(networkID.str().c_str());
@ -989,7 +989,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
setContent(req, res, member.dump());
});
auto memberPost = [&](const httplib::Request &req, httplib::Response &res) {
auto memberPost = [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1].str();
auto memberID = req.matches[2].str();
uint64_t nwid = Utils::hexStrToU64(networkID.c_str());
@ -1095,7 +1095,7 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
s.Put("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", memberPost);
s.Post("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", memberPost);
s.Delete("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res) {
s.Delete("/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto networkID = req.matches[1].str();
auto memberID = req.matches[2].str();

View file

@ -509,13 +509,13 @@ bool ManagedRoute::sync()
}
}
//if (!_applied.count(leftt)) {
if (leftt && !_applied.count(leftt)) {
_applied[leftt] = !_via;
//_routeCmd("delete",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
_routeCmd("add",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
//_routeCmd("change",leftt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
//}
if (rightt) {
}
if (rightt && !_applied.count(rightt)) {
_applied[rightt] = !_via;
//_routeCmd("delete",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);
_routeCmd("add",rightt,_via,(const char *)0,(_via) ? (const char *)0 : _device);

View file

@ -1519,7 +1519,7 @@ public:
_controlPlane.Get("/bond/show/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/bond/show/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
if (!_node->bondController()->inUse()) {
setContent(req, res, "");
res.status = 400;
@ -1547,7 +1547,7 @@ public:
_node->freeQueryResult((void *)pl);
});
auto bondRotate = [&](const httplib::Request &req, httplib::Response &res) {
auto bondRotate = [&, setContent](const httplib::Request &req, httplib::Response &res) {
if (!_node->bondController()->inUse()) {
setContent(req, res, "");
res.status = 400;
@ -1574,7 +1574,7 @@ public:
_controlPlane.Post("/bond/rotate/([0-9a-fA-F]{10})", bondRotate);
_controlPlane.Put("/bond/rotate/([0-9a-fA-F]{10})", bondRotate);
_controlPlane.Get("/config", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/config", [&, setContent](const httplib::Request &req, httplib::Response &res) {
std::string config;
{
Mutex::Lock lc(_localConfig_m);
@ -1586,7 +1586,7 @@ public:
setContent(req, res, config);
});
auto configPost = [&](const httplib::Request &req, httplib::Response &res) {
auto configPost = [&, setContent](const httplib::Request &req, httplib::Response &res) {
json j(OSUtils::jsonParse(req.body));
if (j.is_object()) {
Mutex::Lock lcl(_localConfig_m);
@ -1604,7 +1604,7 @@ public:
_controlPlane.Post("/config/settings", configPost);
_controlPlane.Put("/config/settings", configPost);
_controlPlane.Get("/health", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/health", [&, setContent](const httplib::Request &req, httplib::Response &res) {
json out = json::object();
char tmp[256];
@ -1624,7 +1624,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/moon", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/moon", [&, setContent](const httplib::Request &req, httplib::Response &res) {
std::vector<World> moons(_node->moons());
auto out = json::array();
@ -1636,7 +1636,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/moon/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res){
_controlPlane.Get("/moon/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res){
std::vector<World> moons(_node->moons());
auto input = req.matches[1];
auto out = json::object();
@ -1650,7 +1650,7 @@ public:
setContent(req, res, out.dump());
});
auto moonPost = [&](const httplib::Request &req, httplib::Response &res) {
auto moonPost = [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto input = req.matches[1];
uint64_t seed = 0;
try {
@ -1690,7 +1690,7 @@ public:
_controlPlane.Post("/moon/([0-9a-fA-F]{10})", moonPost);
_controlPlane.Put("/moon/([0-9a-fA-F]{10})", moonPost);
_controlPlane.Delete("/moon/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Delete("/moon/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto input = req.matches[1];
uint64_t id = Utils::hexStrToU64(input.str().c_str());
auto out = json::object();
@ -1699,7 +1699,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/network", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/network", [&, setContent](const httplib::Request &req, httplib::Response &res) {
Mutex::Lock _l(_nets_m);
auto out = json::array();
@ -1712,7 +1712,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/network/([0-9a-fA-F]{16})", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/network/([0-9a-fA-F]{16})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
Mutex::Lock _l(_nets_m);
auto input = req.matches[1];
@ -1728,7 +1728,7 @@ public:
res.status = 404;
});
auto networkPost = [&](const httplib::Request &req, httplib::Response &res) {
auto networkPost = [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto input = req.matches[1];
uint64_t wantnw = Utils::hexStrToU64(input.str().c_str());
_node->join(wantnw, (void*)0, (void*)0);
@ -1770,7 +1770,7 @@ public:
_controlPlane.Post("/network/([0-9a-fA-F]{16})", networkPost);
_controlPlane.Put("/network/([0-9a-fA-F]){16}", networkPost);
_controlPlane.Delete("/network/([0-9a-fA-F]{16})", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Delete("/network/([0-9a-fA-F]{16})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
auto input = req.matches[1];
auto out = json::object();
ZT_VirtualNetworkList *nws = _node->networks();
@ -1785,7 +1785,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/peer", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/peer", [&, setContent](const httplib::Request &req, httplib::Response &res) {
ZT_PeerList *pl = _node->peers();
auto out = nlohmann::json::array();
@ -1803,7 +1803,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/peer/([0-9a-fA-F]{10})", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/peer/([0-9a-fA-F]{10})", [&, setContent](const httplib::Request &req, httplib::Response &res) {
ZT_PeerList *pl = _node->peers();
auto input = req.matches[1];
@ -1823,7 +1823,7 @@ public:
setContent(req, res, out.dump());
});
_controlPlane.Get("/status", [&](const httplib::Request &req, httplib::Response &res) {
_controlPlane.Get("/status", [&, setContent](const httplib::Request &req, httplib::Response &res) {
ZT_NodeStatus status;
_node->status(&status);
@ -1969,7 +1969,7 @@ public:
}
});
_controlPlane.set_exception_handler([&](const httplib::Request &req, httplib::Response &res, std::exception_ptr ep) {
_controlPlane.set_exception_handler([&, setContent](const httplib::Request &req, httplib::Response &res, std::exception_ptr ep) {
char buf[1024];
auto fmt = "{\"error\": %d, \"description\": \"%s\"}";
try {

View file

@ -417,7 +417,7 @@
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\zeroidc\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<LanguageStandard_C>stdc11</LanguageStandard_C>
@ -439,7 +439,7 @@
<AdditionalIncludeDirectories>$(SolutionDir)\..\ext;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\core\include;$(SolutionDir)\..\ext\prometheus-cpp-lite-1.0\simpleapi\include;$(SolutionDir)\..\zeroidc\target;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
@ -461,11 +461,11 @@
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_TRACE;ZT_RULES_ENGINE_DEBUGGING;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -507,11 +507,11 @@
<PreprocessorDefinitions>ZT_SSO_ENABLED=1;ZT_EXPORT;FD_SETSIZE=1024;NOMINMAX;STATICLIB;WIN32;ZT_USE_MINIUPNPC;MINIUPNP_STATICLIB;ZT_SOFTWARE_UPDATE_DEFAULT="disable";%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
@ -558,7 +558,7 @@
<OmitFramePointers>true</OmitFramePointers>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
<ControlFlowGuard>Guard</ControlFlowGuard>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
@ -597,7 +597,6 @@
<ControlFlowGuard>Guard</ControlFlowGuard>
<EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
<CallingConvention>Cdecl</CallingConvention>
<RuntimeTypeInfo>false</RuntimeTypeInfo>
<LanguageStandard>stdcpp17</LanguageStandard>
<DebugInformationFormat>None</DebugInformationFormat>
<CompileAsManaged>false</CompileAsManaged>
@ -606,6 +605,7 @@
<LanguageStandard_C>stdc11</LanguageStandard_C>
<CreateHotpatchableImage>false</CreateHotpatchableImage>
<GuardEHContMetadata>false</GuardEHContMetadata>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<GenerateDebugInformation>false</GenerateDebugInformation>