diff --git a/build b/build index dec2bf5..2edeafb 100644 --- a/build +++ b/build @@ -1 +1 @@ -19 \ No newline at end of file +20 \ No newline at end of file diff --git a/openpapi/ucentralsec/ucentralsec.yaml b/openpapi/ucentralsec/ucentralsec.yaml index 656538f..bb72147 100644 --- a/openpapi/ucentralsec/ucentralsec.yaml +++ b/openpapi/ucentralsec/ucentralsec.yaml @@ -381,6 +381,24 @@ components: - $ref: '#/components/schemas/StringList' - $ref: '#/components/schemas/TagValuePairList' + SystemInfoResults: + type: object + properties: + version: + type: string + uptime: + type: integer + format: integer64 + start: + type: integer + format: integer64 + os: + type: string + processors: + type: integer + hostname: + type: string + ProfileAction: type: object properties: @@ -862,8 +880,7 @@ paths: schema: type: string enum: - - version - - times + - info required: true responses: @@ -872,7 +889,8 @@ paths: content: application/json: schema: - $ref: '#/components/schemas/TagValuePair' + oneOf: + - $ref: '#/components/schemas/SystemInfoResults' 403: $ref: '#/components/responses/Unauthorized' 404: diff --git a/src/RESTAPI_protocol.h b/src/RESTAPI_protocol.h index caf7f76..dfeb3e8 100644 --- a/src/RESTAPI_protocol.h +++ b/src/RESTAPI_protocol.h @@ -69,6 +69,10 @@ namespace OpenWifi::RESTAPI::Protocol { static const char * COMMANDUUID = "commandUUID"; static const char * FIRMWARES = "firmwares"; static const char * TOPIC = "topic"; + static const char * HOST = "host"; + static const char * OS = "os"; + static const char * HOSTNAME = "hostname"; + static const char * PROCESSORS = "processors"; static const char * REASON = "reason"; static const char * FILEUUID = "uuid"; static const char * USERID = "userId"; @@ -122,6 +126,8 @@ namespace OpenWifi::RESTAPI::Protocol { static const char * PASSWORDPOLICY = "passwordPolicy"; static const char * FORGOTPASSWORD = "forgotPassword"; static const char * ME = "me"; + static const char * TELEMETRY = "telemetry"; + static const char * INTERVAL = "interval"; } diff --git a/src/RESTAPI_system_command.cpp b/src/RESTAPI_system_command.cpp index 5da9f62..9df7998 100644 --- a/src/RESTAPI_system_command.cpp +++ b/src/RESTAPI_system_command.cpp @@ -79,29 +79,18 @@ namespace OpenWifi { } void RESTAPI_system_command::DoGet() { - auto Command = GetParameter(RESTAPI::Protocol::COMMAND, ""); - if (!Poco::icompare(Command, RESTAPI::Protocol::VERSION)) { + std::string Arg; + if(HasParameter("command",Arg) && Arg=="info") { Poco::JSON::Object Answer; - Answer.set(RESTAPI::Protocol::TAG, RESTAPI::Protocol::VERSION); - Answer.set(RESTAPI::Protocol::VALUE, Daemon()->Version()); + Answer.set(RESTAPI::Protocol::VERSION, Daemon()->Version()); + Answer.set(RESTAPI::Protocol::UPTIME, Daemon()->uptime().totalSeconds()); + Answer.set(RESTAPI::Protocol::START, Daemon()->startTime().epochTime()); + Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName()); + Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount()); + Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName()); ReturnObject(Answer); return; } - if (!Poco::icompare(Command, RESTAPI::Protocol::TIMES)) { - Poco::JSON::Array Array; - Poco::JSON::Object Answer; - Poco::JSON::Object UpTimeObj; - UpTimeObj.set(RESTAPI::Protocol::TAG,RESTAPI::Protocol::UPTIME); - UpTimeObj.set(RESTAPI::Protocol::VALUE, Daemon()->uptime().totalSeconds()); - Poco::JSON::Object StartObj; - StartObj.set(RESTAPI::Protocol::TAG,RESTAPI::Protocol::START); - StartObj.set(RESTAPI::Protocol::VALUE, Daemon()->startTime().epochTime()); - Array.add(UpTimeObj); - Array.add(StartObj); - Answer.set(RESTAPI::Protocol::TIMES, Array); - ReturnObject(Answer); - return; - } - BadRequest("Unsupported or missing parameters."); + BadRequest("Unknown command."); } } \ No newline at end of file diff --git a/src/SubSystemServer.h b/src/SubSystemServer.h index d903d5d..3a2c374 100644 --- a/src/SubSystemServer.h +++ b/src/SubSystemServer.h @@ -84,7 +84,7 @@ class SubSystemServer : public Poco::Util::Application::Subsystem { virtual void Stop() = 0; protected: - std::recursive_mutex Mutex_{}; + std::recursive_mutex Mutex_; Poco::Logger &Logger_; std::string Name_; std::vector ConfigServersList_; diff --git a/src/Utils.cpp b/src/Utils.cpp index 3d02449..9666537 100644 --- a/src/Utils.cpp +++ b/src/Utils.cpp @@ -151,7 +151,7 @@ namespace OpenWifi::Utils { if(input.length() % 4) throw std::runtime_error("Invalid base64 length!"); - std::size_t padding{}; + std::size_t padding=0; if(input.length()) { @@ -162,7 +162,7 @@ namespace OpenWifi::Utils { std::vector decoded; decoded.reserve(((input.length() / 4) * 3) - padding); - std::uint32_t temp{}; + std::uint32_t temp=0; auto it = input.begin(); while(it < input.end())