mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-11-01 19:27:47 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -57,7 +57,7 @@ namespace OpenWifi {
|
|||||||
Types::StringSet RevisionSet_;
|
Types::StringSet RevisionSet_;
|
||||||
Types::StringSet DeviceSet_;
|
Types::StringSet DeviceSet_;
|
||||||
explicit LatestFirmwareCache() noexcept:
|
explicit LatestFirmwareCache() noexcept:
|
||||||
SubSystemServer("FirmwareCache", "FIRMWARE-CACHE", "FirmwareCache")
|
SubSystemServer("LatestFirmwareCache", "LATEST-FIRMWARE-CACHE", "LatestFirmwareCache")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -23,6 +23,13 @@
|
|||||||
#include <queue>
|
#include <queue>
|
||||||
#include <variant>
|
#include <variant>
|
||||||
|
|
||||||
|
|
||||||
|
// This must be defined for poco_debug and poco_trace macros to function.
|
||||||
|
|
||||||
|
#ifndef POCO_LOG_DEBUG
|
||||||
|
#define POCO_LOG_DEBUG true
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
inline uint64_t Now() { return std::time(nullptr); };
|
inline uint64_t Now() { return std::time(nullptr); };
|
||||||
}
|
}
|
||||||
@@ -1345,17 +1352,17 @@ namespace OpenWifi {
|
|||||||
inline void exception(const Poco::Exception & E) {
|
inline void exception(const Poco::Exception & E) {
|
||||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||||
App_.logger().log(E);
|
App_.logger().log(E);
|
||||||
App_.logger().error(fmt::format("Exception occurred in {}",CurrentThread->getName()));
|
poco_error(App_.logger(), fmt::format("Exception occurred in {}",CurrentThread->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void exception(const std::exception & E) {
|
inline void exception(const std::exception & E) {
|
||||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||||
App_.logger().warning(fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what()));
|
poco_warning(App_.logger(), fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void exception() {
|
inline void exception() {
|
||||||
Poco::Thread * CurrentThread = Poco::Thread::current();
|
Poco::Thread * CurrentThread = Poco::Thread::current();
|
||||||
App_.logger().warning(fmt::format("exception in {}",CurrentThread->getName()));
|
poco_warning(App_.logger(), fmt::format("exception in {}",CurrentThread->getName()));
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
Poco::Util::Application &App_;
|
Poco::Util::Application &App_;
|
||||||
@@ -1363,12 +1370,17 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class BusEventManager : public Poco::Runnable {
|
class BusEventManager : public Poco::Runnable {
|
||||||
public:
|
public:
|
||||||
|
explicit BusEventManager(Poco::Logger &L) : Logger_(L) {
|
||||||
|
|
||||||
|
}
|
||||||
inline void run() final;
|
inline void run() final;
|
||||||
inline void Start();
|
inline void Start();
|
||||||
inline void Stop();
|
inline void Stop();
|
||||||
|
inline Poco::Logger & Logger() { return Logger_; }
|
||||||
private:
|
private:
|
||||||
mutable std::atomic_bool Running_ = false;
|
mutable std::atomic_bool Running_ = false;
|
||||||
Poco::Thread Thread_;
|
Poco::Thread Thread_;
|
||||||
|
Poco::Logger &Logger_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class MyPrivateKeyPassphraseHandler : public Poco::Net::PrivateKeyPassphraseHandler {
|
class MyPrivateKeyPassphraseHandler : public Poco::Net::PrivateKeyPassphraseHandler {
|
||||||
@@ -1382,6 +1394,7 @@ namespace OpenWifi {
|
|||||||
Logger_.information("Returning key passphrase.");
|
Logger_.information("Returning key passphrase.");
|
||||||
privateKey = Password_;
|
privateKey = Password_;
|
||||||
};
|
};
|
||||||
|
inline Poco::Logger & Logger() { return Logger_; }
|
||||||
private:
|
private:
|
||||||
std::string Password_;
|
std::string Password_;
|
||||||
Poco::Logger & Logger_;
|
Poco::Logger & Logger_;
|
||||||
@@ -1650,14 +1663,14 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class SubSystemServer : public Poco::Util::Application::Subsystem {
|
class SubSystemServer : public Poco::Util::Application::Subsystem {
|
||||||
public:
|
public:
|
||||||
SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
SubSystemServer(const std::string & Name, const std::string &LoggingPrefix,
|
||||||
std::string SubSystemConfigPrefix);
|
const std::string & SubSystemConfigPrefix);
|
||||||
|
|
||||||
inline void initialize(Poco::Util::Application &self) override;
|
inline void initialize(Poco::Util::Application &self) override;
|
||||||
inline void uninitialize() override {
|
inline void uninitialize() override {
|
||||||
}
|
}
|
||||||
inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
|
inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
|
||||||
Logger().information("Reloading of this subsystem is not supported.");
|
Logger_->L_.information("Reloading of this subsystem is not supported.");
|
||||||
}
|
}
|
||||||
inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override {
|
inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override {
|
||||||
}
|
}
|
||||||
@@ -1666,30 +1679,30 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
inline const PropertiesFileServerEntry & Host(uint64_t index) { return ConfigServersList_[index]; };
|
inline const PropertiesFileServerEntry & Host(uint64_t index) { return ConfigServersList_[index]; };
|
||||||
inline uint64_t HostSize() const { return ConfigServersList_.size(); }
|
inline uint64_t HostSize() const { return ConfigServersList_.size(); }
|
||||||
inline Poco::Logger &Logger() { if(Log_)
|
inline Poco::Logger & Logger() const { return Logger_->L_; }
|
||||||
return Log_->L;
|
inline void SetLoggingLevel(const std::string & levelName) {
|
||||||
return Poco::Logger::get("tmp");
|
Logger_->L_.setLevel(Poco::Logger::parseLevel(levelName));
|
||||||
};
|
}
|
||||||
inline void SetLoggingLevel(Poco::Message::Priority NewPriority) { Logger().setLevel(NewPriority); }
|
inline int GetLoggingLevel() { return Logger_->L_.getLevel(); }
|
||||||
inline int GetLoggingLevel() { return Logger().getLevel(); }
|
|
||||||
|
|
||||||
virtual int Start() = 0;
|
virtual int Start() = 0;
|
||||||
virtual void Stop() = 0;
|
virtual void Stop() = 0;
|
||||||
|
|
||||||
struct LoggerWrapper {
|
struct LoggerWrapper {
|
||||||
Poco::Logger &L;
|
Poco::Logger & L_;
|
||||||
explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
|
LoggerWrapper(Poco::Logger &L) :
|
||||||
};
|
L_(L) {}
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::recursive_mutex Mutex_;
|
std::recursive_mutex Mutex_;
|
||||||
std::vector<PropertiesFileServerEntry> ConfigServersList_;
|
std::vector<PropertiesFileServerEntry> ConfigServersList_;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<LoggerWrapper> Log_;
|
std::unique_ptr<LoggerWrapper> Logger_;
|
||||||
// Poco::Logger &Logger_;
|
std::string Name_;
|
||||||
std::string Name_;
|
std::string LoggerPrefix_;
|
||||||
std::string LoggerPrefix_;
|
std::string SubSystemConfigPrefix_;
|
||||||
std::string SubSystemConfigPrefix_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class RESTAPI_GenericServer {
|
class RESTAPI_GenericServer {
|
||||||
@@ -1823,7 +1836,7 @@ namespace OpenWifi {
|
|||||||
E->Count++;
|
E->Count++;
|
||||||
Cache_.update(H,E);
|
Cache_.update(H,E);
|
||||||
if(E->Count > MaxCalls) {
|
if(E->Count > MaxCalls) {
|
||||||
Logger().warning(fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
|
poco_warning(Logger(),fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -2165,12 +2178,16 @@ namespace OpenWifi {
|
|||||||
SetCommonHeaders(CloseConnection);
|
SetCommonHeaders(CloseConnection);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void BadRequest(const OpenWifi::RESTAPI::Errors::msg &E) {
|
inline void BadRequest(const OpenWifi::RESTAPI::Errors::msg &E, const std::string & Extra="") {
|
||||||
PrepareResponse(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
|
PrepareResponse(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
|
||||||
Poco::JSON::Object ErrorObject;
|
Poco::JSON::Object ErrorObject;
|
||||||
ErrorObject.set("ErrorCode",400);
|
ErrorObject.set("ErrorCode",400);
|
||||||
ErrorObject.set("ErrorDetails",Request->getMethod());
|
ErrorObject.set("ErrorDetails",Request->getMethod());
|
||||||
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
|
if(Extra.empty())
|
||||||
|
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
|
||||||
|
else
|
||||||
|
ErrorObject.set("ErrorDescription",fmt::format("{}: {} ({})",E.err_num,E.err_txt, Extra)) ;
|
||||||
|
|
||||||
std::ostream &Answer = Response->send();
|
std::ostream &Answer = Response->send();
|
||||||
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
||||||
}
|
}
|
||||||
@@ -2214,7 +2231,7 @@ namespace OpenWifi {
|
|||||||
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
|
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
|
||||||
std::ostream &Answer = Response->send();
|
std::ostream &Answer = Response->send();
|
||||||
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
|
||||||
Logger_.debug(fmt::format("RES-NOTFOUND: User='{}@{}' Method='{}' Path='{}",
|
poco_debug(Logger_,fmt::format("RES-NOTFOUND: User='{}@{}' Method='{}' Path='{}",
|
||||||
UserInfo_.userinfo.email,
|
UserInfo_.userinfo.email,
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->getMethod(),
|
Request->getMethod(),
|
||||||
@@ -2446,6 +2463,7 @@ namespace OpenWifi {
|
|||||||
Poco::Net::HTTPServerResponse *Response= nullptr;
|
Poco::Net::HTTPServerResponse *Response= nullptr;
|
||||||
SecurityObjects::UserInfoAndPolicy UserInfo_;
|
SecurityObjects::UserInfoAndPolicy UserInfo_;
|
||||||
QueryBlock QB_;
|
QueryBlock QB_;
|
||||||
|
const std::string & Requester() const { return REST_Requester_; }
|
||||||
protected:
|
protected:
|
||||||
BindingMap Bindings_;
|
BindingMap Bindings_;
|
||||||
Poco::URI::QueryParameters Parameters_;
|
Poco::URI::QueryParameters Parameters_;
|
||||||
@@ -2462,6 +2480,7 @@ namespace OpenWifi {
|
|||||||
RateLimit MyRates_;
|
RateLimit MyRates_;
|
||||||
uint64_t TransactionId_;
|
uint64_t TransactionId_;
|
||||||
Poco::JSON::Object::Ptr ParsedBody_;
|
Poco::JSON::Object::Ptr ParsedBody_;
|
||||||
|
std::string REST_Requester_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RESTAPI_UnknownRequestHandler : public RESTAPIHandler {
|
class RESTAPI_UnknownRequestHandler : public RESTAPIHandler {
|
||||||
@@ -2781,9 +2800,11 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
inline void Stop() override {
|
inline void Stop() override {
|
||||||
if(KafkaEnabled_) {
|
if(KafkaEnabled_) {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Dispatcher_.Stop();
|
Dispatcher_.Stop();
|
||||||
ProducerThr_.Stop();
|
ProducerThr_.Stop();
|
||||||
ConsumerThr_.Stop();
|
ConsumerThr_.Stop();
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2945,12 +2966,12 @@ namespace OpenWifi {
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
|
void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
|
||||||
{
|
{
|
||||||
Utils::SetThreadName("alb-request");
|
Utils::SetThreadName("alb-request");
|
||||||
try {
|
try {
|
||||||
if((id_ % 100) == 0) {
|
if((id_ % 100) == 0) {
|
||||||
Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.",
|
poco_debug(Logger_,fmt::format("ALB-REQUEST({}): ALB Request {}.",
|
||||||
Request.clientAddress().toString(), id_));
|
Request.clientAddress().toString(), id_));
|
||||||
}
|
}
|
||||||
Response.setChunkedTransferEncoding(true);
|
Response.setChunkedTransferEncoding(true);
|
||||||
@@ -3008,8 +3029,10 @@ namespace OpenWifi {
|
|||||||
inline int Start() override;
|
inline int Start() override;
|
||||||
|
|
||||||
inline void Stop() override {
|
inline void Stop() override {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
if(Running_)
|
if(Running_)
|
||||||
Server_->stop();
|
Server_->stopAll(true);
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -3038,12 +3061,14 @@ namespace OpenWifi {
|
|||||||
inline void Stop() override {
|
inline void Stop() override {
|
||||||
Logger().information("Stopping...");
|
Logger().information("Stopping...");
|
||||||
for( const auto & svr : RESTServers_ )
|
for( const auto & svr : RESTServers_ )
|
||||||
svr->stop();
|
svr->stopAll(true);
|
||||||
Pool_.stopAll();
|
Pool_.stopAll();
|
||||||
Pool_.joinAll();
|
Pool_.joinAll();
|
||||||
RESTServers_.clear();
|
RESTServers_.clear();
|
||||||
|
Logger().information("Stopped...");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void reinitialize(Poco::Util::Application &self) override;
|
inline void reinitialize(Poco::Util::Application &self) override;
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id) {
|
inline Poco::Net::HTTPRequestHandler *CallServer(const std::string &Path, uint64_t Id) {
|
||||||
@@ -3051,10 +3076,11 @@ namespace OpenWifi {
|
|||||||
Utils::SetThreadName(fmt::format("x-rest:{}",Id).c_str());
|
Utils::SetThreadName(fmt::format("x-rest:{}",Id).c_str());
|
||||||
return RESTAPI_ExtRouter(Path, Bindings, Logger(), Server_, Id);
|
return RESTAPI_ExtRouter(Path, Bindings, Logger(), Server_, Id);
|
||||||
}
|
}
|
||||||
|
const Poco::ThreadPool & Pool() { return Pool_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
|
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
|
||||||
Poco::ThreadPool Pool_{"x-rest",2,32};
|
Poco::ThreadPool Pool_{"x-rest",4,128};
|
||||||
RESTAPI_GenericServer Server_;
|
RESTAPI_GenericServer Server_;
|
||||||
|
|
||||||
RESTAPI_ExtServer() noexcept:
|
RESTAPI_ExtServer() noexcept:
|
||||||
@@ -3171,9 +3197,10 @@ namespace OpenWifi {
|
|||||||
inline void Stop() override {
|
inline void Stop() override {
|
||||||
Logger().information("Stopping...");
|
Logger().information("Stopping...");
|
||||||
for( const auto & svr : RESTServers_ )
|
for( const auto & svr : RESTServers_ )
|
||||||
svr->stop();
|
svr->stopAll(true);
|
||||||
Pool_.stopAll();
|
Pool_.stopAll();
|
||||||
Pool_.joinAll();
|
Pool_.joinAll();
|
||||||
|
Logger().information("Stopped...");
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void reinitialize(Poco::Util::Application &self) override;
|
inline void reinitialize(Poco::Util::Application &self) override;
|
||||||
@@ -3183,9 +3210,10 @@ namespace OpenWifi {
|
|||||||
Utils::SetThreadName(fmt::format("i-rest:{}",Id).c_str());
|
Utils::SetThreadName(fmt::format("i-rest:{}",Id).c_str());
|
||||||
return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
|
return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
|
||||||
}
|
}
|
||||||
|
const Poco::ThreadPool & Pool() { return Pool_; }
|
||||||
private:
|
private:
|
||||||
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
|
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
|
||||||
Poco::ThreadPool Pool_{"i-rest",2,16};
|
Poco::ThreadPool Pool_{"i-rest",4,96};
|
||||||
RESTAPI_GenericServer Server_;
|
RESTAPI_GenericServer Server_;
|
||||||
|
|
||||||
RESTAPI_IntServer() noexcept:
|
RESTAPI_IntServer() noexcept:
|
||||||
@@ -3266,7 +3294,7 @@ namespace OpenWifi {
|
|||||||
return ((RandomEngine_() % (max-min)) + min);
|
return ((RandomEngine_() % (max-min)) + min);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Poco::Logger & GetLogger(const std::string &Name) {
|
/* inline Poco::Logger & GetLogger(const std::string &Name) {
|
||||||
static auto initialized = false;
|
static auto initialized = false;
|
||||||
|
|
||||||
if(!initialized) {
|
if(!initialized) {
|
||||||
@@ -3275,7 +3303,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
return Poco::Logger::get(Name);
|
return Poco::Logger::get(Name);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
virtual void GetExtraConfiguration(Poco::JSON::Object & Cfg) {
|
virtual void GetExtraConfiguration(Poco::JSON::Object & Cfg) {
|
||||||
Cfg.set("additionalConfiguration",false);
|
Cfg.set("additionalConfiguration",false);
|
||||||
}
|
}
|
||||||
@@ -3368,7 +3396,6 @@ namespace OpenWifi {
|
|||||||
std::string MyPublicEndPoint_;
|
std::string MyPublicEndPoint_;
|
||||||
std::string UIURI_;
|
std::string UIURI_;
|
||||||
std::string Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH };
|
std::string Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH };
|
||||||
BusEventManager BusEventManager_;
|
|
||||||
std::recursive_mutex InfraMutex_;
|
std::recursive_mutex InfraMutex_;
|
||||||
std::default_random_engine RandomEngine_;
|
std::default_random_engine RandomEngine_;
|
||||||
Poco::Util::PropertyFileConfiguration * PropConfigurationFile_ = nullptr;
|
Poco::Util::PropertyFileConfiguration * PropConfigurationFile_ = nullptr;
|
||||||
@@ -3382,7 +3409,8 @@ namespace OpenWifi {
|
|||||||
bool NoBuiltInCrypto_=false;
|
bool NoBuiltInCrypto_=false;
|
||||||
Poco::JWT::Signer Signer_;
|
Poco::JWT::Signer Signer_;
|
||||||
Poco::Logger &Logger_;
|
Poco::Logger &Logger_;
|
||||||
Poco::ThreadPool TimerPool_{"timer:pool",2,16};
|
Poco::ThreadPool TimerPool_{"timer:pool",2,16};
|
||||||
|
std::unique_ptr<BusEventManager> BusEventManager_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void MicroService::Exit(int Reason) {
|
inline void MicroService::Exit(int Reason) {
|
||||||
@@ -3463,7 +3491,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
Logger_.log(E);
|
logger().log(E);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3714,8 +3742,9 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::InitializeSubSystemServers() {
|
inline void MicroService::InitializeSubSystemServers() {
|
||||||
for(auto i:SubSystems_)
|
for(auto i:SubSystems_) {
|
||||||
addSubsystem(i);
|
addSubsystem(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::StartSubSystemServers() {
|
inline void MicroService::StartSubSystemServers() {
|
||||||
@@ -3723,12 +3752,13 @@ namespace OpenWifi {
|
|||||||
for(auto i:SubSystems_) {
|
for(auto i:SubSystems_) {
|
||||||
i->Start();
|
i->Start();
|
||||||
}
|
}
|
||||||
BusEventManager_.Start();
|
BusEventManager_ = std::make_unique<BusEventManager>(Poco::Logger::create("BusEventManager",Poco::Logger::root().getChannel(),Poco::Logger::root().getLevel()));
|
||||||
|
BusEventManager_->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::StopSubSystemServers() {
|
inline void MicroService::StopSubSystemServers() {
|
||||||
AddActivity("Stopping");
|
AddActivity("Stopping");
|
||||||
BusEventManager_.Stop();
|
BusEventManager_->Stop();
|
||||||
for(auto i=SubSystems_.rbegin(); i!=SubSystems_.rend(); ++i) {
|
for(auto i=SubSystems_.rbegin(); i!=SubSystems_.rend(); ++i) {
|
||||||
(*i)->Stop();
|
(*i)->Stop();
|
||||||
}
|
}
|
||||||
@@ -3905,14 +3935,15 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
|
inline SubSystemServer::SubSystemServer(const std::string &Name, const std::string &LoggingPrefix,
|
||||||
std::string SubSystemConfigPrefix):
|
const std::string &SubSystemConfigPrefix):
|
||||||
Name_(std::move(Name)),
|
Name_(Name),
|
||||||
LoggerPrefix_(LoggingPrefix),
|
LoggerPrefix_(LoggingPrefix),
|
||||||
SubSystemConfigPrefix_(std::move(SubSystemConfigPrefix)) {
|
SubSystemConfigPrefix_(SubSystemConfigPrefix) {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int RESTAPI_ExtServer::Start() {
|
inline int RESTAPI_ExtServer::Start() {
|
||||||
|
Logger().information("Starting.");
|
||||||
Server_.InitLogging();
|
Server_.InitLogging();
|
||||||
|
|
||||||
for(const auto & Svr: ConfigServersList_) {
|
for(const auto & Svr: ConfigServersList_) {
|
||||||
@@ -3944,7 +3975,6 @@ namespace OpenWifi {
|
|||||||
NewServer->start();
|
NewServer->start();
|
||||||
RESTServers_.push_back(std::move(NewServer));
|
RESTServers_.push_back(std::move(NewServer));
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4034,7 +4064,11 @@ namespace OpenWifi {
|
|||||||
auto i = 0;
|
auto i = 0;
|
||||||
bool good = true;
|
bool good = true;
|
||||||
|
|
||||||
Log_ = std::make_unique<LoggerWrapper>(Poco::Logger::get(LoggerPrefix_));
|
auto NewLevel = MicroService::instance().ConfigGetString("logging.level." + Name_, "");
|
||||||
|
if(NewLevel.empty())
|
||||||
|
Logger_ = std::make_unique<LoggerWrapper>(Poco::Logger::create(LoggerPrefix_, Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel()));
|
||||||
|
else
|
||||||
|
Logger_ = std::make_unique<LoggerWrapper>(Poco::Logger::create(LoggerPrefix_, Poco::Logger::root().getChannel(), Poco::Logger::parseLevel(NewLevel)));
|
||||||
|
|
||||||
ConfigServersList_.clear();
|
ConfigServersList_.clear();
|
||||||
while (good) {
|
while (good) {
|
||||||
@@ -4124,9 +4158,11 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
inline void BusEventManager::Stop() {
|
inline void BusEventManager::Stop() {
|
||||||
if(KafkaManager()->Enabled()) {
|
if(KafkaManager()->Enabled()) {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Running_ = false;
|
Running_ = false;
|
||||||
Thread_.wakeUp();
|
Thread_.wakeUp();
|
||||||
Thread_.join();
|
Thread_.join();
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4138,37 +4174,37 @@ namespace OpenWifi {
|
|||||||
inline void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) {
|
inline void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) {
|
||||||
switch ((cppkafka::LogLevel) level) {
|
switch ((cppkafka::LogLevel) level) {
|
||||||
case cppkafka::LogLevel::LogNotice: {
|
case cppkafka::LogLevel::LogNotice: {
|
||||||
KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_notice(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cppkafka::LogLevel::LogDebug: {
|
case cppkafka::LogLevel::LogDebug: {
|
||||||
KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_debug(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cppkafka::LogLevel::LogInfo: {
|
case cppkafka::LogLevel::LogInfo: {
|
||||||
KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_information(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cppkafka::LogLevel::LogWarning: {
|
case cppkafka::LogLevel::LogWarning: {
|
||||||
KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_warning(KafkaManager()->Logger(), fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cppkafka::LogLevel::LogAlert:
|
case cppkafka::LogLevel::LogAlert:
|
||||||
case cppkafka::LogLevel::LogCrit: {
|
case cppkafka::LogLevel::LogCrit: {
|
||||||
KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_critical(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case cppkafka::LogLevel::LogErr:
|
case cppkafka::LogLevel::LogErr:
|
||||||
case cppkafka::LogLevel::LogEmerg:
|
case cppkafka::LogLevel::LogEmerg:
|
||||||
default: {
|
default: {
|
||||||
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
poco_error(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
|
inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
|
||||||
KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason));
|
poco_error(KafkaManager()->Logger(),fmt::format("kafka-error: {}, reason: {}", error, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void AddKafkaSecurity(cppkafka::Configuration & Config) {
|
inline void AddKafkaSecurity(cppkafka::Configuration & Config) {
|
||||||
@@ -4217,11 +4253,11 @@ namespace OpenWifi {
|
|||||||
cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
|
cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
|
||||||
}
|
}
|
||||||
} catch (const cppkafka::HandleException &E) {
|
} catch (const cppkafka::HandleException &E) {
|
||||||
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (producer): {}", E.what()));
|
poco_warning(KafkaManager()->Logger(),fmt::format("Caught a Kafka exception (producer): {}", E.what()));
|
||||||
} catch( const Poco::Exception &E) {
|
} catch( const Poco::Exception &E) {
|
||||||
KafkaManager()->Logger().log(E);
|
KafkaManager()->Logger().log(E);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
KafkaManager()->Logger().error("std::exception");
|
poco_error(KafkaManager()->Logger(),"std::exception");
|
||||||
}
|
}
|
||||||
Note = Queue_.waitDequeueNotification();
|
Note = Queue_.waitDequeueNotification();
|
||||||
}
|
}
|
||||||
@@ -4281,7 +4317,7 @@ namespace OpenWifi {
|
|||||||
continue;
|
continue;
|
||||||
if (Msg.get_error()) {
|
if (Msg.get_error()) {
|
||||||
if (!Msg.is_eof()) {
|
if (!Msg.is_eof()) {
|
||||||
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
|
poco_error(KafkaManager()->Logger(),fmt::format("Error: {}", Msg.get_error().to_string()));
|
||||||
}
|
}
|
||||||
if(!AutoCommit)
|
if(!AutoCommit)
|
||||||
Consumer.async_commit(Msg);
|
Consumer.async_commit(Msg);
|
||||||
@@ -4292,11 +4328,11 @@ namespace OpenWifi {
|
|||||||
Consumer.async_commit(Msg);
|
Consumer.async_commit(Msg);
|
||||||
}
|
}
|
||||||
} catch (const cppkafka::HandleException &E) {
|
} catch (const cppkafka::HandleException &E) {
|
||||||
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
|
poco_warning(KafkaManager()->Logger(),fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
KafkaManager()->Logger().log(E);
|
KafkaManager()->Logger().log(E);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
KafkaManager()->Logger().error("std::exception");
|
poco_error(KafkaManager()->Logger(),"std::exception");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Consumer.unsubscribe();
|
Consumer.unsubscribe();
|
||||||
@@ -4748,14 +4784,15 @@ namespace OpenWifi {
|
|||||||
Contacted = true;
|
Contacted = true;
|
||||||
if(!Allowed) {
|
if(!Allowed) {
|
||||||
if(Server_.LogBadTokens(false)) {
|
if(Server_.LogBadTokens(false)) {
|
||||||
Logger_.debug(fmt::format("I-REQ-DENIED({}): Method={} Path={}",
|
poco_debug(Logger_,fmt::format("I-REQ-DENIED({}): Method={} Path={}",
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->getMethod(), Request->getURI()));
|
Request->getMethod(), Request->getURI()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto Id = Request->get("X-INTERNAL-NAME", "unknown");
|
auto Id = Request->get("X-INTERNAL-NAME", "unknown");
|
||||||
|
REST_Requester_ = Id;
|
||||||
if(Server_.LogIt(Request->getMethod(),true)) {
|
if(Server_.LogIt(Request->getMethod(),true)) {
|
||||||
Logger_.debug(fmt::format("I-REQ-ALLOWED({}): User='{}' Method={} Path={}",
|
poco_debug(Logger_,fmt::format("I-REQ-ALLOWED({}): User='{}' Method={} Path={}",
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()), Id,
|
Utils::FormatIPv6(Request->clientAddress().toString()), Id,
|
||||||
Request->getMethod(), Request->getURI()));
|
Request->getMethod(), Request->getURI()));
|
||||||
}
|
}
|
||||||
@@ -4777,8 +4814,9 @@ namespace OpenWifi {
|
|||||||
#else
|
#else
|
||||||
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired, Contacted, Sub)) {
|
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired, Contacted, Sub)) {
|
||||||
#endif
|
#endif
|
||||||
|
REST_Requester_ = UserInfo_.userinfo.email;
|
||||||
if(Server_.LogIt(Request->getMethod(),true)) {
|
if(Server_.LogIt(Request->getMethod(),true)) {
|
||||||
Logger_.debug(fmt::format("X-REQ-ALLOWED({}): User='{}@{}' Method={} Path={}",
|
poco_debug(Logger_,fmt::format("X-REQ-ALLOWED({}): User='{}@{}' Method={} Path={}",
|
||||||
UserInfo_.userinfo.email,
|
UserInfo_.userinfo.email,
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->clientAddress().toString(),
|
Request->clientAddress().toString(),
|
||||||
@@ -4788,7 +4826,7 @@ namespace OpenWifi {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(Server_.LogBadTokens(true)) {
|
if(Server_.LogBadTokens(true)) {
|
||||||
Logger_.debug(fmt::format("X-REQ-DENIED({}): Method={} Path={}",
|
poco_debug(Logger_,fmt::format("X-REQ-DENIED({}): Method={} Path={}",
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->getMethod(), Request->getURI()));
|
Request->getMethod(), Request->getURI()));
|
||||||
}
|
}
|
||||||
@@ -4859,7 +4897,7 @@ namespace OpenWifi {
|
|||||||
void run() override;
|
void run() override;
|
||||||
// MyParallelSocketReactor &ReactorPool();
|
// MyParallelSocketReactor &ReactorPool();
|
||||||
Poco::Net::SocketReactor & Reactor() { return Reactor_; }
|
Poco::Net::SocketReactor & Reactor() { return Reactor_; }
|
||||||
void NewClient(Poco::Net::WebSocket &WS, const std::string &Id);
|
void NewClient(Poco::Net::WebSocket &WS, const std::string &Id, const std::string &UserName);
|
||||||
bool Register(WebSocketClient *Client, const std::string &Id);
|
bool Register(WebSocketClient *Client, const std::string &Id);
|
||||||
void SetProcessor(WebSocketClientProcessor *F);
|
void SetProcessor(WebSocketClientProcessor *F);
|
||||||
void UnRegister(const std::string &Id);
|
void UnRegister(const std::string &Id);
|
||||||
@@ -4910,18 +4948,22 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class WebSocketClient {
|
class WebSocketClient {
|
||||||
public:
|
public:
|
||||||
explicit WebSocketClient(Poco::Net::WebSocket &WS, const std::string &Id, Poco::Logger &L,
|
explicit WebSocketClient(Poco::Net::WebSocket &WS,
|
||||||
WebSocketClientProcessor *Processor);
|
const std::string &Id,
|
||||||
|
const std::string &UserName,
|
||||||
|
Poco::Logger &L,
|
||||||
|
WebSocketClientProcessor *Processor);
|
||||||
virtual ~WebSocketClient();
|
virtual ~WebSocketClient();
|
||||||
[[nodiscard]] inline const std::string &Id();
|
[[nodiscard]] inline const std::string &Id();
|
||||||
[[nodiscard]] Poco::Logger &Logger();
|
[[nodiscard]] Poco::Logger &Logger();
|
||||||
inline bool Send(const std::string &Payload);
|
inline bool Send(const std::string &Payload);
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Poco::Net::WebSocket> WS_;
|
std::unique_ptr<Poco::Net::WebSocket> WS_;
|
||||||
Poco::Net::SocketReactor &Reactor_;
|
Poco::Net::SocketReactor &Reactor_;
|
||||||
std::string Id_;
|
std::string Id_;
|
||||||
Poco::Logger &Logger_;
|
std::string UserName_;
|
||||||
bool Authenticated_ = false;
|
Poco::Logger &Logger_;
|
||||||
|
std::atomic_bool Authenticated_ = false;
|
||||||
SecurityObjects::UserInfoAndPolicy UserInfo_;
|
SecurityObjects::UserInfoAndPolicy UserInfo_;
|
||||||
WebSocketClientProcessor *Processor_ = nullptr;
|
WebSocketClientProcessor *Processor_ = nullptr;
|
||||||
void OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf);
|
void OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf);
|
||||||
@@ -4929,33 +4971,9 @@ namespace OpenWifi {
|
|||||||
void OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf);
|
void OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* inline MyParallelSocketReactor::MyParallelSocketReactor(uint32_t NumReactors) :
|
inline void WebSocketClientServer::NewClient(Poco::Net::WebSocket & WS, const std::string &Id, const std::string &UserName ) {
|
||||||
NumReactors_(NumReactors)
|
|
||||||
{
|
|
||||||
Reactors_ = new Poco::Net::SocketReactor[NumReactors_];
|
|
||||||
for(uint32_t i=0;i<NumReactors_;i++) {
|
|
||||||
ReactorPool_.start(Reactors_[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline MyParallelSocketReactor::~MyParallelSocketReactor() {
|
|
||||||
for(uint32_t i=0;i<NumReactors_;i++) {
|
|
||||||
Reactors_[i].stop();
|
|
||||||
}
|
|
||||||
ReactorPool_.stopAll();
|
|
||||||
ReactorPool_.joinAll();
|
|
||||||
delete [] Reactors_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Poco::Net::SocketReactor & MyParallelSocketReactor::Reactor() {
|
|
||||||
return Reactors_[ rand() % NumReactors_ ];
|
|
||||||
}
|
|
||||||
|
|
||||||
// inline MyParallelSocketReactor & WebSocketClientServer::ReactorPool() { return *ReactorPool_; }
|
|
||||||
*/
|
|
||||||
inline void WebSocketClientServer::NewClient(Poco::Net::WebSocket & WS, const std::string &Id) {
|
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(Mutex_);
|
||||||
auto Client = new WebSocketClient(WS,Id,Logger(), Processor_);
|
auto Client = new WebSocketClient(WS,Id,UserName,Logger(), Processor_);
|
||||||
Clients_[Id] = std::make_pair(Client,"");
|
Clients_[Id] = std::make_pair(Client,"");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5072,6 +5090,7 @@ namespace OpenWifi {
|
|||||||
auto Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
auto Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||||
|
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
|
poco_warning(Logger(),Poco::format("CLOSE(%s): %s UI Client is closing WS connection.", Id_, UserName_));
|
||||||
return delete this;
|
return delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5084,7 +5103,7 @@ namespace OpenWifi {
|
|||||||
case Poco::Net::WebSocket::FRAME_OP_PONG: {
|
case Poco::Net::WebSocket::FRAME_OP_PONG: {
|
||||||
} break;
|
} break;
|
||||||
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
|
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
|
||||||
Logger().warning(Poco::format("CLOSE(%s): UI Client is closing its connection.", Id_));
|
poco_warning(Logger(),Poco::format("CLOSE(%s): %s UI Client is closing WS connection.", Id_, UserName_));
|
||||||
Done = true;
|
Done = true;
|
||||||
} break;
|
} break;
|
||||||
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
|
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
|
||||||
@@ -5096,6 +5115,8 @@ namespace OpenWifi {
|
|||||||
if (Tokens.size() == 2 &&
|
if (Tokens.size() == 2 &&
|
||||||
AuthClient()->IsAuthorized(Tokens[1], UserInfo_, Expired, Contacted)) {
|
AuthClient()->IsAuthorized(Tokens[1], UserInfo_, Expired, Contacted)) {
|
||||||
Authenticated_ = true;
|
Authenticated_ = true;
|
||||||
|
UserName_ = UserInfo_.userinfo.email;
|
||||||
|
poco_warning(Logger(),Poco::format("START(%s): %s UI Client is starting WS connection.", Id_, UserName_));
|
||||||
std::string S{"Welcome! Bienvenue! Bienvenidos!"};
|
std::string S{"Welcome! Bienvenue! Bienvenidos!"};
|
||||||
WS_->sendFrame(S.c_str(), S.size());
|
WS_->sendFrame(S.c_str(), S.size());
|
||||||
WebSocketClientServer()->SetUser(Id_, UserInfo_.userinfo.email);
|
WebSocketClientServer()->SetUser(Id_, UserInfo_.userinfo.email);
|
||||||
@@ -5141,9 +5162,10 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline WebSocketClient::WebSocketClient( Poco::Net::WebSocket & WS , const std::string &Id, Poco::Logger & L, WebSocketClientProcessor * Processor) :
|
inline WebSocketClient::WebSocketClient( Poco::Net::WebSocket & WS , const std::string &Id, const std::string &UserName, Poco::Logger & L, WebSocketClientProcessor * Processor) :
|
||||||
Reactor_(WebSocketClientServer()->Reactor()),
|
Reactor_(WebSocketClientServer()->Reactor()),
|
||||||
Id_(Id),
|
Id_(Id),
|
||||||
|
UserName_(UserName),
|
||||||
Logger_(L),
|
Logger_(L),
|
||||||
Processor_(Processor) {
|
Processor_(Processor) {
|
||||||
try {
|
try {
|
||||||
@@ -5157,7 +5179,10 @@ namespace OpenWifi {
|
|||||||
Reactor_.addEventHandler(*WS_,
|
Reactor_.addEventHandler(*WS_,
|
||||||
Poco::NObserver<WebSocketClient, Poco::Net::ErrorNotification>(
|
Poco::NObserver<WebSocketClient, Poco::Net::ErrorNotification>(
|
||||||
*this, &WebSocketClient::OnSocketError));
|
*this, &WebSocketClient::OnSocketError));
|
||||||
// WebSocketClientServer()->Register(this, Id_);
|
WS_->setNoDelay(true);
|
||||||
|
WS_->setKeepAlive(true);
|
||||||
|
WS_->setBlocking(false);
|
||||||
|
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
@@ -5223,9 +5248,8 @@ namespace OpenWifi {
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Poco::Net::WebSocket WS(*Request, *Response);
|
Poco::Net::WebSocket WS(*Request, *Response);
|
||||||
Logger().information("UI-WebSocket connection established.");
|
|
||||||
auto Id = MicroService::CreateUUID();
|
auto Id = MicroService::CreateUUID();
|
||||||
WebSocketClientServer()->NewClient(WS,Id);
|
WebSocketClientServer()->NewClient(WS,Id,UserInfo_.userinfo.email);
|
||||||
}
|
}
|
||||||
catch (...) {
|
catch (...) {
|
||||||
std::cout << "Cannot create websocket client..." << std::endl;
|
std::cout << "Cannot create websocket client..." << std::endl;
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ namespace OpenWifi {
|
|||||||
int Start() override {
|
int Start() override {
|
||||||
std::lock_guard Guard(Mutex_);
|
std::lock_guard Guard(Mutex_);
|
||||||
|
|
||||||
Logger().setLevel(Poco::Message::PRIO_INFORMATION);
|
|
||||||
Logger().notice("Starting.");
|
Logger().notice("Starting.");
|
||||||
std::string DBType = MicroService::instance().ConfigGetString("storage.type");
|
std::string DBType = MicroService::instance().ConfigGetString("storage.type");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user