mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-11-01 19:27:47 +00:00
Fixing the configuration reload issue.
This commit is contained in:
@@ -131,6 +131,7 @@ namespace OpenWifi {
|
||||
[[nodiscard]] std::string PrivateEndPoint() const { return MyPrivateEndPoint_; };
|
||||
[[nodiscard]] std::string PublicEndPoint() const { return MyPublicEndPoint_; };
|
||||
[[nodiscard]] std::string MakeSystemEventMessage( const std::string & Type ) const ;
|
||||
[[nodiscard]] const Types::SubSystemVec & GetFullSubSystems() { return SubSystems_; }
|
||||
inline uint64_t DaemonBusTimer() const { return DAEMON_BUS_TIMER; };
|
||||
|
||||
void BusMessageReceived( const std::string & Key, const std::string & Message);
|
||||
|
||||
@@ -235,13 +235,23 @@ namespace OpenWifi {
|
||||
void RESTAPIHandler::BadRequest(const std::string & Reason) {
|
||||
PrepareResponse(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
|
||||
Poco::JSON::Object ErrorObject;
|
||||
ErrorObject.set("ErrorCode",500);
|
||||
ErrorObject.set("ErrorCode",400);
|
||||
ErrorObject.set("ErrorDetails",Request->getMethod());
|
||||
ErrorObject.set("ErrorDescription",Reason.empty() ? "Command is missing parameters or wrong values." : Reason) ;
|
||||
std::ostream &Answer = Response->send();
|
||||
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
||||
}
|
||||
|
||||
void RESTAPIHandler::InternalError(const std::string & Reason) {
|
||||
PrepareResponse(Poco::Net::HTTPResponse::HTTP_INTERNAL_SERVER_ERROR);
|
||||
Poco::JSON::Object ErrorObject;
|
||||
ErrorObject.set("ErrorCode",500);
|
||||
ErrorObject.set("ErrorDetails",Request->getMethod());
|
||||
ErrorObject.set("ErrorDescription",Reason.empty() ? "Please try later or review the data submitted." : Reason) ;
|
||||
std::ostream &Answer = Response->send();
|
||||
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
||||
}
|
||||
|
||||
void RESTAPIHandler::UnAuthorized(const std::string & Reason) {
|
||||
PrepareResponse(Poco::Net::HTTPResponse::HTTP_FORBIDDEN);
|
||||
Poco::JSON::Object ErrorObject;
|
||||
|
||||
@@ -114,6 +114,7 @@ namespace OpenWifi {
|
||||
bool GetBoolParameter(const std::string &Name, bool Default);
|
||||
|
||||
void BadRequest(const std::string &Reason );
|
||||
void InternalError(const std::string &Reason = "");
|
||||
void UnAuthorized(const std::string &Reason = "");
|
||||
void ReturnObject(Poco::JSON::Object &Object);
|
||||
void NotFound();
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
|
||||
#include "Poco/Exception.h"
|
||||
#include "Poco/JSON/Parser.h"
|
||||
#include "Poco/DateTime.h"
|
||||
#include "Poco/DateTimeFormat.h"
|
||||
|
||||
#include "Daemon.h"
|
||||
#include "RESTAPI_protocol.h"
|
||||
@@ -113,6 +115,26 @@ namespace OpenWifi {
|
||||
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
||||
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
||||
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
||||
|
||||
Poco::JSON::Array Certificates;
|
||||
auto SubSystems = Daemon()->GetFullSubSystems();
|
||||
std::set<std::string> CertNames;
|
||||
for(const auto &i:SubSystems) {
|
||||
auto Hosts=i->HostSize();
|
||||
for(uint64_t j=0;j<Hosts;++j) {
|
||||
auto CertFileName = i->Host(j).CertFile();
|
||||
auto InsertResult = CertNames.insert(CertFileName);
|
||||
if( InsertResult.second ) {
|
||||
Poco::JSON::Object Inner;
|
||||
Inner.set("filename", CertFileName);
|
||||
Poco::Crypto::X509Certificate C(CertFileName);
|
||||
auto ExpiresOn = C.expiresOn();
|
||||
Inner.set("expiresOn",ExpiresOn.timestamp().epochTime());
|
||||
Certificates.add(Inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
Answer.set("certificates", Certificates);
|
||||
ReturnObject(Answer);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,8 @@ class SubSystemServer : public Poco::Util::Application::Subsystem {
|
||||
inline const std::string & Name() const { return Name_; };
|
||||
const char * name() const override { return Name_.c_str(); }
|
||||
|
||||
const PropertiesFileServerEntry &Host(int index) { return ConfigServersList_[index]; };
|
||||
const PropertiesFileServerEntry & Host(uint64_t index) { return ConfigServersList_[index]; };
|
||||
uint64_t HostSize() const { return ConfigServersList_.size(); }
|
||||
Poco::Logger &Logger() { return Logger_; };
|
||||
void SetLoggingLevel(Poco::Message::Priority NewPriority) { Logger_.setLevel(NewPriority); }
|
||||
int GetLoggingLevel() { return Logger_.getLevel(); }
|
||||
|
||||
Reference in New Issue
Block a user