mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Compare commits
1 Commits
v2.11.0-RC
...
v2.10.0-RC
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f925ce12be |
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(owprov VERSION 2.11.0)
|
||||
project(owprov VERSION 2.10.0)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
||||
images:
|
||||
owprov:
|
||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
||||
tag: v2.11.0-RC1
|
||||
tag: v2.10.0-RC1
|
||||
pullPolicy: Always
|
||||
# regcred:
|
||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||
|
||||
@@ -1331,6 +1331,12 @@ components:
|
||||
- $ref: '#/components/schemas/StringList'
|
||||
- $ref: '#/components/schemas/TagValuePairList'
|
||||
|
||||
SystemCommandResults:
|
||||
type: object
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/StringList'
|
||||
- $ref: '#/components/schemas/TagValuePairList'
|
||||
|
||||
NoteInfo:
|
||||
type: object
|
||||
properties:
|
||||
@@ -1370,33 +1376,6 @@ components:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
SystemResources:
|
||||
type: object
|
||||
properties:
|
||||
numberOfFileDescriptors:
|
||||
type: integer
|
||||
format: int64
|
||||
currRealMem:
|
||||
type: integer
|
||||
format: int64
|
||||
peakRealMem:
|
||||
type: integer
|
||||
format: int64
|
||||
currVirtMem:
|
||||
type: integer
|
||||
format: int64
|
||||
peakVirtMem:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
SystemCommandResults:
|
||||
type: object
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/SystemResources'
|
||||
- $ref: '#/components/schemas/SystemInfoResults'
|
||||
- $ref: '#/components/schemas/StringList'
|
||||
- $ref: '#/components/schemas/TagValuePairList'
|
||||
|
||||
Dashboard:
|
||||
type: object
|
||||
properties:
|
||||
@@ -2279,7 +2258,7 @@ paths:
|
||||
get:
|
||||
tags:
|
||||
- Configuration Overrides
|
||||
operationId: getConfigurationOverrides
|
||||
operationId: getCponfigurationOverrides
|
||||
summary: retrieve a list of configuration overrides for a given device
|
||||
parameters:
|
||||
- in: path
|
||||
@@ -2303,7 +2282,7 @@ paths:
|
||||
delete:
|
||||
tags:
|
||||
- Configuration Overrides
|
||||
operationId: deleteConfigurationOverrides
|
||||
operationId: deleteCponfigurationOverrides
|
||||
summary: delete all configuration overrides for a given device from a given source
|
||||
parameters:
|
||||
- in: path
|
||||
@@ -4444,12 +4423,15 @@ paths:
|
||||
type: string
|
||||
enum:
|
||||
- info
|
||||
- extraConfiguration
|
||||
- resources
|
||||
required: true
|
||||
responses:
|
||||
200:
|
||||
$ref: '#/components/schemas/SystemCommandResults'
|
||||
description: Successful command execution
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
oneOf:
|
||||
- $ref: '#/components/schemas/SystemInfoResults'
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
404:
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if (!Existing.contacts.empty()) {
|
||||
for (const auto &contact_uuid : Existing.contacts)
|
||||
for (const auto &i : Existing.contacts)
|
||||
StorageService()->ContactDB().DeleteInUse(
|
||||
"id", contact_uuid, StorageService()->VenueDB().Prefix(), UUID);
|
||||
"id", i, StorageService()->VenueDB().Prefix(), UUID);
|
||||
}
|
||||
if (!Existing.location.empty())
|
||||
StorageService()->LocationDB().DeleteInUse("id", Existing.location,
|
||||
@@ -101,9 +101,9 @@ namespace OpenWifi {
|
||||
StorageService()->PolicyDB().DeleteInUse("id", Existing.managementPolicy,
|
||||
StorageService()->VenueDB().Prefix(), UUID);
|
||||
if (!Existing.deviceConfiguration.empty()) {
|
||||
for (auto &configuration_uuid : Existing.deviceConfiguration)
|
||||
for (auto &i : Existing.deviceConfiguration)
|
||||
StorageService()->ConfigurationDB().DeleteInUse(
|
||||
"id", configuration_uuid, StorageService()->VenueDB().Prefix(), UUID);
|
||||
"id", i, StorageService()->VenueDB().Prefix(), UUID);
|
||||
}
|
||||
if (!Existing.parent.empty())
|
||||
StorageService()->VenueDB().DeleteChild("id", Existing.parent, UUID);
|
||||
@@ -157,10 +157,6 @@ namespace OpenWifi {
|
||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||
}
|
||||
|
||||
if(StorageService()->VenueDB().DoesVenueNameAlreadyExist(NewObject.info.name,NewObject.entity, NewObject.parent)) {
|
||||
return BadRequest(RESTAPI::Errors::VenuesNameAlreadyExists);
|
||||
}
|
||||
|
||||
if (!NewObject.contacts.empty()) {
|
||||
for (const auto &i : NewObject.contacts) {
|
||||
if (!StorageService()->ContactDB().Exists("id", i)) {
|
||||
@@ -436,7 +432,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string MoveFromEntity, MoveToEntity;
|
||||
if (AssignIfPresent(RawObject, "entity", MoveToEntity)) {
|
||||
if (MoveToEntity.empty() || !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
|
||||
if (!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
|
||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||
}
|
||||
MoveFromEntity = Existing.entity;
|
||||
@@ -445,7 +441,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string MoveToVenue, MoveFromVenue;
|
||||
if (AssignIfPresent(RawObject, "venue", MoveToVenue)) {
|
||||
if (MoveToVenue.empty() || !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
|
||||
if (!MoveToVenue.empty() && !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
|
||||
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||
}
|
||||
MoveFromVenue = Existing.parent;
|
||||
@@ -454,7 +450,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string MoveFromLocation, MoveToLocation;
|
||||
if (AssignIfPresent(RawObject, "location", MoveToLocation)) {
|
||||
if (MoveToLocation.empty() ||
|
||||
if (!MoveToLocation.empty() &&
|
||||
!StorageService()->LocationDB().Exists("id", MoveToLocation)) {
|
||||
return BadRequest(RESTAPI::Errors::LocationMustExist);
|
||||
}
|
||||
@@ -464,8 +460,8 @@ namespace OpenWifi {
|
||||
|
||||
Types::UUIDvec_t MoveFromContacts, MoveToContacts;
|
||||
if (AssignIfPresent(RawObject, "contacts", MoveToContacts)) {
|
||||
for (const auto &contact : NewObject.contacts) {
|
||||
if (!StorageService()->ContactDB().Exists("id", contact)) {
|
||||
for (const auto &i : NewObject.contacts) {
|
||||
if (!StorageService()->ContactDB().Exists("id", i)) {
|
||||
return BadRequest(RESTAPI::Errors::ContactMustExist);
|
||||
}
|
||||
}
|
||||
@@ -475,7 +471,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string MoveFromPolicy, MoveToPolicy;
|
||||
if (AssignIfPresent(RawObject, "managementPolicy", MoveToPolicy)) {
|
||||
if (MoveToPolicy.empty() || !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
|
||||
if (!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
|
||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||
}
|
||||
MoveFromPolicy = Existing.managementPolicy;
|
||||
@@ -485,8 +481,8 @@ namespace OpenWifi {
|
||||
Types::UUIDvec_t MoveToConfigurations, MoveFromConfigurations;
|
||||
if (RawObject->has("deviceConfiguration")) {
|
||||
MoveToConfigurations = NewObject.deviceConfiguration;
|
||||
for (auto &configuration : MoveToConfigurations) {
|
||||
if (!StorageService()->ConfigurationDB().Exists("id", configuration)) {
|
||||
for (auto &i : MoveToConfigurations) {
|
||||
if (!StorageService()->ConfigurationDB().Exists("id", i)) {
|
||||
return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace OpenWifi {
|
||||
Response.set("Connection", "keep-alive");
|
||||
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
|
||||
std::ostream &Answer = Response.send();
|
||||
Answer << ALBHealthCheckServer()->CallbackText();
|
||||
Answer << "process Alive and kicking!";
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,8 +37,6 @@ namespace OpenWifi {
|
||||
inline static std::atomic_uint64_t req_id_ = 1;
|
||||
};
|
||||
|
||||
typedef std::string ALBHealthMessageCallback();
|
||||
|
||||
class ALBHealthCheckServer : public SubSystemServer {
|
||||
public:
|
||||
ALBHealthCheckServer();
|
||||
@@ -50,22 +48,10 @@ namespace OpenWifi {
|
||||
|
||||
int Start() override;
|
||||
void Stop() override;
|
||||
inline void RegisterExtendedHealthMessage(ALBHealthMessageCallback *F) {
|
||||
Callback_=F;
|
||||
};
|
||||
|
||||
inline std::string CallbackText() {
|
||||
if(Callback_== nullptr) {
|
||||
return "process Alive and kicking!";
|
||||
} else {
|
||||
return Callback_();
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::unique_ptr<Poco::Net::HTTPServer> Server_;
|
||||
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
|
||||
ALBHealthMessageCallback *Callback_= nullptr;
|
||||
int Port_ = 0;
|
||||
mutable std::atomic_bool Running_ = false;
|
||||
};
|
||||
|
||||
@@ -37,10 +37,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"uuid": {
|
||||
"type": "integer"
|
||||
},
|
||||
"public_ip_lookup": {
|
||||
"type": "string",
|
||||
"format": "uc-fqdn"
|
||||
},
|
||||
"unit": {
|
||||
"$ref": "#/$defs/unit"
|
||||
},
|
||||
@@ -638,6 +634,26 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"type": "string",
|
||||
"format": "uc-timeout",
|
||||
"default": "6h"
|
||||
},
|
||||
"relay-server": {
|
||||
"type": "string",
|
||||
"format": "ipv4",
|
||||
"example": "192.168.2.1"
|
||||
},
|
||||
"circuit-id-format": {
|
||||
"type": "string",
|
||||
"example": [
|
||||
"\\{Interface\\}:\\{VLAN-Id\\}:\\{SSID\\}:\\{Model\\}:\\{Name\\}:\\{AP-MAC\\}:\\{Location\\}",
|
||||
"\\{AP-MAC\\};\\{SSID\\};\\{Crypto\\}",
|
||||
"\\{Name\\} \\{ESSID\\}"
|
||||
]
|
||||
},
|
||||
"remote-id-format": {
|
||||
"type": "string",
|
||||
"example": [
|
||||
"\\{Client-MAC-hex\\} \\{SSID\\}",
|
||||
"\\{AP-MAC-hex\\} \\{SSID\\}"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1216,32 +1232,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"secondary": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"host": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"examples": [
|
||||
1812
|
||||
]
|
||||
},
|
||||
"secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"request-attribute": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -1319,25 +1309,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"value": "Example Operator"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "integer",
|
||||
"maximum": 255,
|
||||
"minimum": 1
|
||||
},
|
||||
"hex-value": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"examples": [
|
||||
{
|
||||
"id": 32,
|
||||
"value": "0a0b0c0d"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1687,236 +1658,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.click": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "click-to-continue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.radius": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "radius"
|
||||
},
|
||||
"auth-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"auth-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"auth-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"acct-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"acct-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-interval": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.credentials": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "credentials"
|
||||
},
|
||||
"credentials": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.uam": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "uam"
|
||||
},
|
||||
"uam-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 3990
|
||||
},
|
||||
"uam-secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"uam-server": {
|
||||
"type": "string"
|
||||
},
|
||||
"nasid": {
|
||||
"type": "string"
|
||||
},
|
||||
"nasmac": {
|
||||
"type": "string"
|
||||
},
|
||||
"auth-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"auth-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"auth-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"acct-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"acct-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-interval": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
},
|
||||
"ssid": {
|
||||
"type": "string"
|
||||
},
|
||||
"mac-format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"aabbccddeeff",
|
||||
"aa-bb-cc-dd-ee-ff",
|
||||
"aa:bb:cc:dd:ee:ff",
|
||||
"AABBCCDDEEFF",
|
||||
"AA:BB:CC:DD:EE:FF",
|
||||
"AA-BB-CC-DD-EE-FF"
|
||||
]
|
||||
},
|
||||
"final-redirect-url": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default",
|
||||
"uam"
|
||||
]
|
||||
},
|
||||
"mac-auth": {
|
||||
"type": "boolean",
|
||||
"default": "default"
|
||||
},
|
||||
"radius-gw-proxy": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive": {
|
||||
"allOf": [
|
||||
{
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.click"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.radius"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.credentials"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.uam"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"walled-garden-fqdn": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"walled-garden-ipaddr": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uc-ip"
|
||||
}
|
||||
},
|
||||
"web-root": {
|
||||
"type": "string",
|
||||
"format": "uc-base64"
|
||||
},
|
||||
"idle-timeout": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
},
|
||||
"session-timeout": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"interface.ssid": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -1969,10 +1710,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"isolate-clients": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"strict-forwarding": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
},
|
||||
"power-save": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -2041,14 +1778,7 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"$ref": "#/$defs/interface.ssid.rate-limit"
|
||||
},
|
||||
"roaming": {
|
||||
"anyOf": [
|
||||
{
|
||||
"$ref": "#/$defs/interface.ssid.roaming"
|
||||
},
|
||||
{
|
||||
"type": "boolean"
|
||||
}
|
||||
]
|
||||
"$ref": "#/$defs/interface.ssid.roaming"
|
||||
},
|
||||
"radius": {
|
||||
"$ref": "#/$defs/interface.ssid.radius"
|
||||
@@ -2065,9 +1795,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"access-control-list": {
|
||||
"$ref": "#/$defs/interface.ssid.acl"
|
||||
},
|
||||
"captive": {
|
||||
"$ref": "#/$defs/service.captive"
|
||||
},
|
||||
"hostapd-bss-raw": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -2235,17 +1962,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
]
|
||||
}
|
||||
},
|
||||
"vlan-awareness": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"first": {
|
||||
"type": "integer"
|
||||
},
|
||||
"last": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
},
|
||||
"vlan": {
|
||||
"$ref": "#/$defs/interface.vlan"
|
||||
},
|
||||
@@ -2368,10 +2084,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
"examples": [
|
||||
"01234567890123456789012345678901"
|
||||
]
|
||||
},
|
||||
"mutual-tls": {
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -2981,6 +2693,236 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.click": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "click-to-continue"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.radius": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "radius"
|
||||
},
|
||||
"auth-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"auth-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"auth-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"acct-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"acct-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-interval": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.credentials": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "credentials"
|
||||
},
|
||||
"credentials": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"username": {
|
||||
"type": "string"
|
||||
},
|
||||
"password": {
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive.uam": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"auth-mode": {
|
||||
"type": "string",
|
||||
"const": "uam"
|
||||
},
|
||||
"uam-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 3990
|
||||
},
|
||||
"uam-secret": {
|
||||
"type": "string"
|
||||
},
|
||||
"uam-server": {
|
||||
"type": "string"
|
||||
},
|
||||
"nasid": {
|
||||
"type": "string"
|
||||
},
|
||||
"nasmac": {
|
||||
"type": "string"
|
||||
},
|
||||
"auth-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"auth-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"auth-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-server": {
|
||||
"type": "string",
|
||||
"format": "uc-host",
|
||||
"examples": [
|
||||
"192.168.1.10"
|
||||
]
|
||||
},
|
||||
"acct-port": {
|
||||
"type": "integer",
|
||||
"maximum": 65535,
|
||||
"minimum": 1024,
|
||||
"default": 1812
|
||||
},
|
||||
"acct-secret": {
|
||||
"type": "string",
|
||||
"examples": [
|
||||
"secret"
|
||||
]
|
||||
},
|
||||
"acct-interval": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
},
|
||||
"ssid": {
|
||||
"type": "string"
|
||||
},
|
||||
"mac-format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"aabbccddeeff",
|
||||
"aa-bb-cc-dd-ee-ff",
|
||||
"aa:bb:cc:dd:ee:ff",
|
||||
"AABBCCDDEEFF",
|
||||
"AA:BB:CC:DD:EE:FF",
|
||||
"AA-BB-CC-DD-EE-FF"
|
||||
]
|
||||
},
|
||||
"final-redirect-url": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"default",
|
||||
"uam"
|
||||
]
|
||||
},
|
||||
"mac-auth": {
|
||||
"type": "boolean",
|
||||
"default": "default"
|
||||
},
|
||||
"radius-gw-proxy": {
|
||||
"type": "boolean",
|
||||
"default": false
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.captive": {
|
||||
"allOf": [
|
||||
{
|
||||
"oneOf": [
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.click"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.radius"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.credentials"
|
||||
},
|
||||
{
|
||||
"$ref": "#/$defs/service.captive.uam"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"walled-garden-fqdn": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"walled-garden-ipaddr": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string",
|
||||
"format": "uc-ip"
|
||||
}
|
||||
},
|
||||
"web-root": {
|
||||
"type": "string",
|
||||
"format": "uc-base64"
|
||||
},
|
||||
"idle-timeout": {
|
||||
"type": "integer",
|
||||
"default": 600
|
||||
},
|
||||
"session-timeout": {
|
||||
"type": "integer"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"service.gps": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -2999,32 +2941,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.dhcp-relay": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"select-ports": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"vlans": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"vlan": {
|
||||
"type": "number"
|
||||
},
|
||||
"relay-server": {
|
||||
"type": "string",
|
||||
"format": "uc-ip"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"service": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3084,9 +3000,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
||||
},
|
||||
"gps": {
|
||||
"$ref": "#/$defs/service.gps"
|
||||
},
|
||||
"dhcp-relay": {
|
||||
"$ref": "#/$defs/service.dhcp-relay"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -213,7 +213,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void KafkaProducer::Produce(const char *Topic, const std::string &Key,
|
||||
std::shared_ptr<std::string> Payload) {
|
||||
const std::shared_ptr<std::string> Payload) {
|
||||
std::lock_guard G(Mutex_);
|
||||
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
||||
}
|
||||
|
||||
@@ -18,8 +18,8 @@ namespace OpenWifi {
|
||||
|
||||
class KafkaMessage : public Poco::Notification {
|
||||
public:
|
||||
KafkaMessage(const char * Topic, const std::string &Key, std::shared_ptr<std::string> Payload)
|
||||
: Topic_(Topic), Key_(Key), Payload_(Payload) {}
|
||||
KafkaMessage(const char * Topic, const std::string &Key, const std::shared_ptr<std::string> Payload)
|
||||
: Topic_(Topic), Key_(Key), Payload_(std::move(Payload)) {}
|
||||
|
||||
inline const char * Topic() { return Topic_; }
|
||||
inline const std::string &Key() { return Key_; }
|
||||
@@ -36,7 +36,7 @@ namespace OpenWifi {
|
||||
void run() override;
|
||||
void Start();
|
||||
void Stop();
|
||||
void Produce(const char *Topic, const std::string &Key, std::shared_ptr<std::string> Payload);
|
||||
void Produce(const char *Topic, const std::string &Key, const std::shared_ptr<std::string> Payload);
|
||||
|
||||
private:
|
||||
std::recursive_mutex Mutex_;
|
||||
@@ -92,9 +92,9 @@ namespace OpenWifi {
|
||||
void Stop() override;
|
||||
|
||||
void PostMessage(const char *topic, const std::string &key,
|
||||
std::shared_ptr<std::string> PayLoad, bool WrapMessage = true);
|
||||
void Dispatch(const char *Topic, const std::string &Key, std::shared_ptr<std::string> Payload);
|
||||
[[nodiscard]] const std::shared_ptr<std::string> WrapSystemId(std::shared_ptr<std::string> PayLoad);
|
||||
const std::shared_ptr<std::string> PayLoad, bool WrapMessage = true);
|
||||
void Dispatch(const char *Topic, const std::string &Key, const std::shared_ptr<std::string> Payload);
|
||||
[[nodiscard]] const std::shared_ptr<std::string> WrapSystemId(const std::shared_ptr<std::string> PayLoad);
|
||||
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
||||
uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
||||
void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id);
|
||||
|
||||
@@ -129,8 +129,6 @@ namespace OpenWifi {
|
||||
}
|
||||
} else {
|
||||
poco_error(logger(), "Bad bus message.");
|
||||
std::ostringstream os;
|
||||
Object->stringify(std::cout);
|
||||
}
|
||||
|
||||
auto i = Services_.begin();
|
||||
|
||||
@@ -5,8 +5,6 @@
|
||||
#include "framework/MicroServiceFuncs.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
#include "framework/ALBserver.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
|
||||
|
||||
@@ -125,8 +123,4 @@ namespace OpenWifi {
|
||||
return MicroService::instance().AllowExternalMicroServices();
|
||||
}
|
||||
|
||||
void MicroServiceALBCallback( std::string Callback()) {
|
||||
return ALBHealthCheckServer()->RegisterExtendedHealthMessage(Callback);
|
||||
}
|
||||
|
||||
} // namespace OpenWifi
|
||||
|
||||
@@ -53,5 +53,4 @@ namespace OpenWifi {
|
||||
std::string MicroServiceGetPublicAPIEndPoint();
|
||||
void MicroServiceDeleteOverrideConfiguration();
|
||||
bool AllowExternalMicroServices();
|
||||
void MicroServiceALBCallback( std::string Callback());
|
||||
} // namespace OpenWifi
|
||||
|
||||
@@ -28,9 +28,6 @@ namespace OpenWifi::Types {
|
||||
typedef std::string UUID_t;
|
||||
typedef std::vector<UUID_t> UUIDvec_t;
|
||||
typedef std::map<std::string, std::map<uint32_t, uint64_t>> Counted3DMapSII;
|
||||
typedef std::vector<int64_t> IntList;
|
||||
typedef std::vector<uint64_t> UIntList;
|
||||
typedef std::vector<double> DoubleList;
|
||||
|
||||
struct MicroServiceMeta {
|
||||
uint64_t Id = 0;
|
||||
|
||||
@@ -24,63 +24,50 @@ namespace OpenWifi {
|
||||
Server, TransactionId, Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/system"}; }
|
||||
|
||||
inline void DoGet() final {
|
||||
inline void DoGet() {
|
||||
std::string Arg;
|
||||
if (HasParameter("command", Arg)) {
|
||||
if (Arg == "info") {
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
||||
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
||||
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
||||
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
||||
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
||||
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
||||
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
||||
if (HasParameter("command", Arg) && Arg == "info") {
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
||||
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
||||
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
||||
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
||||
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
||||
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
||||
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
||||
|
||||
Poco::JSON::Array Certificates;
|
||||
auto SubSystems = MicroServiceGetFullSubSystems();
|
||||
std::set<std::string> CertNames;
|
||||
Poco::JSON::Array Certificates;
|
||||
auto SubSystems = MicroServiceGetFullSubSystems();
|
||||
std::set<std::string> CertNames;
|
||||
|
||||
for (const auto &i : SubSystems) {
|
||||
auto Hosts = i->HostSize();
|
||||
for (uint64_t j = 0; j < Hosts; ++j) {
|
||||
auto CertFileName = i->Host(j).CertFile();
|
||||
if (!CertFileName.empty()) {
|
||||
Poco::File F1(CertFileName);
|
||||
if (F1.exists()) {
|
||||
auto InsertResult = CertNames.insert(CertFileName);
|
||||
if (InsertResult.second) {
|
||||
Poco::JSON::Object Inner;
|
||||
Poco::Path F(CertFileName);
|
||||
Inner.set("filename", F.getFileName());
|
||||
Poco::Crypto::X509Certificate C(CertFileName);
|
||||
auto ExpiresOn = C.expiresOn();
|
||||
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
||||
Certificates.add(Inner);
|
||||
}
|
||||
for (const auto &i : SubSystems) {
|
||||
auto Hosts = i->HostSize();
|
||||
for (uint64_t j = 0; j < Hosts; ++j) {
|
||||
auto CertFileName = i->Host(j).CertFile();
|
||||
if (!CertFileName.empty()) {
|
||||
Poco::File F1(CertFileName);
|
||||
if (F1.exists()) {
|
||||
auto InsertResult = CertNames.insert(CertFileName);
|
||||
if (InsertResult.second) {
|
||||
Poco::JSON::Object Inner;
|
||||
Poco::Path F(CertFileName);
|
||||
Inner.set("filename", F.getFileName());
|
||||
Poco::Crypto::X509Certificate C(CertFileName);
|
||||
auto ExpiresOn = C.expiresOn();
|
||||
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
||||
Certificates.add(Inner);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Answer.set("certificates", Certificates);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
if (Arg == "extraConfiguration") {
|
||||
Poco::JSON::Object Answer;
|
||||
MicroServiceGetExtraConfiguration(Answer);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
if (Arg == "resources") {
|
||||
Poco::JSON::Object Answer;
|
||||
Answer.set("numberOfFileDescriptors", Utils::get_open_fds());
|
||||
std::uint64_t currRealMem, peakRealMem, currVirtMem, peakVirtMem;
|
||||
Utils::getMemory(currRealMem, peakRealMem, currVirtMem, peakVirtMem);
|
||||
Answer.set("currRealMem", currRealMem);
|
||||
Answer.set("peakRealMem", peakRealMem);
|
||||
Answer.set("currVirtMem", currVirtMem);
|
||||
Answer.set("peakVirtMem", peakVirtMem);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
Answer.set("certificates", Certificates);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
if (GetBoolParameter("extraConfiguration")) {
|
||||
Poco::JSON::Object Answer;
|
||||
MicroServiceGetExtraConfiguration(Answer);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
BadRequest(RESTAPI::Errors::InvalidCommand);
|
||||
}
|
||||
|
||||
@@ -14,15 +14,8 @@
|
||||
#include "framework/OpenWifiTypes.h"
|
||||
#include "framework/utils.h"
|
||||
|
||||
#include <RESTObjects/RESTAPI_SecurityObjects.h>
|
||||
|
||||
namespace OpenWifi::RESTAPI_utils {
|
||||
|
||||
inline bool IsRootOrAdmin(const SecurityObjects::UserInfo &UI) {
|
||||
return UI.userRole==SecurityObjects::ROOT ||
|
||||
UI.userRole==SecurityObjects::ADMIN;
|
||||
}
|
||||
|
||||
inline void EmbedDocument(const std::string &ObjName, Poco::JSON::Object &Obj,
|
||||
const std::string &ObjStr) {
|
||||
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
||||
@@ -102,20 +95,6 @@ namespace OpenWifi::RESTAPI_utils {
|
||||
Obj.set(Field, A);
|
||||
}
|
||||
|
||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::DoubleList &V) {
|
||||
Poco::JSON::Array A;
|
||||
for (const auto &i : V)
|
||||
A.add(i);
|
||||
Obj.set(Field, A);
|
||||
}
|
||||
|
||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::IntList &V) {
|
||||
Poco::JSON::Array A;
|
||||
for (const auto &i : V)
|
||||
A.add(i);
|
||||
Obj.set(Field, A);
|
||||
}
|
||||
|
||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::TagList &V) {
|
||||
Poco::JSON::Array A;
|
||||
for (const auto &i : V)
|
||||
@@ -298,28 +277,6 @@ namespace OpenWifi::RESTAPI_utils {
|
||||
}
|
||||
}
|
||||
|
||||
inline void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
||||
Types::DoubleList &Value) {
|
||||
if (Obj->isArray(Field) && !Obj->isNull(Field)) {
|
||||
Value.clear();
|
||||
Poco::JSON::Array::Ptr A = Obj->getArray(Field);
|
||||
for (const auto &i : *A) {
|
||||
Value.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
||||
Types::IntList &Value) {
|
||||
if (Obj->isArray(Field) && !Obj->isNull(Field)) {
|
||||
Value.clear();
|
||||
Poco::JSON::Array::Ptr A = Obj->getArray(Field);
|
||||
for (const auto &i : *A) {
|
||||
Value.push_back(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
||||
std::vector<T> &Value) {
|
||||
|
||||
@@ -22,8 +22,9 @@ namespace OpenWifi {
|
||||
|
||||
class StorageClass : public SubSystemServer {
|
||||
public:
|
||||
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {}
|
||||
|
||||
inline int Start() override {
|
||||
int Start() override {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
|
||||
Logger().notice("Starting.");
|
||||
@@ -39,22 +40,17 @@ namespace OpenWifi {
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline void Stop() override { Pool_->shutdown(); }
|
||||
void Stop() override { Pool_->shutdown(); }
|
||||
|
||||
DBType Type() const { return dbType_; };
|
||||
|
||||
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {
|
||||
|
||||
}
|
||||
|
||||
private:
|
||||
inline int Setup_SQLite();
|
||||
inline int Setup_MySQL();
|
||||
inline int Setup_PostgreSQL();
|
||||
|
||||
|
||||
protected:
|
||||
std::shared_ptr<Poco::Data::SessionPool> Pool_;
|
||||
protected:
|
||||
std::unique_ptr<Poco::Data::SessionPool> Pool_;
|
||||
Poco::Data::SQLite::Connector SQLiteConn_;
|
||||
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
||||
Poco::Data::MySQL::Connector MySQLConn_;
|
||||
@@ -85,7 +81,7 @@ namespace OpenWifi {
|
||||
// Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
||||
// (int)NumSessions,
|
||||
// (int)IdleTime));
|
||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
||||
(int)NumSessions, (int)IdleTime);
|
||||
return 0;
|
||||
}
|
||||
@@ -106,7 +102,7 @@ namespace OpenWifi {
|
||||
";compress=true;auto-reconnect=true";
|
||||
|
||||
Poco::Data::MySQL::Connector::registerConnector();
|
||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
||||
NumSessions, IdleTime);
|
||||
|
||||
return 0;
|
||||
@@ -130,7 +126,7 @@ namespace OpenWifi {
|
||||
" connect_timeout=" + ConnectionTimeout;
|
||||
|
||||
Poco::Data::PostgreSQL::Connector::registerConnector();
|
||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
||||
NumSessions, IdleTime);
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -401,12 +401,6 @@ namespace OpenWifi::RESTAPI::Errors {
|
||||
1171, "Command not supported on simulated device."
|
||||
};
|
||||
|
||||
static const struct msg VenuesNameAlreadyExists {
|
||||
1172, "The venue name already exists."
|
||||
};
|
||||
|
||||
static const struct msg DefFirmwareNameExists { 1172, "Firmware name already exists." };
|
||||
|
||||
static const struct msg SimulationDoesNotExist {
|
||||
7000, "Simulation Instance ID does not exist."
|
||||
};
|
||||
|
||||
@@ -27,10 +27,6 @@ namespace OpenWifi::Utils {
|
||||
std::all_of(Serial.begin(), Serial.end(), [](auto i) { return std::isxdigit(i); }));
|
||||
}
|
||||
|
||||
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &numbers) {
|
||||
return std::all_of(numbers.begin(),numbers.end(),[](auto &number) {return ValidSerialNumber(number);});
|
||||
}
|
||||
|
||||
[[nodiscard]] bool ValidUUID(const std::string &UUID) {
|
||||
if (UUID.size() > 36)
|
||||
return false;
|
||||
@@ -132,15 +128,6 @@ namespace OpenWifi::Utils {
|
||||
return std::regex_match(Hostname, HostNameRegex);
|
||||
}
|
||||
|
||||
[[nodiscard]] bool ValidNumber(const std::string &number, bool isSigned)
|
||||
{
|
||||
static std::regex IntRegex("^-?[0-9]\\d*(\\.\\d+)?$");
|
||||
if(!isSigned) {
|
||||
IntRegex = "^[0-9]\\d*(\\.\\d+)?$";
|
||||
}
|
||||
return std::regex_match(number, IntRegex);
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string ToHex(const std::vector<unsigned char> &B) {
|
||||
std::string R;
|
||||
R.reserve(B.size() * 2);
|
||||
|
||||
@@ -13,8 +13,6 @@
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <dirent.h>
|
||||
|
||||
#include "Poco/Base64Decoder.h"
|
||||
#include "Poco/Base64Encoder.h"
|
||||
#include "Poco/File.h"
|
||||
@@ -70,10 +68,8 @@ namespace OpenWifi::Utils {
|
||||
};
|
||||
|
||||
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial);
|
||||
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &Serial);
|
||||
[[nodiscard]] bool ValidUUID(const std::string &UUID);
|
||||
[[nodiscard]] bool ValidHostname(const std::string &hostname);
|
||||
[[nodiscard]] bool ValidNumber(const std::string &number, bool isSigned);
|
||||
|
||||
template <typename... Args> std::string ComputeHash(Args &&...args) {
|
||||
Poco::SHA2Engine E;
|
||||
@@ -184,67 +180,4 @@ namespace OpenWifi::Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
static inline std::uint64_t GetValue(FILE *file) {
|
||||
unsigned long v=0;
|
||||
char factor[32];
|
||||
if(fscanf(file, " %lu %31s", &v, factor)==2) {
|
||||
switch (factor[0]) {
|
||||
case 'k':
|
||||
return v * 1000;
|
||||
case 'M':
|
||||
return v * 1000000;
|
||||
case 'G':
|
||||
return v * 1000000000;
|
||||
}
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
inline bool getMemory(
|
||||
std::uint64_t &currRealMem, std::uint64_t &peakRealMem,
|
||||
std::uint64_t &currVirtMem, std::uint64_t &peakVirtMem) {
|
||||
|
||||
// stores each word in status file
|
||||
char buffer[1024] = "";
|
||||
|
||||
currRealMem = peakRealMem = currVirtMem = peakVirtMem = 0;
|
||||
|
||||
// linux file contains this-process info
|
||||
FILE * file = std::fopen("/proc/self/status", "r");
|
||||
if (file == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the entire file, recording mems in kB
|
||||
while (fscanf(file, " %1023s", buffer) == 1) {
|
||||
|
||||
if (strcmp(buffer, "VmRSS:") == 0) {
|
||||
currRealMem= GetValue(file);
|
||||
} else if (strcmp(buffer, "VmHWM:") == 0) {
|
||||
peakRealMem= GetValue(file);
|
||||
} else if (strcmp(buffer, "VmSize:") == 0) {
|
||||
currVirtMem= GetValue(file);
|
||||
} else if (strcmp(buffer, "VmPeak:") == 0) {
|
||||
peakVirtMem= GetValue(file);
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
inline int get_open_fds() {
|
||||
DIR *dp = opendir("/proc/self/fd");
|
||||
struct dirent *de;
|
||||
int count = -3; // '.', '..', dp
|
||||
|
||||
if (dp == nullptr)
|
||||
return -1;
|
||||
while ((de = readdir(dp)) != nullptr)
|
||||
count++;
|
||||
(void)closedir(dp);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
} // namespace OpenWifi::Utils
|
||||
|
||||
@@ -112,31 +112,6 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VenueDB::DoesVenueNameAlreadyExist(const std::string &name, const std::string &entity_uuid, const std::string &parent_uuid) {
|
||||
|
||||
std::string Statement;
|
||||
if(!entity_uuid.empty()) {
|
||||
Statement = fmt::format("select count(*) from venues where entity='{}' and upper(name)='{}'",
|
||||
entity_uuid, Poco::toUpper(name));
|
||||
} else {
|
||||
Statement = fmt::format("select count(*) from venues where parent='{}' and upper(name)='{}'",
|
||||
parent_uuid, Poco::toUpper(name));
|
||||
}
|
||||
|
||||
std::uint64_t RecordCount = 0;
|
||||
try {
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
Poco::Data::Statement Command(Session);
|
||||
|
||||
Command << Statement,
|
||||
Poco::Data::Keywords::into(RecordCount);
|
||||
Command.execute();
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return RecordCount!=0;
|
||||
}
|
||||
|
||||
} // namespace OpenWifi
|
||||
|
||||
template <>
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace OpenWifi {
|
||||
bool GetByIP(const std::string &IP, std::string &uuid);
|
||||
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||
bool EvaluateDeviceRules(const std::string &id, ProvObjects::DeviceRules &Rules);
|
||||
bool DoesVenueNameAlreadyExist(const std::string &name, const std::string &entity_uuid, const std::string &parent_uuid);
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user