mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-06-07 21:13:44 +02:00
add a /health health-check endpoint
only shows online and version information
This commit is contained in:
parent
0eecb8a8a0
commit
9316c21631
1 changed files with 21 additions and 1 deletions
|
@ -1444,7 +1444,7 @@ public:
|
|||
|
||||
// Internal HTTP Control Plane
|
||||
void startHTTPControlPlane() {
|
||||
std::vector<std::string> noAuthEndpoints { "/sso" };
|
||||
std::vector<std::string> noAuthEndpoints { "/sso", "/health" };
|
||||
|
||||
auto authCheck = [=] (const httplib::Request &req, httplib::Response &res) {
|
||||
std::string r = req.remote_addr + "/32";
|
||||
|
@ -1590,6 +1590,26 @@ public:
|
|||
_controlPlane.Post("/config/settings", configPost);
|
||||
_controlPlane.Put("/config/settings", configPost);
|
||||
|
||||
_controlPlane.Get("/health", [this](const httplib::Request &req, httplib::Response &res) {
|
||||
json out = json::object();
|
||||
|
||||
char tmp[256];
|
||||
|
||||
ZT_NodeStatus status;
|
||||
_node->status(&status);
|
||||
|
||||
out["online"] = (bool)(status.online != 0);
|
||||
out["versionMajor"] = ZEROTIER_ONE_VERSION_MAJOR;
|
||||
out["versionMinor"] = ZEROTIER_ONE_VERSION_MINOR;
|
||||
out["versionRev"] = ZEROTIER_ONE_VERSION_REVISION;
|
||||
out["versionBuild"] = ZEROTIER_ONE_VERSION_BUILD;
|
||||
OSUtils::ztsnprintf(tmp,sizeof(tmp),"%d.%d.%d",ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION);
|
||||
out["version"] = tmp;
|
||||
out["clock"] = OSUtils::now();
|
||||
|
||||
res.set_content(out.dump(), "application/json");
|
||||
});
|
||||
|
||||
_controlPlane.Get("/moon", [this](const httplib::Request &req, httplib::Response &res) {
|
||||
std::vector<World> moons(_node->moons());
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue