mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-05-29 13:34:29 +00:00
commit
2d49931300
@ -867,12 +867,33 @@ void EmbeddedNetworkController::configureHTTPControlPlane(
|
|||||||
const std::function<void(const httplib::Request&, httplib::Response&, std::string)> setContent)
|
const std::function<void(const httplib::Request&, httplib::Response&, std::string)> setContent)
|
||||||
{
|
{
|
||||||
// Control plane Endpoints
|
// Control plane Endpoints
|
||||||
|
std::string controllerPath = "/controller";
|
||||||
std::string networkListPath = "/controller/network";
|
std::string networkListPath = "/controller/network";
|
||||||
std::string networkPath = "/controller/network/([0-9a-fA-F]{16})";
|
std::string networkPath = "/controller/network/([0-9a-fA-F]{16})";
|
||||||
std::string oldAndBustedNetworkCreatePath = "/controller/network/([0-9a-fA-F]{10})______";
|
std::string oldAndBustedNetworkCreatePath = "/controller/network/([0-9a-fA-F]{10})______";
|
||||||
std::string memberListPath = "/controller/network/([0-9a-fA-F]{16})/member";
|
std::string memberListPath = "/controller/network/([0-9a-fA-F]{16})/member";
|
||||||
std::string memberPath = "/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})";
|
std::string memberPath = "/controller/network/([0-9a-fA-F]{16})/member/([0-9a-fA-F]{10})";
|
||||||
|
|
||||||
|
auto controllerGet = [&, setContent](const httplib::Request &req, httplib::Response &res) {
|
||||||
|
char tmp[4096];
|
||||||
|
const bool dbOk = _db.isReady();
|
||||||
|
OSUtils::ztsnprintf(
|
||||||
|
tmp,
|
||||||
|
sizeof(tmp),
|
||||||
|
"{\n\t\"controller\": true,\n\t\"apiVersion\": %d,\n\t\"clock\": %llu,\n\t\"databaseReady\": %s\n}\n",
|
||||||
|
ZT_NETCONF_CONTROLLER_API_VERSION,
|
||||||
|
(unsigned long long)OSUtils::now(),
|
||||||
|
dbOk ? "true" : "false");
|
||||||
|
|
||||||
|
if (!dbOk) {
|
||||||
|
res.status = 503;
|
||||||
|
}
|
||||||
|
|
||||||
|
setContent(req, res, tmp);
|
||||||
|
};
|
||||||
|
s.Get(controllerPath, controllerGet);
|
||||||
|
sv6.Get(controllerPath, controllerGet);
|
||||||
|
|
||||||
auto networkListGet = [&, setContent](const httplib::Request &req, httplib::Response &res) {
|
auto networkListGet = [&, setContent](const httplib::Request &req, httplib::Response &res) {
|
||||||
std::set<uint64_t> networkIds;
|
std::set<uint64_t> networkIds;
|
||||||
_db.networks(networkIds);
|
_db.networks(networkIds);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user