mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-11-01 19:27:47 +00:00
Code sanitizer
This commit is contained in:
@@ -65,6 +65,10 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu
|
|||||||
|
|
||||||
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
||||||
|
|
||||||
|
add_compile_options(-Wall -Wextra)
|
||||||
|
#add_compile_options(-fsanitize=address)
|
||||||
|
#add_link_options(-fsanitize=address)
|
||||||
|
|
||||||
add_executable( owfms
|
add_executable( owfms
|
||||||
build
|
build
|
||||||
src/ow_version.h.in
|
src/ow_version.h.in
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
|||||||
Queue_.emplace_back(std::make_pair(std::move(serialNumber),std::move(DeviceType)));
|
Queue_.emplace_back(std::make_pair(std::move(serialNumber),std::move(DeviceType)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::onTimer(Poco::Timer & timer) {
|
void AutoUpdater::onTimer([[maybe_unused]] Poco::Timer & timer) {
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
std::unique_lock L(Mutex_);
|
std::unique_lock L(Mutex_);
|
||||||
while(!Queue_.empty() && Running_) {
|
while(!Queue_.empty() && Running_) {
|
||||||
@@ -96,7 +96,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AutoUpdater::reinitialize(Poco::Util::Application &self) {
|
void AutoUpdater::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
Logger().information("Reinitializing.");
|
Logger().information("Reinitializing.");
|
||||||
Reset();
|
Reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,7 @@ namespace OpenWifi {
|
|||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Daemon::initialize(Poco::Util::Application &self) {
|
void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
MicroService::initialize(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MicroServicePostInitialization() {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ namespace OpenWifi {
|
|||||||
const SubSystemVec & SubSystems) :
|
const SubSystemVec & SubSystems) :
|
||||||
MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {};
|
MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {};
|
||||||
|
|
||||||
void initialize(Poco::Util::Application &self);
|
void PostInitialization(Poco::Util::Application &self);
|
||||||
static Daemon *instance();
|
static Daemon *instance();
|
||||||
inline void ResetDashboard() { DB_.Reset(); }
|
inline void ResetDashboard() { DB_.Reset(); }
|
||||||
inline void CreateDashboard() { DB_.Create(); }
|
inline void CreateDashboard() { DB_.Create(); }
|
||||||
@@ -40,6 +40,9 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline Daemon * Daemon() { return Daemon::instance(); }
|
inline Daemon * Daemon() { return Daemon::instance(); }
|
||||||
|
inline void DaemonPostInitialization(Poco::Util::Application &self) {
|
||||||
|
Daemon()->PostInitialization(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //UCENTRALFWS_DAEMON_H
|
#endif //UCENTRALFWS_DAEMON_H
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<FMSObjects::Firmware> GetFirmware(const std::string & DeviceType, const std::string & Revision) {
|
std::shared_ptr<FMSObjects::Firmware> GetFirmware([[maybe_unused]] const std::string & DeviceType, [[maybe_unused]] const std::string & Revision) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<FMSObjects::Firmware> AddFirmware(const FMSObjects::Firmware &F) {
|
std::shared_ptr<FMSObjects::Firmware> AddFirmware([[maybe_unused]] const FMSObjects::Firmware &F) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
void ManifestCreator::onTimer(Poco::Timer &timer) {
|
void ManifestCreator::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||||
Logger().information("Performing DB refresh");
|
Logger().information("Performing DB refresh");
|
||||||
S3BucketContent BucketList;
|
S3BucketContent BucketList;
|
||||||
StorageService()->FirmwaresDB().RemoveOldFirmware();
|
StorageService()->FirmwaresDB().RemoveOldFirmware();
|
||||||
|
|||||||
@@ -29,8 +29,7 @@ namespace OpenWifi {
|
|||||||
private:
|
private:
|
||||||
Poco::Thread Worker_;
|
Poco::Thread Worker_;
|
||||||
std::atomic_bool Running_ = false;
|
std::atomic_bool Running_ = false;
|
||||||
int ConnectionWatcherId_=0;
|
uint64_t ConnectionWatcherId_=0;
|
||||||
int HealthcheckWatcherId_=0;
|
|
||||||
Types::StringPairQueue NewConnections_;
|
Types::StringPairQueue NewConnections_;
|
||||||
|
|
||||||
NewConnectionHandler() noexcept:
|
NewConnectionHandler() noexcept:
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ namespace OpenWifi::FMSObjects {
|
|||||||
snapshot = std::time(nullptr);
|
snapshot = std::time(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceReport::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -626,7 +626,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_to_json( Obj,"data",data);
|
RESTAPI_utils::field_to_json( Obj,"data",data);
|
||||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_to_json( Obj,"creator",creator);
|
RESTAPI_utils::field_to_json( Obj,"creator",creator);
|
||||||
field_to_json( Obj,"visibility",visibility);
|
RESTAPI_utils::field_to_json( Obj,"visibility",visibility);
|
||||||
RESTAPI_utils::field_to_json( Obj,"access",access);
|
RESTAPI_utils::field_to_json( Obj,"access",access);
|
||||||
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
|
RESTAPI_utils::field_to_json( Obj,"managementPolicy", managementPolicy);
|
||||||
RESTAPI_utils::field_to_json( Obj,"venue", venue);
|
RESTAPI_utils::field_to_json( Obj,"venue", venue);
|
||||||
@@ -638,7 +638,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
RESTAPI_utils::field_from_json( Obj,"data",data);
|
RESTAPI_utils::field_from_json( Obj,"data",data);
|
||||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
||||||
RESTAPI_utils::field_from_json( Obj,"creator",creator);
|
RESTAPI_utils::field_from_json( Obj,"creator",creator);
|
||||||
field_from_json( Obj,"visibility",visibility);
|
RESTAPI_utils::field_from_json( Obj,"visibility",visibility);
|
||||||
RESTAPI_utils::field_from_json( Obj,"access",access);
|
RESTAPI_utils::field_from_json( Obj,"access",access);
|
||||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
|
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
|
||||||
RESTAPI_utils::field_from_json( Obj,"venue", venue);
|
RESTAPI_utils::field_from_json( Obj,"venue", venue);
|
||||||
@@ -837,7 +837,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||||
I.modified = I.created = OpenWifi::Now();
|
I.modified = I.created = OpenWifi::Now();
|
||||||
I.id = MicroService::CreateUUID();
|
I.id = MicroService::CreateUUID();
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -400,7 +400,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string data;
|
std::string data;
|
||||||
std::string entity;
|
std::string entity;
|
||||||
std::string creator;
|
std::string creator;
|
||||||
VISIBILITY visibility = PRIVATE;
|
std::string visibility{"private"};
|
||||||
ObjectACLList access;
|
ObjectACLList access;
|
||||||
Types::UUID_t managementPolicy;
|
Types::UUID_t managementPolicy;
|
||||||
std::string venue;
|
std::string venue;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
namespace OpenWifi::SDK::GW {
|
namespace OpenWifi::SDK::GW {
|
||||||
|
|
||||||
bool SendFirmwareUpgradeCommand( const std::string & serialNumber, const std::string & URI, uint64_t When ) {
|
bool SendFirmwareUpgradeCommand( const std::string & serialNumber, const std::string & URI, [[maybe_unused]] uint64_t When ) {
|
||||||
Types::StringPairVec QueryData;
|
Types::StringPairVec QueryData;
|
||||||
Poco::JSON::Object Body;
|
Poco::JSON::Object Body;
|
||||||
|
|
||||||
|
|||||||
@@ -2614,7 +2614,7 @@ namespace OpenWifi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigurationValidator::reinitialize(Poco::Util::Application &self) {
|
void ConfigurationValidator::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
Logger().information("Reinitializing.");
|
Logger().information("Reinitializing.");
|
||||||
Working_ = Initialized_ = false;
|
Working_ = Initialized_ = false;
|
||||||
Init();
|
Init();
|
||||||
|
|||||||
@@ -80,9 +80,7 @@ using namespace std::chrono_literals;
|
|||||||
#include "framework/ow_constants.h"
|
#include "framework/ow_constants.h"
|
||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
#include "ow_version.h"
|
#include "ow_version.h"
|
||||||
|
|
||||||
#include "fmt/core.h"
|
#include "fmt/core.h"
|
||||||
|
|
||||||
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
|
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
|
||||||
@@ -301,7 +299,7 @@ namespace OpenWifi::RESTAPI_utils {
|
|||||||
Obj.set(Field, Arr);
|
Obj.set(Field, Arr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class T> void field_to_json(Poco::JSON::Object Obj, const char *Field, const T &Value) {
|
template<class T> void field_to_json(Poco::JSON::Object &Obj, const char *Field, const T &Value) {
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
Value.to_json(Answer);
|
Value.to_json(Answer);
|
||||||
Obj.set(Field, Answer);
|
Obj.set(Field, Answer);
|
||||||
@@ -575,7 +573,7 @@ namespace OpenWifi::RESTAPI_utils {
|
|||||||
try {
|
try {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
auto Object = P.parse(ObjectString).template extract<Poco::JSON::Array::Ptr>();
|
auto Object = P.parse(ObjectString).template extract<Poco::JSON::Array::Ptr>();
|
||||||
for (auto const i : *Object) {
|
for (auto const &i : *Object) {
|
||||||
auto InnerObject = i.template extract<Poco::JSON::Object::Ptr>();
|
auto InnerObject = i.template extract<Poco::JSON::Object::Ptr>();
|
||||||
T Obj;
|
T Obj;
|
||||||
Obj.from_json(InnerObject);
|
Obj.from_json(InnerObject);
|
||||||
@@ -751,15 +749,12 @@ namespace OpenWifi::Utils {
|
|||||||
|
|
||||||
using byte = std::uint8_t;
|
using byte = std::uint8_t;
|
||||||
|
|
||||||
[[nodiscard]] inline std::string base64encode(const byte *input, unsigned long size) {
|
[[nodiscard]] inline std::string base64encode(const byte *input, uint32_t size) {
|
||||||
std::string encoded;
|
std::string encoded;
|
||||||
encoded.reserve(((size / 3) + (size % 3 > 0)) * 4);
|
encoded.reserve(((size / 3) + (size % 3 > 0)) * 4);
|
||||||
|
|
||||||
std::uint32_t temp;
|
std::uint32_t temp,i,ee;
|
||||||
|
ee = (size/3);
|
||||||
std::size_t i;
|
|
||||||
|
|
||||||
int ee = (int)(size/3);
|
|
||||||
|
|
||||||
for (i = 0; i < 3*ee; ++i) {
|
for (i = 0; i < 3*ee; ++i) {
|
||||||
temp = input[i++] << 16;
|
temp = input[i++] << 16;
|
||||||
@@ -851,7 +846,7 @@ namespace OpenWifi::Utils {
|
|||||||
inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) {
|
inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) {
|
||||||
Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM);
|
Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM);
|
||||||
|
|
||||||
Hours = Minutes = Hours = 0 ;
|
Hours = Minutes = Seconds = 0 ;
|
||||||
if(TimeTokens.count()==1) {
|
if(TimeTokens.count()==1) {
|
||||||
Hours = std::atoi(TimeTokens[0].c_str());
|
Hours = std::atoi(TimeTokens[0].c_str());
|
||||||
} else if(TimeTokens.count()==2) {
|
} else if(TimeTokens.count()==2) {
|
||||||
@@ -1257,7 +1252,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
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()));
|
App_.logger().warning(fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void exception() {
|
inline void exception() {
|
||||||
@@ -1282,9 +1277,10 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger):
|
explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger):
|
||||||
PrivateKeyPassphraseHandler(true),
|
PrivateKeyPassphraseHandler(true),
|
||||||
Logger_(Logger),
|
Password_(Password),
|
||||||
Password_(Password) {}
|
Logger_(Logger)
|
||||||
void onPrivateKeyRequested(const void * pSender,std::string & privateKey) {
|
{}
|
||||||
|
void onPrivateKeyRequested([[maybe_unused]] const void * pSender,std::string & privateKey) {
|
||||||
Logger_.information("Returning key passphrase.");
|
Logger_.information("Returning key passphrase.");
|
||||||
privateKey = Password_;
|
privateKey = Password_;
|
||||||
};
|
};
|
||||||
@@ -1302,11 +1298,19 @@ namespace OpenWifi {
|
|||||||
Poco::Net::Context::VerificationMode M =
|
Poco::Net::Context::VerificationMode M =
|
||||||
Poco::Net::Context::VerificationMode::VERIFY_RELAXED,
|
Poco::Net::Context::VerificationMode::VERIFY_RELAXED,
|
||||||
int backlog = 64)
|
int backlog = 64)
|
||||||
: address_(std::move(Address)), port_(port), key_file_(std::move(Key_file)),
|
: address_(std::move(Address)),
|
||||||
cert_file_(std::move(Cert_file)), root_ca_(std::move(RootCa)),
|
port_(port),
|
||||||
issuer_cert_file_(std::move(Issuer)), client_cas_(std::move(ClientCas)),
|
cert_file_(std::move(Cert_file)),
|
||||||
cas_(std::move(Cas)), key_file_password_(std::move(Key_file_password)),
|
key_file_(std::move(Key_file)),
|
||||||
name_(std::move(Name)), level_(M), backlog_(backlog){};
|
root_ca_(std::move(RootCa)),
|
||||||
|
key_file_password_(std::move(Key_file_password)),
|
||||||
|
issuer_cert_file_(std::move(Issuer)),
|
||||||
|
client_cas_(std::move(ClientCas)),
|
||||||
|
cas_(std::move(Cas)),
|
||||||
|
name_(std::move(Name)),
|
||||||
|
backlog_(backlog),
|
||||||
|
level_(M)
|
||||||
|
{};
|
||||||
|
|
||||||
[[nodiscard]] inline const std::string &Address() const { return address_; };
|
[[nodiscard]] inline const std::string &Address() const { return address_; };
|
||||||
[[nodiscard]] inline uint32_t Port() const { return port_; };
|
[[nodiscard]] inline uint32_t Port() const { return port_; };
|
||||||
@@ -1394,7 +1398,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline Poco::Net::ServerSocket CreateSocket(Poco::Logger &L) const {
|
[[nodiscard]] inline Poco::Net::ServerSocket CreateSocket([[maybe_unused]] Poco::Logger &L) const {
|
||||||
Poco::Net::Context::Params P;
|
Poco::Net::Context::Params P;
|
||||||
|
|
||||||
if (address_ == "*") {
|
if (address_ == "*") {
|
||||||
@@ -1532,6 +1536,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::string address_;
|
std::string address_;
|
||||||
|
uint32_t port_;
|
||||||
std::string cert_file_;
|
std::string cert_file_;
|
||||||
std::string key_file_;
|
std::string key_file_;
|
||||||
std::string root_ca_;
|
std::string root_ca_;
|
||||||
@@ -1539,7 +1544,6 @@ namespace OpenWifi {
|
|||||||
std::string issuer_cert_file_;
|
std::string issuer_cert_file_;
|
||||||
std::string client_cas_;
|
std::string client_cas_;
|
||||||
std::string cas_;
|
std::string cas_;
|
||||||
uint32_t port_;
|
|
||||||
std::string name_;
|
std::string name_;
|
||||||
int backlog_;
|
int backlog_;
|
||||||
Poco::Net::Context::VerificationMode level_;
|
Poco::Net::Context::VerificationMode level_;
|
||||||
@@ -1553,10 +1557,10 @@ namespace OpenWifi {
|
|||||||
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(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().information("Reloading of this subsystem is not supported.");
|
||||||
}
|
}
|
||||||
inline void defineOptions(Poco::Util::OptionSet &options) override {
|
inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override {
|
||||||
}
|
}
|
||||||
inline const std::string & Name() const { return Name_; };
|
inline const std::string & Name() const { return Name_; };
|
||||||
inline const char * name() const override { return Name_.c_str(); }
|
inline const char * name() const override { return Name_.c_str(); }
|
||||||
@@ -1575,7 +1579,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
struct LoggerWrapper {
|
struct LoggerWrapper {
|
||||||
Poco::Logger &L;
|
Poco::Logger &L;
|
||||||
inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
|
explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -1776,17 +1780,17 @@ namespace OpenWifi {
|
|||||||
: Bindings_(std::move(map)),
|
: Bindings_(std::move(map)),
|
||||||
Logger_(l),
|
Logger_(l),
|
||||||
Methods_(std::move(Methods)),
|
Methods_(std::move(Methods)),
|
||||||
Server_(Server),
|
|
||||||
TransactionId_(TransactionId),
|
|
||||||
Internal_(Internal),
|
Internal_(Internal),
|
||||||
AlwaysAuthorize_(AlwaysAuthorize),
|
|
||||||
RateLimited_(RateLimited),
|
RateLimited_(RateLimited),
|
||||||
MyRates_(Profile),
|
SubOnlyService_(SubscriberOnly),
|
||||||
SubOnlyService_(SubscriberOnly)
|
AlwaysAuthorize_(AlwaysAuthorize),
|
||||||
{
|
Server_(Server),
|
||||||
|
MyRates_(Profile),
|
||||||
|
TransactionId_(TransactionId)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool RoleIsAuthorized(const std::string & Path, const std::string & Method, std::string & Reason) {
|
inline bool RoleIsAuthorized([[maybe_unused]] const std::string & Path, [[maybe_unused]] const std::string & Method, [[maybe_unused]] std::string & Reason) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1854,7 +1858,7 @@ namespace OpenWifi {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
bool Matched = true;
|
bool Matched = true;
|
||||||
for (auto i = 0; i != PathItems.size() && Matched; i++) {
|
for (size_t i = 0; i != PathItems.size() && Matched; i++) {
|
||||||
if (PathItems[i] != ParamItems[i]) {
|
if (PathItems[i] != ParamItems[i]) {
|
||||||
if (ParamItems[i][0] == '{') {
|
if (ParamItems[i][0] == '{') {
|
||||||
auto ParamName = ParamItems[i].substr(1, ParamItems[i].size() - 2);
|
auto ParamName = ParamItems[i].substr(1, ParamItems[i].size() - 2);
|
||||||
@@ -1938,13 +1942,13 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
[[nodiscard]] inline static std::string MakeList(const std::vector<std::string> &L) {
|
[[nodiscard]] inline static std::string MakeList(const std::vector<std::string> &L) {
|
||||||
std::string Return;
|
std::string Return;
|
||||||
for (const auto &i : L)
|
for (const auto &i : L) {
|
||||||
if (Return.empty())
|
if (Return.empty())
|
||||||
Return = i;
|
Return = i;
|
||||||
else
|
else
|
||||||
Return += ", " + i;
|
Return += ", " + i;
|
||||||
|
}
|
||||||
return Return;
|
return Return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) {
|
static inline bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, Types::UUIDvec_t & Value) {
|
||||||
@@ -2138,7 +2142,7 @@ namespace OpenWifi {
|
|||||||
Response->sendFile(File.path(),MT.ContentType);
|
Response->sendFile(File.path(),MT.ContentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SendFile(Poco::TemporaryFile &TempAvatar, const std::string &Type, const std::string & Name) {
|
inline void SendFile(Poco::TemporaryFile &TempAvatar, [[maybe_unused]] const std::string &Type, const std::string & Name) {
|
||||||
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
|
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
|
||||||
AddCORS();
|
AddCORS();
|
||||||
auto MT = Utils::FindMediaType(Name);
|
auto MT = Utils::FindMediaType(Name);
|
||||||
@@ -2243,8 +2247,9 @@ namespace OpenWifi {
|
|||||||
auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, "");
|
auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, "");
|
||||||
|
|
||||||
auto Entries = Poco::StringTokenizer(RawSelect,",");
|
auto Entries = Poco::StringTokenizer(RawSelect,",");
|
||||||
for(const auto &i:Entries)
|
for(const auto &i:Entries) {
|
||||||
QB_.Select.emplace_back(i);
|
QB_.Select.emplace_back(i);
|
||||||
|
}
|
||||||
if(QB_.Offset<1)
|
if(QB_.Offset<1)
|
||||||
QB_.Offset=0;
|
QB_.Offset=0;
|
||||||
return true;
|
return true;
|
||||||
@@ -2640,7 +2645,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) {
|
[[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) {
|
||||||
return std::move( SystemInfoWrapper_ + PayLoad + "}");
|
return SystemInfoWrapper_ + PayLoad + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
||||||
@@ -2712,7 +2717,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
|
inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
|
||||||
return ((T.expires_in_+T.created_)<std::time(nullptr));
|
return ((T.expires_in_+T.created_) < OpenWifi::Now());
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool RetrieveTokenInformation(const std::string & SessionToken,
|
inline bool RetrieveTokenInformation(const std::string & SessionToken,
|
||||||
@@ -2898,13 +2903,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
||||||
public:
|
public:
|
||||||
explicit ExtRequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
ExtRequestHandlerFactory() = default;
|
||||||
Logger_(RESTAPI_ExtServer::instance()->Logger()),
|
|
||||||
Server_(Server)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
||||||
try {
|
try {
|
||||||
Poco::URI uri(Request.getURI());
|
Poco::URI uri(Request.getURI());
|
||||||
@@ -2916,17 +2915,14 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static inline std::atomic_uint64_t TransactionId_ = 1;
|
static inline std::atomic_uint64_t TransactionId_ = 1;
|
||||||
Poco::Logger &Logger_;
|
|
||||||
RESTAPI_GenericServer &Server_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class LogMuxer : public Poco::Channel {
|
class LogMuxer : public Poco::Channel {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
inline std::string getProperty( const std::string &p ) const final {
|
inline std::string getProperty( [[maybe_unused]] const std::string &p ) const final {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2977,7 +2973,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void setProperty(const std::string &name, const std::string &value) final {
|
inline void setProperty([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) final {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3039,10 +3035,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
||||||
public:
|
public:
|
||||||
explicit IntRequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
inline IntRequestHandlerFactory() = default;
|
||||||
Logger_(RESTAPI_IntServer()->Logger()),
|
|
||||||
Server_(Server){}
|
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
||||||
Poco::URI uri(Request.getURI());
|
Poco::URI uri(Request.getURI());
|
||||||
auto *Path = uri.getPath().c_str();
|
auto *Path = uri.getPath().c_str();
|
||||||
@@ -3050,8 +3043,6 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
static inline std::atomic_uint64_t TransactionId_ = 1;
|
static inline std::atomic_uint64_t TransactionId_ = 1;
|
||||||
Poco::Logger &Logger_;
|
|
||||||
RESTAPI_GenericServer &Server_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct MicroServiceMeta {
|
struct MicroServiceMeta {
|
||||||
@@ -3198,7 +3189,6 @@ namespace OpenWifi {
|
|||||||
bool DebugMode_ = false;
|
bool DebugMode_ = false;
|
||||||
std::string DataDir_;
|
std::string DataDir_;
|
||||||
std::string WWWAssetsDir_;
|
std::string WWWAssetsDir_;
|
||||||
SubSystemVec SubSystems_;
|
|
||||||
Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
|
Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
|
||||||
Poco::Crypto::Cipher * Cipher_ = nullptr;
|
Poco::Crypto::Cipher * Cipher_ = nullptr;
|
||||||
Poco::SHA2Engine SHA2_;
|
Poco::SHA2Engine SHA2_;
|
||||||
@@ -3217,6 +3207,7 @@ namespace OpenWifi {
|
|||||||
std::string DAEMON_CONFIG_ENV_VAR;
|
std::string DAEMON_CONFIG_ENV_VAR;
|
||||||
std::string DAEMON_APP_NAME;
|
std::string DAEMON_APP_NAME;
|
||||||
uint64_t DAEMON_BUS_TIMER;
|
uint64_t DAEMON_BUS_TIMER;
|
||||||
|
SubSystemVec SubSystems_;
|
||||||
bool NoAPISecurity_=false;
|
bool NoAPISecurity_=false;
|
||||||
bool NoBuiltInCrypto_=false;
|
bool NoBuiltInCrypto_=false;
|
||||||
Poco::JWT::Signer Signer_;
|
Poco::JWT::Signer Signer_;
|
||||||
@@ -3226,7 +3217,7 @@ namespace OpenWifi {
|
|||||||
std::exit(Reason);
|
std::exit(Reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::BusMessageReceived(const std::string &Key, const std::string & Payload) {
|
inline void MicroService::BusMessageReceived([[maybe_unused]] const std::string &Key, const std::string & Payload) {
|
||||||
std::lock_guard G(InfraMutex_);
|
std::lock_guard G(InfraMutex_);
|
||||||
try {
|
try {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
@@ -3425,6 +3416,8 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DaemonPostInitialization(Poco::Util::Application &self);
|
||||||
|
|
||||||
inline void MicroService::initialize(Poco::Util::Application &self) {
|
inline void MicroService::initialize(Poco::Util::Application &self) {
|
||||||
// add the default services
|
// add the default services
|
||||||
LoadConfigurationFile();
|
LoadConfigurationFile();
|
||||||
@@ -3458,11 +3451,10 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
InitializeSubSystemServers();
|
InitializeSubSystemServers();
|
||||||
ServerApplication::initialize(self);
|
ServerApplication::initialize(self);
|
||||||
|
DaemonPostInitialization(self);
|
||||||
|
|
||||||
Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); };
|
Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); };
|
||||||
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
|
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
|
||||||
|
|
||||||
MicroServicePostInitialization();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::uninitialize() {
|
inline void MicroService::uninitialize() {
|
||||||
@@ -3512,28 +3504,28 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::handleHelp(const std::string &name, const std::string &value) {
|
inline void MicroService::handleHelp([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) {
|
||||||
HelpRequested_ = true;
|
HelpRequested_ = true;
|
||||||
displayHelp();
|
displayHelp();
|
||||||
stopOptionsProcessing();
|
stopOptionsProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::handleVersion(const std::string &name, const std::string &value) {
|
inline void MicroService::handleVersion([[maybe_unused]] const std::string &name, [[maybe_unused]] const std::string &value) {
|
||||||
HelpRequested_ = true;
|
HelpRequested_ = true;
|
||||||
std::cout << Version() << std::endl;
|
std::cout << Version() << std::endl;
|
||||||
stopOptionsProcessing();
|
stopOptionsProcessing();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::handleDebug(const std::string &name, const std::string &value) {
|
inline void MicroService::handleDebug([[maybe_unused]] const std::string &name, const std::string &value) {
|
||||||
if(value == "true")
|
if(value == "true")
|
||||||
DebugMode_ = true ;
|
DebugMode_ = true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::handleLogs(const std::string &name, const std::string &value) {
|
inline void MicroService::handleLogs([[maybe_unused]] const std::string &name, const std::string &value) {
|
||||||
LogDir_ = value;
|
LogDir_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void MicroService::handleConfig(const std::string &name, const std::string &value) {
|
inline void MicroService::handleConfig([[maybe_unused]] const std::string &name, const std::string &value) {
|
||||||
ConfigFileName_ = value;
|
ConfigFileName_ = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3688,14 +3680,16 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline std::string MicroService::Encrypt(const std::string &S) {
|
inline std::string MicroService::Encrypt(const std::string &S) {
|
||||||
if(NoBuiltInCrypto_)
|
if(NoBuiltInCrypto_) {
|
||||||
return S;
|
return S;
|
||||||
|
}
|
||||||
return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
|
return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string MicroService::Decrypt(const std::string &S) {
|
inline std::string MicroService::Decrypt(const std::string &S) {
|
||||||
if(NoBuiltInCrypto_)
|
if(NoBuiltInCrypto_) {
|
||||||
return S;
|
return S;
|
||||||
|
}
|
||||||
return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
|
return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3770,10 +3764,10 @@ namespace OpenWifi {
|
|||||||
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
|
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
|
||||||
if(MicroService::instance().NoAPISecurity()) {
|
if(MicroService::instance().NoAPISecurity()) {
|
||||||
auto Sock{Svr.CreateSocket(Logger())};
|
auto Sock{Svr.CreateSocket(Logger())};
|
||||||
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
|
||||||
} else {
|
} else {
|
||||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||||
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory, Pool_, Sock, Params);
|
||||||
};
|
};
|
||||||
NewServer->start();
|
NewServer->start();
|
||||||
RESTServers_.push_back(std::move(NewServer));
|
RESTServers_.push_back(std::move(NewServer));
|
||||||
@@ -3806,10 +3800,10 @@ namespace OpenWifi {
|
|||||||
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
|
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
|
||||||
if(MicroService::instance().NoAPISecurity()) {
|
if(MicroService::instance().NoAPISecurity()) {
|
||||||
auto Sock{Svr.CreateSocket(Logger())};
|
auto Sock{Svr.CreateSocket(Logger())};
|
||||||
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
|
||||||
} else {
|
} else {
|
||||||
auto Sock{Svr.CreateSecureSocket(Logger())};
|
auto Sock{Svr.CreateSecureSocket(Logger())};
|
||||||
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory, Pool_, Sock, Params);
|
||||||
};
|
};
|
||||||
NewServer->start();
|
NewServer->start();
|
||||||
RESTServers_.push_back(std::move(NewServer));
|
RESTServers_.push_back(std::move(NewServer));
|
||||||
@@ -3818,7 +3812,7 @@ namespace OpenWifi {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int MicroService::main(const ArgVec &args) {
|
inline int MicroService::main([[maybe_unused]] const ArgVec &args) {
|
||||||
|
|
||||||
MyErrorHandler ErrorHandler(*this);
|
MyErrorHandler ErrorHandler(*this);
|
||||||
Poco::ErrorHandler::set(&ErrorHandler);
|
Poco::ErrorHandler::set(&ErrorHandler);
|
||||||
@@ -3864,7 +3858,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SubSystemServer::initialize(Poco::Util::Application &self) {
|
inline void SubSystemServer::initialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
auto i = 0;
|
auto i = 0;
|
||||||
bool good = true;
|
bool good = true;
|
||||||
|
|
||||||
@@ -3967,39 +3961,39 @@ namespace OpenWifi {
|
|||||||
KafkaEnabled_ = MicroService::instance().ConfigGetBool("openwifi.kafka.enable",false);
|
KafkaEnabled_ = MicroService::instance().ConfigGetBool("openwifi.kafka.enable",false);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void KafkaLoggerFun(cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &messqge) {
|
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, messqge));
|
KafkaManager()->Logger().notice(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, messqge));
|
KafkaManager()->Logger().debug(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, messqge));
|
KafkaManager()->Logger().information(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, messqge));
|
KafkaManager()->Logger().warning(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, messqge));
|
KafkaManager()->Logger().critical(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, messqge));
|
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void KafkaErrorFun(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));
|
KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4072,13 +4066,13 @@ namespace OpenWifi {
|
|||||||
Config.set_default_topic_configuration(topic_config);
|
Config.set_default_topic_configuration(topic_config);
|
||||||
|
|
||||||
cppkafka::Consumer Consumer(Config);
|
cppkafka::Consumer Consumer(Config);
|
||||||
Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) {
|
Consumer.set_assignment_callback([](cppkafka::TopicPartitionList& partitions) {
|
||||||
if(!partitions.empty()) {
|
if(!partitions.empty()) {
|
||||||
KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...",
|
KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...",
|
||||||
partitions.front().get_partition()));
|
partitions.front().get_partition()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) {
|
Consumer.set_revocation_callback([](const cppkafka::TopicPartitionList& partitions) {
|
||||||
if(!partitions.empty()) {
|
if(!partitions.empty()) {
|
||||||
KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...",
|
KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...",
|
||||||
partitions.front().get_partition()));
|
partitions.front().get_partition()));
|
||||||
@@ -4119,14 +4113,14 @@ namespace OpenWifi {
|
|||||||
Consumer.unsubscribe();
|
Consumer.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RESTAPI_ExtServer::reinitialize(Poco::Util::Application &self) {
|
inline void RESTAPI_ExtServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
MicroService::instance().LoadConfigurationFile();
|
MicroService::instance().LoadConfigurationFile();
|
||||||
Logger().information("Reinitializing.");
|
Logger().information("Reinitializing.");
|
||||||
Stop();
|
Stop();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) {
|
void RESTAPI_IntServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||||
MicroService::instance().LoadConfigurationFile();
|
MicroService::instance().LoadConfigurationFile();
|
||||||
Logger().information("Reinitializing.");
|
Logger().information("Reinitializing.");
|
||||||
Stop();
|
Stop();
|
||||||
@@ -4475,7 +4469,7 @@ namespace OpenWifi {
|
|||||||
#ifdef TIP_SECURITY_SERVICE
|
#ifdef TIP_SECURITY_SERVICE
|
||||||
[[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired , bool Sub );
|
[[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired , bool Sub );
|
||||||
#endif
|
#endif
|
||||||
inline bool RESTAPIHandler::IsAuthorized( bool & Expired , bool & Contacted , bool Sub ) {
|
inline bool RESTAPIHandler::IsAuthorized( bool & Expired , [[maybe_unused]] bool & Contacted , bool Sub ) {
|
||||||
if(Internal_ && Request->has("X-INTERNAL-NAME")) {
|
if(Internal_ && Request->has("X-INTERNAL-NAME")) {
|
||||||
auto Allowed = MicroService::instance().IsValidAPIKEY(*Request);
|
auto Allowed = MicroService::instance().IsValidAPIKEY(*Request);
|
||||||
if(!Allowed) {
|
if(!Allowed) {
|
||||||
|
|||||||
@@ -108,11 +108,11 @@ namespace ORM {
|
|||||||
return "LONGBLOB";
|
return "LONGBLOB";
|
||||||
else if(Type==OpenWifi::DBType::pgsql)
|
else if(Type==OpenWifi::DBType::pgsql)
|
||||||
return "BYTEA";
|
return "BYTEA";
|
||||||
else if(Type==OpenWifi::DBType::sqlite)
|
else
|
||||||
return "BLOB";
|
return "BLOB";
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
assert(false);
|
assert(false);
|
||||||
return "";
|
return "";
|
||||||
@@ -121,12 +121,13 @@ namespace ORM {
|
|||||||
inline std::string Escape(const std::string &S) {
|
inline std::string Escape(const std::string &S) {
|
||||||
std::string R;
|
std::string R;
|
||||||
|
|
||||||
for(const auto &i:S)
|
for(const auto &i:S) {
|
||||||
if(i=='\'')
|
if (i == '\'')
|
||||||
R += "''";
|
R += "''";
|
||||||
else
|
else
|
||||||
R += i;
|
R += i;
|
||||||
return R;
|
}
|
||||||
|
return R;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE };
|
enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE };
|
||||||
@@ -157,7 +158,9 @@ namespace ORM {
|
|||||||
|
|
||||||
template <typename RecordType> class DBCache {
|
template <typename RecordType> class DBCache {
|
||||||
public:
|
public:
|
||||||
DBCache(unsigned Size, unsigned Timeout)
|
DBCache(unsigned Size, unsigned Timeout) :
|
||||||
|
Size_(Size),
|
||||||
|
Timeout_(Timeout)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -166,7 +169,8 @@ namespace ORM {
|
|||||||
virtual void UpdateCache(const RecordType &R)=0;
|
virtual void UpdateCache(const RecordType &R)=0;
|
||||||
virtual void Delete(const std::string &FieldName, const std::string &Value)=0;
|
virtual void Delete(const std::string &FieldName, const std::string &Value)=0;
|
||||||
private:
|
private:
|
||||||
|
size_t Size_=0;
|
||||||
|
uint64_t Timeout_=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename RecordTuple, typename RecordType> class DB {
|
template <typename RecordTuple, typename RecordType> class DB {
|
||||||
@@ -182,8 +186,8 @@ namespace ORM {
|
|||||||
Poco::Logger &L,
|
Poco::Logger &L,
|
||||||
const char *Prefix,
|
const char *Prefix,
|
||||||
DBCache<RecordType> * Cache=nullptr):
|
DBCache<RecordType> * Cache=nullptr):
|
||||||
Type_(dbtype),
|
|
||||||
TableName_(TableName),
|
TableName_(TableName),
|
||||||
|
Type_(dbtype),
|
||||||
Pool_(Pool),
|
Pool_(Pool),
|
||||||
Logger_(L),
|
Logger_(L),
|
||||||
Prefix_(Prefix),
|
Prefix_(Prefix),
|
||||||
@@ -290,7 +294,7 @@ namespace ORM {
|
|||||||
return std::string("(")+P1 + BOPS[BOP] + P2 +")";
|
return std::string("(")+P1 + BOPS[BOP] + P2 +")";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string OP( bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) {
|
std::string OP( [[maybe_unused]] bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) {
|
||||||
return P1 + BOPS[BOP] + P2 +")";
|
return P1 + BOPS[BOP] + P2 +")";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -865,19 +869,19 @@ namespace ORM {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
std::string TableName_;
|
||||||
|
OpenWifi::DBType Type_;
|
||||||
Poco::Data::SessionPool &Pool_;
|
Poco::Data::SessionPool &Pool_;
|
||||||
Poco::Logger &Logger_;
|
Poco::Logger &Logger_;
|
||||||
std::string TableName_;
|
std::string Prefix_;
|
||||||
DBCache<RecordType> *Cache_= nullptr;
|
DBCache<RecordType> *Cache_= nullptr;
|
||||||
private:
|
private:
|
||||||
OpenWifi::DBType Type_;
|
|
||||||
std::string CreateFields_;
|
std::string CreateFields_;
|
||||||
std::string SelectFields_;
|
std::string SelectFields_;
|
||||||
std::string SelectList_;
|
std::string SelectList_;
|
||||||
std::string UpdateFields_;
|
std::string UpdateFields_;
|
||||||
std::vector<std::string> IndexCreation_;
|
std::vector<std::string> IndexCreation_;
|
||||||
std::map<std::string,int> FieldNames_;
|
std::map<std::string,int> FieldNames_;
|
||||||
std::string Prefix_;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,16 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
|
|
||||||
|
#if defined(__GNUC__)
|
||||||
|
#pragma GCC diagnostic push
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace OpenWifi::RESTAPI::Errors {
|
namespace OpenWifi::RESTAPI::Errors {
|
||||||
static const std::string MissingUUID{"Missing UUID."};
|
static const std::string MissingUUID{"Missing UUID."};
|
||||||
static const std::string MissingSerialNumber{"Missing Serial Number."};
|
static const std::string MissingSerialNumber{"Missing Serial Number."};
|
||||||
@@ -353,4 +363,12 @@ namespace OpenWifi::Provisioning::DeviceClass {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(__GNUC__ )
|
||||||
|
#pragma GCC diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(__clang__)
|
||||||
|
#pragma clang diagnostic pop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace OpenWifi {
|
|||||||
class DevicesDB : public ORM::DB<DevicesRecordTuple, FMSObjects::DeviceConnectionInformation> {
|
class DevicesDB : public ORM::DB<DevicesRecordTuple, FMSObjects::DeviceConnectionInformation> {
|
||||||
public:
|
public:
|
||||||
DevicesDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
DevicesDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
|
virtual ~DevicesDB() {};
|
||||||
bool SetDeviceRevision(std::string &SerialNumber, std::string & Revision, std::string & DeviceType, std::string &EndPoint);
|
bool SetDeviceRevision(std::string &SerialNumber, std::string & Revision, std::string & DeviceType, std::string &EndPoint);
|
||||||
bool DeleteDevice( std::string & SerialNumber);
|
bool DeleteDevice( std::string & SerialNumber);
|
||||||
bool SetDeviceDisconnected(std::string &SerialNumber, std::string &EndPoint);
|
bool SetDeviceDisconnected(std::string &SerialNumber, std::string &EndPoint);
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ namespace OpenWifi {
|
|||||||
class FirmwaresDB : public ORM::DB<FirmwaresRecordTuple, FMSObjects::Firmware> {
|
class FirmwaresDB : public ORM::DB<FirmwaresRecordTuple, FMSObjects::Firmware> {
|
||||||
public:
|
public:
|
||||||
FirmwaresDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
FirmwaresDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
|
virtual ~FirmwaresDB() {};
|
||||||
|
|
||||||
bool AddFirmware(FMSObjects::Firmware & F);
|
bool AddFirmware(FMSObjects::Firmware & F);
|
||||||
bool UpdateFirmware(std::string & ID, FMSObjects::Firmware & F);
|
bool UpdateFirmware(std::string & ID, FMSObjects::Firmware & F);
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ namespace OpenWifi {
|
|||||||
return AddHistory(History);
|
return AddHistory(History);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryDB::DeleteHistory(std::string &SerialNumber, std::string &Id) {
|
bool HistoryDB::DeleteHistory([[maybe_unused]] std::string &SerialNumber, std::string &Id) {
|
||||||
return DeleteRecord("id", Id);
|
return DeleteRecord("id", Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ namespace OpenWifi {
|
|||||||
class HistoryDB : public ORM::DB<HistoryRecordTuple, FMSObjects::RevisionHistoryEntry> {
|
class HistoryDB : public ORM::DB<HistoryRecordTuple, FMSObjects::RevisionHistoryEntry> {
|
||||||
public:
|
public:
|
||||||
HistoryDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
HistoryDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
|
virtual ~HistoryDB() {};
|
||||||
|
|
||||||
bool GetHistory(const std::string &SerialNumber, uint64_t From, uint64_t HowMany,
|
bool GetHistory(const std::string &SerialNumber, uint64_t From, uint64_t HowMany,
|
||||||
FMSObjects::RevisionHistoryEntryVec &History);
|
FMSObjects::RevisionHistoryEntryVec &History);
|
||||||
|
|||||||
Reference in New Issue
Block a user