Controller API status message.

This commit is contained in:
Adam Ierymenko 2015-05-15 09:41:45 -07:00
parent f693d4d0c8
commit 6d2376eb9c

View File

@ -61,6 +61,9 @@
#define ZT_NETCONF_SQLITE_SCHEMA_VERSION 1 #define ZT_NETCONF_SQLITE_SCHEMA_VERSION 1
#define ZT_NETCONF_SQLITE_SCHEMA_VERSION_STR "1" #define ZT_NETCONF_SQLITE_SCHEMA_VERSION_STR "1"
// API version reported via JSON control plane
#define ZT_NETCONF_CONTROLLER_API_VERSION 1
// Maximum age in ms for a cached netconf before we regenerate anyway (one hour) // Maximum age in ms for a cached netconf before we regenerate anyway (one hour)
#define ZT_CACHED_NETCONF_MAX_AGE (60 * 60 * 1000) #define ZT_CACHED_NETCONF_MAX_AGE (60 * 60 * 1000)
@ -619,8 +622,8 @@ unsigned int SqliteNetworkController::handleControlPlaneHttpGET(
if (sqlite3_step(_sGetMember2) == SQLITE_ROW) { if (sqlite3_step(_sGetMember2) == SQLITE_ROW) {
Utils::snprintf(json,sizeof(json), Utils::snprintf(json,sizeof(json),
"{\n" "{\n"
"\taddress: \"%s\"" "\taddress: \"%s\"\n"
"\tauthorized: %s," "\tauthorized: %s,\n"
"\tactiveBridge: %s,\n" "\tactiveBridge: %s,\n"
"\tlastAt: \"%s\",\n" "\tlastAt: \"%s\",\n"
"\tlastSeen: %llu,\n" "\tlastSeen: %llu,\n"
@ -820,7 +823,13 @@ unsigned int SqliteNetworkController::handleControlPlaneHttpGET(
return 200; return 200;
} // else 404 } // else 404
} // else 404 } else {
// GET /controller returns status and API version if controller is supported
Utils::snprintf(json,sizeof(json),"{\n\tcontroller: true,\n\tapiVersion: %d\n\tclock: %llu\n}",ZT_NETCONF_CONTROLLER_API_VERSION,(unsigned long long)OSUtils::now());
responseBody = json;
responseContentType = "applicaiton/json";
return 200;
}
return 404; return 404;
} }