stephb9959
2022-10-27 23:25:53 -07:00
parent e8800782b4
commit 2c85a691bb
10 changed files with 24 additions and 18 deletions

View File

@@ -5,6 +5,7 @@
#pragma once
#include "RESTAPI_ProvObjects.h"
#include "framework/utils.h"
#include <vector>
namespace OpenWifi {
@@ -375,7 +376,7 @@ namespace OpenWifi {
};
struct WifiClientHistory {
uint64_t timestamp=OpenWifi::Now();
uint64_t timestamp=Utils::Now();
std::string station_id;
std::string bssid;
std::string ssid;

View File

@@ -4,6 +4,7 @@
#include "RESTAPI_FMSObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -233,7 +234,7 @@ namespace OpenWifi::FMSObjects {
UnknownFirmwares_.clear();
totalSecondsOld_.clear();
numberOfDevices = 0 ;
snapshot = OpenWifi::Now();
snapshot = Utils::Now();
}
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {

View File

@@ -17,6 +17,7 @@
#include "RESTAPI_GWobjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -206,7 +207,7 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"started", started);
field_to_json(Obj,"sessionId", sessionId);
field_to_json(Obj,"connectionCompletionTime", connectionCompletionTime);
field_to_json(Obj,"totalConnectionTime", OpenWifi::Now() - started);
field_to_json(Obj,"totalConnectionTime", Utils::Now() - started);
switch(VerifiedCertificate) {
case NO_CERTIFICATE:
@@ -285,7 +286,7 @@ namespace OpenWifi::GWObjects {
lastContact.clear();
associations.clear();
numberOfDevices = 0 ;
snapshot = OpenWifi::Now();
snapshot = Utils::Now();
}
void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{

View File

@@ -10,6 +10,7 @@
#include "RESTAPI_ProvObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -1092,7 +1093,7 @@ namespace OpenWifi::ProvObjects {
}
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = OpenWifi::Now();
uint64_t Now = Utils::Now();
if(O->has("name"))
I.name = O->get("name").toString();
@@ -1113,7 +1114,7 @@ namespace OpenWifi::ProvObjects {
}
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = OpenWifi::Now();
uint64_t Now = Utils::Now();
if(O->has("name"))
I.name = O->get("name").toString();
@@ -1137,7 +1138,7 @@ namespace OpenWifi::ProvObjects {
}
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
I.modified = I.created = OpenWifi::Now();
I.modified = I.created = Utils::Now();
I.id = MicroServiceCreateUUID();
return true;
}

View File

@@ -433,7 +433,7 @@ namespace OpenWifi::SecurityObjects {
SecurityObjects::NoteInfoVec NIV;
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
for(auto const &i:NIV) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
Notes.push_back(ii);
}
}
@@ -446,7 +446,7 @@ namespace OpenWifi::SecurityObjects {
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
for(auto const &i:NewNotes) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
ExistingNotes.push_back(ii);
}
return true;

View File

@@ -14,6 +14,7 @@
#include "Poco/JSON/Object.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/LOBStream.h"
#include "framework/utils.h"
namespace OpenWifi {
uint64_t Now();
@@ -62,7 +63,7 @@ namespace OpenWifi {
std::string UserTypeToString(USER_ROLE U);
struct NoteInfo {
uint64_t created=0; // = OpenWifi::Now();
uint64_t created=0; // = Utils::Now();
std::string createdBy;
std::string note;
@@ -101,7 +102,7 @@ namespace OpenWifi {
std::string uuid;
std::string question;
std::string method;
uint64_t created = OpenWifi::Now();
uint64_t created = Utils::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -264,7 +265,7 @@ namespace OpenWifi {
std::string locale;
std::string message;
uint64_t sent=0;
uint64_t created=OpenWifi::Now();
uint64_t created=Utils::Now();
uint64_t expires=0;
uint64_t completed=0;
uint64_t canceled=0;

View File

@@ -8,7 +8,6 @@
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
namespace OpenWifi::SubObjects {
void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const {

View File

@@ -23,7 +23,7 @@ namespace OpenWifi {
void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override;
private:
Poco::Logger & Logger_;
[[maybe_unused]] Poco::Logger & Logger_;
uint64_t id_;
};

View File

@@ -7,6 +7,7 @@
#include "framework/SubSystemServer.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "Poco/ExpireLRUCache.h"
#include "framework/utils.h"
namespace OpenWifi {
@@ -38,7 +39,7 @@ namespace OpenWifi {
}
inline static bool IsTokenExpired(const SecurityObjects::WebToken &T) {
return ((T.expires_in_+T.created_) < OpenWifi::Now());
return ((T.expires_in_+T.created_) < Utils::Now());
}
bool RetrieveTokenInformation(const std::string & SessionToken,

View File

@@ -25,6 +25,7 @@
#include "framework/RESTAPI_GenericServerAccounting.h"
#include "framework/RESTAPI_ExtServer.h"
#include "framework/RESTAPI_IntServer.h"
#include "framework/utils.h"
namespace OpenWifi {
@@ -54,7 +55,7 @@ namespace OpenWifi {
Object->has(KafkaTopics::ServiceEvents::Fields::KEY)) {
auto PrivateEndPoint = Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString();
if (Event == KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE && Services_.find(PrivateEndPoint) != Services_.end()) {
Services_[PrivateEndPoint].LastUpdate = OpenWifi::Now();
Services_[PrivateEndPoint].LastUpdate = Utils::Now();
} else if (Event == KafkaTopics::ServiceEvents::EVENT_LEAVE) {
Services_.erase(PrivateEndPoint);
poco_debug(logger(),fmt::format("Service {} ID={} leaving system.",Object->get(KafkaTopics::ServiceEvents::Fields::PRIVATE).toString(),ID));
@@ -67,7 +68,7 @@ namespace OpenWifi {
.PublicEndPoint = Object->get(KafkaTopics::ServiceEvents::Fields::PUBLIC).toString(),
.AccessKey = Object->get(KafkaTopics::ServiceEvents::Fields::KEY).toString(),
.Version = Object->get(KafkaTopics::ServiceEvents::Fields::VRSN).toString(),
.LastUpdate = OpenWifi::Now() };
.LastUpdate = Utils::Now() };
std::string SvcList;
for (const auto &Svc: Services_) {
@@ -98,7 +99,7 @@ namespace OpenWifi {
}
auto i=Services_.begin();
auto now = OpenWifi::Now();
auto now = Utils::Now();
for(;i!=Services_.end();) {
if((now - i->second.LastUpdate)>60) {
i = Services_.erase(i);