Code analyzer fixes.

This commit is contained in:
stephb9959
2022-03-25 11:50:01 -07:00
parent 84376a07c9
commit c6efb7a80b
49 changed files with 205 additions and 174 deletions

View File

@@ -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)
add_compile_options(-Wall -Wextra)
#add_compile_options(-fsanitize=address)
#add_link_options(-fsanitize=address)
add_executable(owprov
build
src/ow_version.h.in

2
build
View File

@@ -1 +1 @@
66
71

View File

@@ -37,7 +37,7 @@ namespace OpenWifi {
return false;
}
static void ShowJSON(const char *S, const Poco::JSON::Object::Ptr &Obj) {
static void ShowJSON([[maybe_unused]] const char *S, [[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
/*
std::stringstream O;
Poco::JSON::Stringifier::stringify(Obj,O);
@@ -286,7 +286,7 @@ namespace OpenWifi {
} else {
// we need to insert after everything bigger or equal
auto Hint = std::lower_bound(Config_.cbegin(),Config_.cend(),i.weight,
[](const VerboseElement &Elem, int Value) {
[](const VerboseElement &Elem, uint64_t Value) {
return Elem.element.weight>=Value; });
VerboseElement VE{ .element = i, .info = Config.info};
Config_.insert(Hint,VE);

View File

@@ -25,27 +25,27 @@ namespace OpenWifi {
return false;
}
void ConfigSanityChecker::Check_radios(nlohmann::json &d) {
void ConfigSanityChecker::Check_radios([[maybe_unused]] nlohmann::json &d) {
std::cout << "Validating radios" << std::endl;
};
void ConfigSanityChecker::Check_interfaces(nlohmann::json &d) {
void ConfigSanityChecker::Check_interfaces([[maybe_unused]] nlohmann::json &d) {
std::cout << "Validating interfaces" << std::endl;
};
void ConfigSanityChecker::Check_metrics(nlohmann::json &d) {
void ConfigSanityChecker::Check_metrics([[maybe_unused]] nlohmann::json &d) {
std::cout << "Validating metrics" << std::endl;
};
void ConfigSanityChecker::Check_services(nlohmann::json &d) {
void ConfigSanityChecker::Check_services([[maybe_unused]] nlohmann::json &d) {
std::cout << "Validating services" << std::endl;
};
void ConfigSanityChecker::Check_uuid(nlohmann::json &d) {
void ConfigSanityChecker::Check_uuid([[maybe_unused]] nlohmann::json &d) {
std::cout << "Validating uuid" << std::endl;
};

View File

@@ -48,7 +48,7 @@ namespace OpenWifi {
return instance_;
}
void Daemon::initialize() {
void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) {
if(MicroService::instance().ConfigGetBool("firmware.updater.upgrade",false)) {
if(MicroService::instance().ConfigGetBool("firmware.updater.releaseonly",false)) {
FWRules_ = ProvObjects::upgrade_release_only;
@@ -69,10 +69,6 @@ namespace OpenWifi {
}
}
}
void MicroServicePostInitialization() {
Daemon()->initialize();
}
}
int main(int argc, char **argv) {

View File

@@ -37,12 +37,13 @@ namespace OpenWifi {
const SubSystemVec & SubSystems) :
MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {};
void initialize();
static Daemon *instance();
inline OpenWifi::ProvisioningDashboard & GetDashboard() { return DB_; }
Poco::Logger & Log() { return Poco::Logger::get(AppName()); }
ProvObjects::FIRMWARE_UPGRADE_RULES FirmwareRules() const { return FWRules_; }
inline const std::string & AssetDir() { return AssetDir_; }
void PostInitialization(Poco::Util::Application &self);
private:
static Daemon *instance_;
OpenWifi::ProvisioningDashboard DB_{};
@@ -51,5 +52,7 @@ namespace OpenWifi {
};
inline Daemon * Daemon() { return Daemon::instance(); }
}
inline void DaemonPostInitialization(Poco::Util::Application &self) {
Daemon()->PostInitialization(self);
}}

View File

@@ -31,7 +31,7 @@ namespace OpenWifi {
Timer_.stop();
}
inline void onTimer(Poco::Timer & timer) {
inline void onTimer([[maybe_unused]] Poco::Timer & timer) {
UpdateDeviceTypes();
}

View File

@@ -19,7 +19,7 @@ namespace OpenWifi {
Logger().notice("Stopping.");
}
void FileDownloader::onTimer(Poco::Timer &timer) {
void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {
const static std::vector<std::pair<std::string,std::string>> Files
{
{"https://raw.githubusercontent.com/blogic/ucentral-schema/main/ucentral.schema.json", "ucentral.schema.json" },

View File

@@ -73,7 +73,7 @@ namespace OpenWifi {
std::string Description_;
std::string RegisteredName_;
ParametersVec Parameters_;
bool Parallel_=true;
[[maybe_unused]] bool Parallel_=true;
};
class JobRegistry {

View File

@@ -45,7 +45,7 @@ namespace OpenWifi{
return OK();
}
static auto ValidateVisibility(const std::string &V) {
static bool ValidateVisibility(const std::string &V) {
return (V=="private" || V=="public" || V=="select");
}
@@ -65,6 +65,10 @@ namespace OpenWifi{
return BadRequest( RESTAPI::Errors::NameMustBeSet);
}
if(!ValidateVisibility(NewObject.visibility)) {
return BadRequest("Invalid visibility attribute");
}
if(RawObject->has("entity")) {
if(!NewObject.entity.empty() && !StorageService()->EntityDB().Exists("id",NewObject.entity))
return BadRequest(RESTAPI::Errors::EntityMustExist);
@@ -108,10 +112,10 @@ namespace OpenWifi{
}
if(Existing.creator != UserInfo_.userinfo.id) {
if(Existing.visibility == ProvObjects::PRIVATE) {
if(Existing.visibility == "private") {
return UnAuthorized(RESTAPI::Errors::InsufficientAccessRights, ACCESS_DENIED);
}
if(Existing.visibility == ProvObjects::SELECT) {
if(Existing.visibility == "select") {
for(const auto &i:Existing.access.list) {
for(const auto &j:i.users.list) {
if(j==UserInfo_.userinfo.id) {

View File

@@ -140,9 +140,6 @@ namespace OpenWifi {
auto Command = O->get("command").toString();
if (Command == "serial_number_search" && O->has("serial_prefix")) {
auto Prefix = O->get("serial_prefix").toString();
uint64_t HowMany = 32;
if (O->has("howMany"))
HowMany = O->get("howMany");
Logger().information(Poco::format("serial_number_search: %s", Prefix));
if (!Prefix.empty() && Prefix.length() < 13) {
std::vector<uint64_t> Numbers;

View File

@@ -236,7 +236,7 @@ namespace OpenWifi::FMSObjects {
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 {
return true;

View File

@@ -626,7 +626,7 @@ namespace OpenWifi::ProvObjects {
RESTAPI_utils::field_to_json( Obj,"data",data);
RESTAPI_utils::field_to_json( Obj,"entity",entity);
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,"managementPolicy", managementPolicy);
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,"entity",entity);
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,"managementPolicy", managementPolicy);
RESTAPI_utils::field_from_json( Obj,"venue", venue);
@@ -837,7 +837,7 @@ namespace OpenWifi::ProvObjects {
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.id = MicroService::CreateUUID();
return true;

View File

@@ -400,7 +400,7 @@ namespace OpenWifi::ProvObjects {
std::string data;
std::string entity;
std::string creator;
VISIBILITY visibility = PRIVATE;
std::string visibility{"private"};
ObjectACLList access;
Types::UUID_t managementPolicy;
std::string venue;

View File

@@ -37,7 +37,7 @@ namespace OpenWifi {
private:
int DeviceTypeIndex_=0;
uint64_t LastUpdate_ = 0 ;
[[maybe_unused]] uint64_t LastUpdate_ = 0 ;
SerialCacheContent SNs_;
std::map<std::string,int> DeviceTypeDictionary_;

View File

@@ -35,7 +35,7 @@ namespace OpenWifi {
Worker_.join();
}
void Signup::onTimer(Poco::Timer &timer) {
void Signup::onTimer([[maybe_unused]] Poco::Timer &timer) {
std::lock_guard G(Mutex_);
StorageService()->SignupDB().RemoveIncompleteSignups();
}

View File

@@ -66,11 +66,11 @@ namespace OpenWifi {
ExpandFunc_[ConfigurationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return ConfigurationDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[LocationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return LocationDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[RolesDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return RolesDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); };
ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; };
ExpandFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return MapDB_->Exists(F,V);; };
ExpandFunc_[SignupDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SignupDB_->Exists(F,V);; };
ExpandFunc_[VariablesDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return VariablesDB_->Exists(F,V);; };
ExpandFunc_[TagsDictionaryDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return TagsDictionaryDB_->Exists(F,V); };
ExpandFunc_[TagsObjectDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return TagsObjectDB_->Exists(F,V);; };
ExpandFunc_[MapDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return MapDB_->Exists(F,V);; };
ExpandFunc_[SignupDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return SignupDB_->Exists(F,V);; };
ExpandFunc_[VariablesDB_->Prefix()] = [=](const char *F, std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return VariablesDB_->Exists(F,V);; };
EntityDB_->CheckForRoot();
InventoryDB_->InitializeSerialCache();
@@ -82,7 +82,7 @@ namespace OpenWifi {
return 0;
}
void Storage::onTimer(Poco::Timer &timer) {
void Storage::onTimer([[maybe_unused]] Poco::Timer &timer) {
}
void Storage::Stop() {

View File

@@ -10,7 +10,7 @@ namespace OpenWifi {
// we need to get the entire dictionary in memory...
// std::function<bool(const TagsDictionary &)> Function = [](const TagsDictionary &D) -> bool { return true; };
StorageService()->TagsDictionaryDB().Iterate([](const TagsDictionary &D) -> bool { return true; });
StorageService()->TagsDictionaryDB().Iterate([]([[maybe_unused]] const TagsDictionary &D) -> bool { return true; });
return 0;

View File

@@ -32,7 +32,7 @@ namespace OpenWifi {
}
};
void WebSocketClient::OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf) {
void WebSocketClient::OnSocketError([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf) {
delete this;
}
@@ -45,7 +45,7 @@ namespace OpenWifi {
return false;
}
void WebSocketClient::OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
void WebSocketClient::OnSocketReadable([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
int flags;
int n;
bool Done=false;
@@ -96,7 +96,7 @@ namespace OpenWifi {
std::string Answer;
Process(Obj, Answer, Done );
if (!Answer.empty())
WS_->sendFrame(Answer.c_str(), Answer.size());
WS_->sendFrame(Answer.c_str(), (int) Answer.size());
else {
WS_->sendFrame("{}", 2);
}
@@ -117,7 +117,7 @@ namespace OpenWifi {
}
}
void WebSocketClient::OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
void WebSocketClient::OnSocketShutdown([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
delete this;
}
@@ -127,9 +127,6 @@ namespace OpenWifi {
auto Command = O->get("command").toString();
if (Command == "serial_number_search" && O->has("serial_prefix")) {
auto Prefix = O->get("serial_prefix").toString();
uint64_t HowMany = 32;
if (O->has("howMany"))
HowMany = O->get("howMany");
Logger().information(Poco::format("serial_number_search: %s", Prefix));
if (!Prefix.empty() && Prefix.length() < 13) {
std::vector<uint64_t> Numbers;

View File

@@ -17,17 +17,17 @@ namespace OpenWifi {
class MyParallelSocketReactor {
public:
explicit MyParallelSocketReactor(unsigned NumReactors=8) :
explicit MyParallelSocketReactor(uint32_t NumReactors=8) :
NumReactors_(NumReactors)
{
Reactors_ = new Poco::Net::SocketReactor[NumReactors_];
for(int i=0;i<NumReactors_;i++) {
for(uint32_t i=0;i<NumReactors_;i++) {
ReactorPool_.start(Reactors_[i]);
}
}
~MyParallelSocketReactor() {
for(int i=0;i<NumReactors_;i++) {
for(uint32_t i=0;i<NumReactors_;i++) {
Reactors_[i].stop();
}
ReactorPool_.stopAll();
@@ -40,7 +40,7 @@ namespace OpenWifi {
}
private:
unsigned NumReactors_;
uint32_t NumReactors_;
Poco::Net::SocketReactor * Reactors_;
Poco::ThreadPool ReactorPool_;
};

View File

@@ -2609,13 +2609,12 @@ namespace OpenWifi {
return false;
} catch(...) {
std::cout << "4 Some kind of bullshit exception..." << std::endl;
return false;
}
}
return true;
}
void ConfigurationValidator::reinitialize(Poco::Util::Application &self) {
void ConfigurationValidator::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
Logger().information("Reinitializing.");
Working_ = Initialized_ = false;
Init();

View File

@@ -80,9 +80,7 @@ using namespace std::chrono_literals;
#include "framework/ow_constants.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "nlohmann/json.hpp"
#include "ow_version.h"
#include "fmt/core.h"
#define _OWDEBUG_ std::cout<< __FILE__ <<":" << __LINE__ << std::endl;
@@ -575,7 +573,7 @@ namespace OpenWifi::RESTAPI_utils {
try {
Poco::JSON::Parser P;
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>();
T Obj;
Obj.from_json(InnerObject);
@@ -751,15 +749,12 @@ namespace OpenWifi::Utils {
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;
encoded.reserve(((size / 3) + (size % 3 > 0)) * 4);
std::uint32_t temp;
std::size_t i;
int ee = (int)(size/3);
std::uint32_t temp,i,ee;
ee = (size/3);
for (i = 0; i < 3*ee; ++i) {
temp = input[i++] << 16;
@@ -851,7 +846,7 @@ namespace OpenWifi::Utils {
inline bool ParseTime(const std::string &Time, int & Hours, int & Minutes, int & Seconds) {
Poco::StringTokenizer TimeTokens(Time,":",Poco::StringTokenizer::TOK_TRIM);
Hours = Minutes = Hours = 0 ;
Hours = Minutes = Seconds = 0 ;
if(TimeTokens.count()==1) {
Hours = std::atoi(TimeTokens[0].c_str());
} else if(TimeTokens.count()==2) {
@@ -1257,7 +1252,7 @@ namespace OpenWifi {
inline void exception(const std::exception & E) {
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() {
@@ -1282,9 +1277,10 @@ namespace OpenWifi {
public:
explicit MyPrivateKeyPassphraseHandler(const std::string &Password, Poco::Logger & Logger):
PrivateKeyPassphraseHandler(true),
Logger_(Logger),
Password_(Password) {}
void onPrivateKeyRequested(const void * pSender,std::string & privateKey) {
Password_(Password),
Logger_(Logger)
{}
void onPrivateKeyRequested([[maybe_unused]] const void * pSender,std::string & privateKey) {
Logger_.information("Returning key passphrase.");
privateKey = Password_;
};
@@ -1302,11 +1298,19 @@ namespace OpenWifi {
Poco::Net::Context::VerificationMode M =
Poco::Net::Context::VerificationMode::VERIFY_RELAXED,
int backlog = 64)
: address_(std::move(Address)), port_(port), key_file_(std::move(Key_file)),
cert_file_(std::move(Cert_file)), root_ca_(std::move(RootCa)),
issuer_cert_file_(std::move(Issuer)), client_cas_(std::move(ClientCas)),
cas_(std::move(Cas)), key_file_password_(std::move(Key_file_password)),
name_(std::move(Name)), level_(M), backlog_(backlog){};
: address_(std::move(Address)),
port_(port),
cert_file_(std::move(Cert_file)),
key_file_(std::move(Key_file)),
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 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;
if (address_ == "*") {
@@ -1532,6 +1536,7 @@ namespace OpenWifi {
private:
std::string address_;
uint32_t port_;
std::string cert_file_;
std::string key_file_;
std::string root_ca_;
@@ -1539,7 +1544,6 @@ namespace OpenWifi {
std::string issuer_cert_file_;
std::string client_cas_;
std::string cas_;
uint32_t port_;
std::string name_;
int backlog_;
Poco::Net::Context::VerificationMode level_;
@@ -1553,10 +1557,10 @@ namespace OpenWifi {
inline void initialize(Poco::Util::Application &self) 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.");
}
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 char * name() const override { return Name_.c_str(); }
@@ -1575,7 +1579,7 @@ namespace OpenWifi {
struct LoggerWrapper {
Poco::Logger &L;
inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
};
protected:
@@ -1776,17 +1780,17 @@ namespace OpenWifi {
: Bindings_(std::move(map)),
Logger_(l),
Methods_(std::move(Methods)),
Server_(Server),
TransactionId_(TransactionId),
Internal_(Internal),
AlwaysAuthorize_(AlwaysAuthorize),
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;
}
@@ -1854,7 +1858,7 @@ namespace OpenWifi {
continue;
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 (ParamItems[i][0] == '{') {
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) {
std::string Return;
for (const auto &i : L)
if (Return.empty())
Return = i;
else
Return += ", " + i;
return Return;
for (const auto &i : L) {
if (Return.empty())
Return = i;
else
Return += ", " + i;
}
return Return;
}
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);
}
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);
AddCORS();
auto MT = Utils::FindMediaType(Name);
@@ -2243,8 +2247,9 @@ namespace OpenWifi {
auto RawSelect = GetParameter(RESTAPI::Protocol::SELECT, "");
auto Entries = Poco::StringTokenizer(RawSelect,",");
for(const auto &i:Entries)
for(const auto &i:Entries) {
QB_.Select.emplace_back(i);
}
if(QB_.Offset<1)
QB_.Offset=0;
return true;
@@ -2640,7 +2645,7 @@ namespace OpenWifi {
}
[[nodiscard]] inline std::string WrapSystemId(const std::string & PayLoad) {
return std::move( SystemInfoWrapper_ + PayLoad + "}");
return SystemInfoWrapper_ + PayLoad + "}";
}
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
@@ -2712,7 +2717,7 @@ namespace OpenWifi {
}
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,
@@ -2898,13 +2903,7 @@ namespace OpenWifi {
class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
public:
explicit ExtRequestHandlerFactory(RESTAPI_GenericServer & Server) :
Logger_(RESTAPI_ExtServer::instance()->Logger()),
Server_(Server)
{
}
ExtRequestHandlerFactory() = default;
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
try {
Poco::URI uri(Request.getURI());
@@ -2916,17 +2915,14 @@ namespace OpenWifi {
}
return nullptr;
}
private:
static inline std::atomic_uint64_t TransactionId_ = 1;
Poco::Logger &Logger_;
RESTAPI_GenericServer &Server_;
};
class LogMuxer : public Poco::Channel {
public:
inline std::string getProperty( const std::string &p ) const final {
inline std::string getProperty( [[maybe_unused]] const std::string &p ) const final {
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 {
public:
explicit IntRequestHandlerFactory(RESTAPI_GenericServer & Server) :
Logger_(RESTAPI_IntServer()->Logger()),
Server_(Server){}
inline IntRequestHandlerFactory() = default;
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
Poco::URI uri(Request.getURI());
auto *Path = uri.getPath().c_str();
@@ -3050,8 +3043,6 @@ namespace OpenWifi {
}
private:
static inline std::atomic_uint64_t TransactionId_ = 1;
Poco::Logger &Logger_;
RESTAPI_GenericServer &Server_;
};
struct MicroServiceMeta {
@@ -3198,7 +3189,6 @@ namespace OpenWifi {
bool DebugMode_ = false;
std::string DataDir_;
std::string WWWAssetsDir_;
SubSystemVec SubSystems_;
Poco::Crypto::CipherFactory & CipherFactory_ = Poco::Crypto::CipherFactory::defaultFactory();
Poco::Crypto::Cipher * Cipher_ = nullptr;
Poco::SHA2Engine SHA2_;
@@ -3217,6 +3207,7 @@ namespace OpenWifi {
std::string DAEMON_CONFIG_ENV_VAR;
std::string DAEMON_APP_NAME;
uint64_t DAEMON_BUS_TIMER;
SubSystemVec SubSystems_;
bool NoAPISecurity_=false;
bool NoBuiltInCrypto_=false;
Poco::JWT::Signer Signer_;
@@ -3226,7 +3217,7 @@ namespace OpenWifi {
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_);
try {
Poco::JSON::Parser P;
@@ -3425,8 +3416,11 @@ namespace OpenWifi {
}
}
void DaemonPostInitialization(Poco::Util::Application &self);
inline void MicroService::initialize(Poco::Util::Application &self) {
// add the default services
std::cout << "Initialize MicroService" << std::endl;
LoadConfigurationFile();
InitializeLoggingSystem();
@@ -3458,11 +3452,10 @@ namespace OpenWifi {
InitializeSubSystemServers();
ServerApplication::initialize(self);
DaemonPostInitialization(self);
Types::TopicNotifyFunction F = [this](const std::string &Key,const std::string &Payload) { this->BusMessageReceived(Key, Payload); };
KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
MicroServicePostInitialization();
}
inline void MicroService::uninitialize() {
@@ -3512,28 +3505,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;
displayHelp();
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;
std::cout << Version() << std::endl;
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")
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;
}
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;
}
@@ -3688,14 +3681,16 @@ namespace OpenWifi {
}
inline std::string MicroService::Encrypt(const std::string &S) {
if(NoBuiltInCrypto_)
if(NoBuiltInCrypto_) {
return S;
}
return Cipher_->encryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
}
inline std::string MicroService::Decrypt(const std::string &S) {
if(NoBuiltInCrypto_)
if(NoBuiltInCrypto_) {
return S;
}
return Cipher_->decryptString(S, Poco::Crypto::Cipher::Cipher::ENC_BASE64);;
}
@@ -3770,10 +3765,10 @@ namespace OpenWifi {
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
if(MicroService::instance().NoAPISecurity()) {
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 {
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();
RESTServers_.push_back(std::move(NewServer));
@@ -3806,10 +3801,10 @@ namespace OpenWifi {
std::unique_ptr<Poco::Net::HTTPServer> NewServer;
if(MicroService::instance().NoAPISecurity()) {
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 {
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();
RESTServers_.push_back(std::move(NewServer));
@@ -3818,7 +3813,7 @@ namespace OpenWifi {
return 0;
}
inline int MicroService::main(const ArgVec &args) {
inline int MicroService::main([[maybe_unused]] const ArgVec &args) {
MyErrorHandler ErrorHandler(*this);
Poco::ErrorHandler::set(&ErrorHandler);
@@ -3864,7 +3859,7 @@ namespace OpenWifi {
}
}
inline void SubSystemServer::initialize(Poco::Util::Application &self) {
inline void SubSystemServer::initialize([[maybe_unused]] Poco::Util::Application &self) {
auto i = 0;
bool good = true;
@@ -3967,39 +3962,39 @@ namespace OpenWifi {
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) {
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;
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;
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;
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;
case cppkafka::LogLevel::LogAlert:
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;
case cppkafka::LogLevel::LogErr:
case cppkafka::LogLevel::LogEmerg:
default: {
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, messqge));
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
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));
}
@@ -4072,13 +4067,13 @@ namespace OpenWifi {
Config.set_default_topic_configuration(topic_config);
cppkafka::Consumer Consumer(Config);
Consumer.set_assignment_callback([this](cppkafka::TopicPartitionList& partitions) {
Consumer.set_assignment_callback([](cppkafka::TopicPartitionList& partitions) {
if(!partitions.empty()) {
KafkaManager()->Logger().information(fmt::format("Partition assigned: {}...",
partitions.front().get_partition()));
}
});
Consumer.set_revocation_callback([this](const cppkafka::TopicPartitionList& partitions) {
Consumer.set_revocation_callback([](const cppkafka::TopicPartitionList& partitions) {
if(!partitions.empty()) {
KafkaManager()->Logger().information(fmt::format("Partition revocation: {}...",
partitions.front().get_partition()));
@@ -4119,14 +4114,14 @@ namespace OpenWifi {
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();
Logger().information("Reinitializing.");
Stop();
Start();
}
void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) {
void RESTAPI_IntServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
MicroService::instance().LoadConfigurationFile();
Logger().information("Reinitializing.");
Stop();

View File

@@ -108,11 +108,11 @@ namespace ORM {
return "LONGBLOB";
else if(Type==OpenWifi::DBType::pgsql)
return "BYTEA";
else if(Type==OpenWifi::DBType::sqlite)
else
return "BLOB";
default:
assert(false);
return "";
default:
assert(false);
}
assert(false);
return "";
@@ -121,12 +121,13 @@ namespace ORM {
inline std::string Escape(const std::string &S) {
std::string R;
for(const auto &i:S)
if(i=='\'')
for(const auto &i:S) {
if (i == '\'')
R += "''";
else
R += i;
return R;
}
return R;
}
enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE };
@@ -157,7 +158,9 @@ namespace ORM {
template <typename RecordType> class DBCache {
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 Delete(const std::string &FieldName, const std::string &Value)=0;
private:
size_t Size_=0;
uint64_t Timeout_=0;
};
template <typename RecordTuple, typename RecordType> class DB {
@@ -182,8 +186,8 @@ namespace ORM {
Poco::Logger &L,
const char *Prefix,
DBCache<RecordType> * Cache=nullptr):
Type_(dbtype),
TableName_(TableName),
Type_(dbtype),
Pool_(Pool),
Logger_(L),
Prefix_(Prefix),
@@ -290,7 +294,7 @@ namespace ORM {
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 +")";
}
@@ -865,19 +869,19 @@ namespace ORM {
}
protected:
std::string TableName_;
OpenWifi::DBType Type_;
Poco::Data::SessionPool &Pool_;
Poco::Logger &Logger_;
std::string TableName_;
std::string Prefix_;
DBCache<RecordType> *Cache_= nullptr;
private:
OpenWifi::DBType Type_;
std::string CreateFields_;
std::string SelectFields_;
std::string SelectList_;
std::string UpdateFields_;
std::vector<std::string> IndexCreation_;
std::map<std::string,int> FieldNames_;
std::string Prefix_;
};
}

View File

@@ -7,6 +7,16 @@
#include <string>
#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 {
static const std::string MissingUUID{"Missing UUID."};
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

View File

@@ -8,7 +8,7 @@
namespace OpenWifi::SDK::GW {
namespace Device {
void Reboot(RESTAPIHandler *client, const std::string & Mac, uint64_t When) {
void Reboot(RESTAPIHandler *client, const std::string & Mac, [[maybe_unused]] uint64_t When) {
std::string EndPoint = "/api/v1/device/" + Mac + "/reboot";
Poco::JSON::Object ObjRequest;
@@ -40,7 +40,7 @@ namespace OpenWifi::SDK::GW {
PerformCommand(client,"factory",EndPoint, ObjRequest);
}
void Upgrade(RESTAPIHandler *client, const std::string & Mac, uint64_t When, const std::string & ImageName, bool KeepRedirector) {
void Upgrade(RESTAPIHandler *client, const std::string & Mac, uint64_t When, const std::string & ImageName, [[maybe_unused]] bool KeepRedirector) {
std::string EndPoint = "/api/v1/device/" + Mac + "/upgrade";
Poco::JSON::Object ObjRequest;

View File

@@ -82,7 +82,7 @@ namespace OpenWifi::SDK::Prov {
return true;
}
bool Update( RESTAPIHandler *client, const std::string &ConfigUUID, ProvObjects::DeviceConfiguration & Config) {
bool Update( [[maybe_unused]] RESTAPIHandler *client, [[maybe_unused]] const std::string &ConfigUUID, [[maybe_unused]] ProvObjects::DeviceConfiguration & Config) {
return false;
}

View File

@@ -7,7 +7,7 @@
namespace OpenWifi::SDK::Sec {
namespace User {
bool Exists(RESTAPIHandler *client, const Types::UUID_t & Id) {
bool Exists([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) {
OpenAPIRequestGet Req( uSERVICE_SECURITY,
"/api/v1/user/" + Id,
{},
@@ -21,7 +21,7 @@ namespace OpenWifi::SDK::Sec {
return false;
}
bool Get(RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) {
bool Get([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) {
OpenAPIRequestGet Req( uSERVICE_SECURITY,
"/api/v1/user/" + Id,
{},
@@ -37,7 +37,7 @@ namespace OpenWifi::SDK::Sec {
}
namespace Subscriber {
bool Exists(RESTAPIHandler *client, const Types::UUID_t & Id) {
bool Exists([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) {
OpenAPIRequestGet Req( uSERVICE_SECURITY,
"/api/v1/subuser/" + Id,
{},
@@ -51,7 +51,7 @@ namespace OpenWifi::SDK::Sec {
return false;
}
bool Get(RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) {
bool Get([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id, SecurityObjects::UserInfo & UserInfo) {
OpenAPIRequestGet Req( uSERVICE_SECURITY,
"/api/v1/subuser/" + Id,
{},
@@ -65,7 +65,7 @@ namespace OpenWifi::SDK::Sec {
return false;
}
bool Delete(RESTAPIHandler *client, const Types::UUID_t & Id) {
bool Delete([[maybe_unused]] RESTAPIHandler *client, const Types::UUID_t & Id) {
OpenAPIRequestDelete Req( uSERVICE_SECURITY,
"/api/v1/subuser/" + Id,
{},

View File

@@ -45,7 +45,7 @@ namespace OpenWifi {
ORM::Indextype::ASC} } }
};
bool ConfigurationDB::Upgrade(uint32_t from, uint32_t &to) {
bool ConfigurationDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{
"alter table " + TableName_ + " add column subscriberOnly BOOLEAN;",
"alter table " + TableName_ + " add column entity TEXT;",

View File

@@ -39,6 +39,7 @@ namespace OpenWifi {
ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
bool GetListOfAffectedDevices(const Types::UUID_t & ConfigUUID, Types::UUIDvec_t & DeviceSerialNumbers );
bool Upgrade(uint32_t from, uint32_t &to) override;
virtual ~ConfigurationDB() {};
private:
};
}

View File

@@ -40,6 +40,7 @@ namespace OpenWifi {
class ContactDB : public ORM::DB<ContactDBRecordType, ProvObjects::Contact> {
public:
ContactDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~ContactDB() {};
private:
};
}

View File

@@ -55,7 +55,7 @@ namespace OpenWifi {
CheckForRoot();
}
bool EntityDB::Upgrade(uint32_t from, uint32_t &to) {
bool EntityDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
to = Version();
std::vector<std::string> Script{
"alter table " + TableName_ + " add column variables text",

View File

@@ -42,6 +42,7 @@ namespace OpenWifi {
public:
static const std::string RootUUID_;
EntityDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~EntityDB() {};
inline bool RootExists() const { return RootExists_; };
static inline bool IsRoot(const std::string &UUID) { return (UUID == RootUUID_); }
static inline const std::string RootUUID() { return RootUUID_; }

View File

@@ -57,7 +57,7 @@ namespace OpenWifi {
ORM::Indextype::ASC} } }
};
bool InventoryDB::Upgrade(uint32_t from, uint32_t &to) {
bool InventoryDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
to = Version();
std::vector<std::string> Script{
"alter table " + TableName_ + " add column state text" ,

View File

@@ -41,6 +41,7 @@ namespace OpenWifi {
class InventoryDB : public ORM::DB<InventoryDBRecordType, ProvObjects::InventoryTag> {
public:
InventoryDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~InventoryDB() {};
bool CreateFromConnection(const std::string & SerialNumber, const std::string & ConnectionInfo,
const std::string & DeviceType, const std::string &Locale );
bool FindFirmwareOptions(std::string & SerialNumber, ProvObjects::FIRMWARE_UPGRADE_RULES & Rules);

View File

@@ -34,6 +34,7 @@ namespace OpenWifi {
class JobDB : public ORM::DB<JobDBRecordType, JobRecord> {
public:
JobDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~JobDB() {};
private:
};
}

View File

@@ -38,6 +38,7 @@ namespace OpenWifi {
class LocationDB : public ORM::DB<LocationDBRecordType, ProvObjects::Location> {
public:
LocationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~LocationDB() {};
private:
};
}

View File

@@ -40,7 +40,7 @@ namespace OpenWifi {
ManagementRoleDB::ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "roles", RolesDB_Fields, RolesDB_Indexes, P, L, "rol") {}
bool ManagementRoleDB::Upgrade(uint32_t from, uint32_t &to) {
bool ManagementRoleDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{
"alter table " + TableName_ + " add column entity text;",
"alter table " + TableName_ + " add column venue text;"

View File

@@ -30,6 +30,7 @@ namespace OpenWifi {
class ManagementRoleDB : public ORM::DB<ManagementRoleDBRecordType, ProvObjects::ManagementRole> {
public:
ManagementRoleDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~ManagementRoleDB() {};
private:
bool Upgrade(uint32_t from, uint32_t &to) override;
};

View File

@@ -34,7 +34,7 @@ namespace OpenWifi {
MapDB::MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "maps", MapsDB_Fields, MapsDB_Indexes, P, L, "map") {}
bool MapDB::Upgrade(uint32_t from, uint32_t &to) {
bool MapDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{
"alter table " + TableName_ + " add column managementPolicy text;",
"alter table " + TableName_ + " add column entity text;",
@@ -57,7 +57,7 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma
Out.info.tags = OpenWifi::RESTAPI_utils::to_taglist(In.get<6>());
Out.data = In.get<7>();
Out.creator = In.get<8>();
Out.visibility = OpenWifi::ProvObjects::visibility_from_string(In.get<9>());
Out.visibility = In.get<9>();
Out.access = OpenWifi::RESTAPI_utils::to_object<OpenWifi::ProvObjects::ObjectACLList>(In.get<10>());
Out.entity = In.get<11>();
Out.managementPolicy = In.get<12>();
@@ -74,7 +74,7 @@ template<> void ORM::DB< OpenWifi::MapDBRecordType, OpenWifi::ProvObjects::Ma
Out.set<6>(OpenWifi::RESTAPI_utils::to_string(In.info.tags));
Out.set<7>(In.data);
Out.set<8>(In.creator);
Out.set<9>(OpenWifi::ProvObjects::to_string(In.visibility));
Out.set<9>(In.visibility);
Out.set<10>(OpenWifi::RESTAPI_utils::to_string(In.access));
Out.set<11>(In.entity);
Out.set<12>(In.managementPolicy);

View File

@@ -28,6 +28,7 @@ namespace OpenWifi {
class MapDB : public ORM::DB<MapDBRecordType, ProvObjects::Map> {
public:
MapDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~MapDB() {};
private:
bool Upgrade(uint32_t from, uint32_t &to) override;
};

View File

@@ -38,7 +38,7 @@ namespace OpenWifi {
PolicyDB::PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "policies", PolicyDB_Fields, PolicyDB_Indexes, P, L, "pol") {}
bool PolicyDB::Upgrade(uint32_t from, uint32_t &to) {
bool PolicyDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{
"alter table " + TableName_ + " add column entity text;",
"alter table " + TableName_ + " add column venue text;"

View File

@@ -29,6 +29,7 @@ namespace OpenWifi {
class PolicyDB : public ORM::DB<PolicyDBRecordType, ProvObjects::ManagementPolicy> {
public:
PolicyDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~PolicyDB() {};
private:
bool Upgrade(uint32_t from, uint32_t &to) override;
};

View File

@@ -30,6 +30,7 @@ namespace OpenWifi {
class SignupDB : public ORM::DB<SignupDBRecordType, ProvObjects::SignupEntry> {
public:
explicit SignupDB(OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept;
virtual ~SignupDB() {};
bool GetIncompleteSignups( SignupDB::RecordVec & Signups );
void RemoveIncompleteSignups();
private:

View File

@@ -14,7 +14,7 @@ namespace OpenWifi {
// object info
ORM::Field{"entity",ORM::FieldType::FT_TEXT, 64},
ORM::Field{"id",ORM::FieldType::FT_INT, 0,true},
ORM::Field{"name",ORM::FieldType::FT_TEXT, 32, }
ORM::Field{"name",ORM::FieldType::FT_TEXT, 32}
};
static ORM::IndexVec TagsDictionaryDB_Indexes{

View File

@@ -35,12 +35,14 @@ namespace OpenWifi {
class TagsDictionaryDB : public ORM::DB<TagsDictionaryRecordType, TagsDictionary> {
public:
TagsDictionaryDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~TagsDictionaryDB() {};
private:
};
class TagsObjectDB : public ORM::DB<TagsObjectRecordType, TagsObject> {
public:
TagsObjectDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~TagsObjectDB() {};
private:
};
}

View File

@@ -42,7 +42,7 @@ namespace OpenWifi {
DB(T, "variables2", VariablesDB_Fields, VariablesDB_Indexes, P, L, "var") {
}
bool VariablesDB::Upgrade(uint32_t from, uint32_t &to) {
bool VariablesDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
std::vector<std::string> Statements{
// "alter table " + TableName_ + " add column configurations TEXT;" ,
// "alter table " + TableName_ + " add column managementPolicy TEXT;"

View File

@@ -27,6 +27,7 @@ namespace OpenWifi {
class VariablesDB : public ORM::DB<VariablesDBRecordType, ProvObjects::VariableBlock> {
public:
explicit VariablesDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) noexcept;
virtual ~VariablesDB() {};
private:
bool Upgrade(uint32_t from, uint32_t &to) override;
};

View File

@@ -55,7 +55,7 @@ namespace OpenWifi {
VenueDB::VenueDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
DB(T, "venues", VenueDB_Fields, VenueDB_Indexes, P, L, "ven") {}
bool VenueDB::Upgrade(uint32_t from, uint32_t &to) {
bool VenueDB::Upgrade([[maybe_unused]] uint32_t from, uint32_t &to) {
to = Version();
std::vector<std::string> Script{
"alter table " + TableName_ + " add column variables text",

View File

@@ -43,6 +43,7 @@ namespace OpenWifi {
class VenueDB : public ORM::DB<VenueDBRecordType, ProvObjects::Venue> {
public:
VenueDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
virtual ~VenueDB() {};
bool GetByIP(const std::string &IP, std::string & uuid);
bool Upgrade(uint32_t from, uint32_t &to) override;
private: