mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-10-30 02:12:22 +00:00
Compare commits
30 Commits
v2.9.0-RC1
...
v2.11.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8466e0e025 | ||
|
|
a408d0d128 | ||
|
|
fb2f53c63d | ||
|
|
b018dc70ef | ||
|
|
42d44b056e | ||
|
|
7d9d5b4d15 | ||
|
|
7fc77e529b | ||
|
|
e8986d84b4 | ||
|
|
f54fd2b411 | ||
|
|
86f3754c7e | ||
|
|
4223cb8146 | ||
|
|
260927a3eb | ||
|
|
bb571ad11a | ||
|
|
bd0fbfd6d2 | ||
|
|
33ba7b2323 | ||
|
|
28cbc79890 | ||
|
|
0137d8ee66 | ||
|
|
1ca77de37e | ||
|
|
bd5ae332bd | ||
|
|
28dcf0085c | ||
|
|
f1a687f6e1 | ||
|
|
d2bae99b3c | ||
|
|
180d8d1502 | ||
|
|
bd7eca32f4 | ||
|
|
43658550df | ||
|
|
c113fc24c5 | ||
|
|
5ddbd0bad3 | ||
|
|
8d030ff51b | ||
|
|
388e5d9aee | ||
|
|
a1ea461b68 |
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(owfms VERSION 2.9.0)
|
project(owfms VERSION 2.11.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
@@ -61,7 +61,7 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu
|
|||||||
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
||||||
|
|
||||||
add_compile_options(-Wall -Wextra)
|
add_compile_options(-Wall -Wextra)
|
||||||
add_definitions(-DPOCO_LOG_DEBUG="1")
|
add_definitions(-DPOCO_LOG_DEBUG="1" -DBOOST_NO_CXX98_FUNCTION_BASE=1)
|
||||||
|
|
||||||
if(ASAN)
|
if(ASAN)
|
||||||
add_compile_options(-fsanitize=address)
|
add_compile_options(-fsanitize=address)
|
||||||
@@ -117,6 +117,7 @@ add_executable( owfms
|
|||||||
src/framework/RESTAPI_PartHandler.h
|
src/framework/RESTAPI_PartHandler.h
|
||||||
src/framework/MicroService.cpp
|
src/framework/MicroService.cpp
|
||||||
src/framework/MicroServiceExtra.h
|
src/framework/MicroServiceExtra.h
|
||||||
|
src/framework/default_device_types.h
|
||||||
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
|
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
|
||||||
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
|
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
|
||||||
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.cpp
|
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.cpp
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ s3.secret = *******************************************
|
|||||||
s3.key = *******************************************
|
s3.key = *******************************************
|
||||||
s3.retry = 60
|
s3.retry = 60
|
||||||
s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com
|
s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com
|
||||||
|
s3.endpoint.https = true
|
||||||
|
s3.endpointOverride = ""
|
||||||
|
s3.useVirtualAdressing = true
|
||||||
```
|
```
|
||||||
|
|
||||||
#### s3.bucketname
|
#### s3.bucketname
|
||||||
@@ -44,6 +47,12 @@ The AWS key for access for this S3 bucket
|
|||||||
The AWS retry window in seconds.
|
The AWS retry window in seconds.
|
||||||
#### s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com
|
#### s3.bucket.uri = ucentral-ap-firmware.s3.amazonaws.com
|
||||||
The URI to the S3 bucket
|
The URI to the S3 bucket
|
||||||
|
#### s3.endpointOverride = ""
|
||||||
|
The Endpoint Address to override if you using a different provider that not AWS.
|
||||||
|
#### s3.endpoint.https = true
|
||||||
|
The Endpoint Method if you using a HTTP endpoint
|
||||||
|
#### s3.useVirtualAdressing = true
|
||||||
|
In a virtual-hosted–style URI, the bucket name is part of the domain name in the URL. (Not supported by all providers)
|
||||||
|
|
||||||
## Generic OpenWiFi SDK parameters
|
## Generic OpenWiFi SDK parameters
|
||||||
### REST API External parameters
|
### REST API External parameters
|
||||||
|
|||||||
49
Dockerfile
49
Dockerfile
@@ -1,6 +1,9 @@
|
|||||||
ARG DEBIAN_VERSION=11.5-slim
|
ARG DEBIAN_VERSION=11.5-slim
|
||||||
ARG POCO_VERSION=poco-tip-v2
|
ARG POCO_VERSION=poco-tip-v2
|
||||||
ARG CPPKAFKA_VERSION=tip-v1
|
ARG CPPKAFKA_VERSION=tip-v1
|
||||||
|
ARG VALIJASON_VERSION=tip-v1
|
||||||
|
ARG APP_NAME=owfms
|
||||||
|
ARG APP_HOME_DIR=/openwifi
|
||||||
|
|
||||||
FROM debian:$DEBIAN_VERSION AS build-base
|
FROM debian:$DEBIAN_VERSION AS build-base
|
||||||
|
|
||||||
@@ -38,14 +41,17 @@ RUN cmake ..
|
|||||||
RUN cmake --build . --config Release -j8
|
RUN cmake --build . --config Release -j8
|
||||||
RUN cmake --build . --target install
|
RUN cmake --build . --target install
|
||||||
|
|
||||||
FROM build-base AS owfms-build
|
FROM build-base AS app-build
|
||||||
|
|
||||||
ADD CMakeLists.txt build /owfms/
|
ARG APP_NAME
|
||||||
ADD overlays /owfms/overlays
|
|
||||||
ADD cmake /owfms/cmake
|
ADD CMakeLists.txt build /${APP_NAME}/
|
||||||
ADD src /owfms/src
|
ADD overlays /${APP_NAME}/overlays
|
||||||
ADD .git /owfms/.git
|
ADD cmake /${APP_NAME}/cmake
|
||||||
|
ADD src /${APP_NAME}/src
|
||||||
|
ADD .git /${APP_NAME}/.git
|
||||||
ARG VCPKG_VERSION=2022.11.14
|
ARG VCPKG_VERSION=2022.11.14
|
||||||
|
|
||||||
RUN git clone --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg && \
|
RUN git clone --depth 1 --branch ${VCPKG_VERSION} https://github.com/microsoft/vcpkg && \
|
||||||
./vcpkg/bootstrap-vcpkg.sh && \
|
./vcpkg/bootstrap-vcpkg.sh && \
|
||||||
mkdir /vcpkg/custom-triplets && \
|
mkdir /vcpkg/custom-triplets && \
|
||||||
@@ -58,23 +64,28 @@ COPY --from=poco-build /usr/local/lib /usr/local/lib
|
|||||||
COPY --from=cppkafka-build /usr/local/include /usr/local/include
|
COPY --from=cppkafka-build /usr/local/include /usr/local/include
|
||||||
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
|
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
|
||||||
|
|
||||||
WORKDIR /owfms
|
WORKDIR /${APP_NAME}
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
WORKDIR /owfms/cmake-build
|
WORKDIR /${APP_NAME}/cmake-build
|
||||||
RUN cmake -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake ..
|
RUN cmake -DCMAKE_TOOLCHAIN_FILE=/vcpkg/scripts/buildsystems/vcpkg.cmake ..
|
||||||
RUN cmake --build . --config Release -j8
|
RUN cmake --build . --config Release -j8
|
||||||
|
|
||||||
FROM debian:$DEBIAN_VERSION
|
FROM debian:$DEBIAN_VERSION
|
||||||
|
|
||||||
ENV OWFMS_USER=owfms \
|
ARG APP_NAME
|
||||||
OWFMS_ROOT=/owfms-data \
|
ARG APP_HOME_DIR
|
||||||
OWFMS_CONFIG=/owfms-data
|
|
||||||
|
|
||||||
RUN useradd "$OWFMS_USER"
|
ENV APP_NAME=$APP_NAME \
|
||||||
|
APP_USER=$APP_NAME \
|
||||||
|
APP_ROOT=/$APP_NAME-data \
|
||||||
|
APP_CONFIG=/$APP_NAME-data \
|
||||||
|
APP_HOME_DIR=$APP_HOME_DIR
|
||||||
|
|
||||||
RUN mkdir /openwifi
|
RUN useradd $APP_USER
|
||||||
RUN mkdir -p "$OWFMS_ROOT" "$OWFMS_CONFIG" && \
|
|
||||||
chown "$OWFMS_USER": "$OWFMS_ROOT" "$OWFMS_CONFIG"
|
RUN mkdir $APP_HOME_DIR
|
||||||
|
RUN mkdir -p "$APP_ROOT" "$APP_CONFIG" && \
|
||||||
|
chown "$APP_USER": "$APP_ROOT" "$APP_CONFIG"
|
||||||
|
|
||||||
RUN apt-get update && apt-get install --no-install-recommends -y \
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
|
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
|
||||||
@@ -83,14 +94,14 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
|
|||||||
COPY readiness_check /readiness_check
|
COPY readiness_check /readiness_check
|
||||||
COPY test_scripts/curl/cli /cli
|
COPY test_scripts/curl/cli /cli
|
||||||
|
|
||||||
COPY owfms.properties.tmpl /
|
COPY $APP_NAME.properties.tmpl /
|
||||||
COPY docker-entrypoint.sh /
|
COPY docker-entrypoint.sh /
|
||||||
COPY wait-for-postgres.sh /
|
COPY wait-for-postgres.sh /
|
||||||
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
||||||
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
|
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
|
||||||
|
|
||||||
COPY --from=owfms-build /owfms/cmake-build/owfms /openwifi/owfms
|
COPY --from=app-build /$APP_NAME/cmake-build/$APP_NAME $APP_HOME_DIR/$APP_NAME
|
||||||
COPY --from=owfms-build /vcpkg/installed/x64-linux/lib/ /usr/local/lib/
|
COPY --from=app-build /vcpkg/installed/x64-linux/lib/ /usr/local/lib/
|
||||||
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/ /usr/local/lib/
|
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/ /usr/local/lib/
|
||||||
COPY --from=poco-build /poco/cmake-build/lib/ /usr/local/lib/
|
COPY --from=poco-build /poco/cmake-build/lib/ /usr/local/lib/
|
||||||
|
|
||||||
@@ -99,4 +110,4 @@ RUN ldconfig
|
|||||||
EXPOSE 16004 17004 16104
|
EXPOSE 16004 17004 16104
|
||||||
|
|
||||||
ENTRYPOINT ["/docker-entrypoint.sh"]
|
ENTRYPOINT ["/docker-entrypoint.sh"]
|
||||||
CMD ["/openwifi/owfms"]
|
CMD ${APP_HOME_DIR}/${APP_NAME}
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then
|
|||||||
SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \
|
SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \
|
||||||
FIRMWAREDB_REFRESH=${FIRMWAREDB_REFRESH:-"86400"} \
|
FIRMWAREDB_REFRESH=${FIRMWAREDB_REFRESH:-"86400"} \
|
||||||
FIRMWAREDB_MAXAGE=${FIRMWAREDB_MAXAGE:-"90"} \
|
FIRMWAREDB_MAXAGE=${FIRMWAREDB_MAXAGE:-"90"} \
|
||||||
|
S3_VIRTUAL_ADRESSING=${S3_VIRTUAL_ADRESSING:-"true"} \
|
||||||
|
S3_HTTPS=${S3_HTTPS:-"true"} \
|
||||||
|
S3_ENDPOINT=${S3_ENDPOINT:-""} \
|
||||||
S3_BUCKETNAME=${S3_BUCKETNAME:-"ucentral-ap-firmware"} \
|
S3_BUCKETNAME=${S3_BUCKETNAME:-"ucentral-ap-firmware"} \
|
||||||
S3_REGION=${S3_REGION:-"us-east-1"} \
|
S3_REGION=${S3_REGION:-"us-east-1"} \
|
||||||
S3_SECRET=${S3_SECRET:-"*******************************************"} \
|
S3_SECRET=${S3_SECRET:-"*******************************************"} \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
|||||||
images:
|
images:
|
||||||
owfms:
|
owfms:
|
||||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owfms
|
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owfms
|
||||||
tag: main
|
tag: v2.11.0
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
# regcred:
|
# regcred:
|
||||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||||
@@ -143,6 +143,9 @@ configProperties:
|
|||||||
openwifi.internal.restapi.host.0.cert: $OWFMS_ROOT/certs/restapi-cert.pem
|
openwifi.internal.restapi.host.0.cert: $OWFMS_ROOT/certs/restapi-cert.pem
|
||||||
openwifi.internal.restapi.host.0.key: $OWFMS_ROOT/certs/restapi-key.pem
|
openwifi.internal.restapi.host.0.key: $OWFMS_ROOT/certs/restapi-key.pem
|
||||||
# Firmware Microservice Specific Section
|
# Firmware Microservice Specific Section
|
||||||
|
s3.endpointOverride: ""
|
||||||
|
s3.useVirtualAdressing: true
|
||||||
|
s3.endpoint.https: true
|
||||||
s3.bucketname: ucentral-ap-firmware
|
s3.bucketname: ucentral-ap-firmware
|
||||||
s3.region: us-east-1
|
s3.region: us-east-1
|
||||||
s3.retry: 60
|
s3.retry: 60
|
||||||
|
|||||||
@@ -353,6 +353,33 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
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'
|
||||||
|
|
||||||
SystemCommandSetLogLevel:
|
SystemCommandSetLogLevel:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -743,19 +770,19 @@ paths:
|
|||||||
operationId: getFirmwareAge
|
operationId: getFirmwareAge
|
||||||
parameters:
|
parameters:
|
||||||
- in: query
|
- in: query
|
||||||
description: The exact current verion of the firmware on that device.
|
description: The exact current version of the firmware on that device.
|
||||||
name: revision
|
name: revision
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
- in: query
|
- in: query
|
||||||
description: The exact current verion of the firmware on that device.
|
description: The exact current version of the firmware on that device.
|
||||||
name: deviceType
|
name: deviceType
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
required: true
|
required: true
|
||||||
- in: query
|
- in: query
|
||||||
description: Specify lits of serial numbers to retrive age for
|
description: Specify list of serial numbers to retrieve age for
|
||||||
name: select
|
name: select
|
||||||
schema:
|
schema:
|
||||||
type: string
|
type: string
|
||||||
@@ -925,16 +952,12 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- info
|
- info
|
||||||
|
- extraConfiguration
|
||||||
|
- resources
|
||||||
required: true
|
required: true
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Successfull command execution
|
$ref: '#/components/schemas/SystemCommandResults'
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
oneOf:
|
|
||||||
- $ref: '#/components/schemas/SystemInfoResults'
|
|
||||||
403:
|
403:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
404:
|
404:
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ firmwaredb.maxage = 90
|
|||||||
#
|
#
|
||||||
# Firmware Microservice Specific Section
|
# Firmware Microservice Specific Section
|
||||||
#
|
#
|
||||||
|
s3.useVirtualAdressing = true
|
||||||
|
s3.endpoint.https = true
|
||||||
s3.bucketname = ucentral-ap-firmware
|
s3.bucketname = ucentral-ap-firmware
|
||||||
s3.region = us-east-1
|
s3.region = us-east-1
|
||||||
s3.secret = *******************************************
|
s3.secret = *******************************************
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ firmwaredb.maxage = ${FIRMWAREDB_MAXAGE}
|
|||||||
#
|
#
|
||||||
# Firmware Microservice Specific Section
|
# Firmware Microservice Specific Section
|
||||||
#
|
#
|
||||||
|
s3.useVirtualAdressing = ${S3_VIRTUAL_ADRESSING}
|
||||||
|
s3.endpointOverride = ${S3_ENDPOINT}
|
||||||
|
s3.endpoint.https = ${S3_HTTPS}
|
||||||
s3.bucketname = ${S3_BUCKETNAME}
|
s3.bucketname = ${S3_BUCKETNAME}
|
||||||
s3.region = ${S3_REGION}
|
s3.region = ${S3_REGION}
|
||||||
s3.secret = ${S3_SECRET}
|
s3.secret = ${S3_SECRET}
|
||||||
|
|||||||
@@ -148,6 +148,9 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
int ManifestCreator::Start() {
|
int ManifestCreator::Start() {
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
|
S3EndpointOverride_ = MicroServiceConfigGetString("s3.endpointOverride", "");
|
||||||
|
S3EndpointHttps_ = MicroServiceConfigGetBool("s3.endpoint.https", true);
|
||||||
|
S3UseVirtualAdressing_ = MicroServiceConfigGetBool("s3.useVirtualAdressing", true);
|
||||||
S3BucketName_ = MicroServiceConfigGetString("s3.bucketname", "");
|
S3BucketName_ = MicroServiceConfigGetString("s3.bucketname", "");
|
||||||
S3Region_ = MicroServiceConfigGetString("s3.region", "");
|
S3Region_ = MicroServiceConfigGetString("s3.region", "");
|
||||||
S3Secret_ = MicroServiceConfigGetString("s3.secret", "");
|
S3Secret_ = MicroServiceConfigGetString("s3.secret", "");
|
||||||
@@ -160,6 +163,12 @@ namespace OpenWifi {
|
|||||||
AwsConfig_.enableTcpKeepAlive = true;
|
AwsConfig_.enableTcpKeepAlive = true;
|
||||||
AwsConfig_.enableEndpointDiscovery = true;
|
AwsConfig_.enableEndpointDiscovery = true;
|
||||||
AwsConfig_.useDualStack = true;
|
AwsConfig_.useDualStack = true;
|
||||||
|
if(!S3EndpointHttps_)
|
||||||
|
AwsConfig_.scheme = Aws::Http::Scheme::HTTP;
|
||||||
|
if(!S3EndpointOverride_.empty()) {
|
||||||
|
AwsConfig_.endpointOverride = Aws::String(S3EndpointOverride_);
|
||||||
|
AwsConfig_.useDualStack = false;
|
||||||
|
}
|
||||||
if (!S3Region_.empty())
|
if (!S3Region_.empty())
|
||||||
AwsConfig_.region = S3Region_;
|
AwsConfig_.region = S3Region_;
|
||||||
AwsCreds_.SetAWSAccessKeyId(S3Key_);
|
AwsCreds_.SetAWSAccessKeyId(S3Key_);
|
||||||
@@ -214,7 +223,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
Aws::S3::Model::ListObjectsV2Request Request;
|
Aws::S3::Model::ListObjectsV2Request Request;
|
||||||
Request.WithBucket(S3BucketName_.c_str());
|
Request.WithBucket(S3BucketName_.c_str());
|
||||||
Aws::S3::S3Client S3Client(AwsCreds_, AwsConfig_);
|
Aws::S3::S3Client S3Client(AwsCreds_, AwsConfig_, Aws::Client::AWSAuthV4Signer::PayloadSigningPolicy::Never, S3UseVirtualAdressing_);
|
||||||
Request.SetMaxKeys(100);
|
Request.SetMaxKeys(100);
|
||||||
Aws::S3::Model::ListObjectsV2Outcome Outcome;
|
Aws::S3::Model::ListObjectsV2Outcome Outcome;
|
||||||
|
|
||||||
@@ -317,7 +326,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
// std::cout << "Count:" << Count << " Runs:" << Runs << std::endl;
|
// std::cout << "Count:" << Count << " Runs:" << Runs << std::endl;
|
||||||
if (!Outcome.IsSuccess()) {
|
if (!Outcome.IsSuccess()) {
|
||||||
poco_error(Logger(), fmt::format("Error while doing ListObjectsV2: {}, {}",
|
poco_error(Logger(), fmt::format("Run({},{}) Error while doing ListObjectsV2: {}, {}",
|
||||||
|
Runs, Count,
|
||||||
std::string{Outcome.GetError().GetExceptionName()},
|
std::string{Outcome.GetError().GetExceptionName()},
|
||||||
std::string{Outcome.GetError().GetMessage()}));
|
std::string{Outcome.GetError().GetMessage()}));
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -54,6 +54,9 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
std::atomic_bool Running_ = false;
|
std::atomic_bool Running_ = false;
|
||||||
|
Aws::String S3EndpointOverride_;
|
||||||
|
bool S3EndpointHttps_;
|
||||||
|
bool S3UseVirtualAdressing_;
|
||||||
Aws::String S3BucketName_;
|
Aws::String S3BucketName_;
|
||||||
Aws::String S3Region_;
|
Aws::String S3Region_;
|
||||||
Aws::String S3Key_;
|
Aws::String S3Key_;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
#ifdef TIP_GATEWAY_SERVICE
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
#include "AP_WS_Server.h"
|
#include "AP_WS_Server.h"
|
||||||
#include "CapabilitiesCache.h"
|
#include "CapabilitiesCache.h"
|
||||||
|
#include "RADIUSSessionTracker.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "RESTAPI_GWobjects.h"
|
#include "RESTAPI_GWobjects.h"
|
||||||
@@ -29,6 +30,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj, "serialNumber", SerialNumber);
|
field_to_json(Obj, "serialNumber", SerialNumber);
|
||||||
#ifdef TIP_GATEWAY_SERVICE
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
field_to_json(Obj, "deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
|
field_to_json(Obj, "deviceType", CapabilitiesCache::instance()->GetPlatform(Compatible));
|
||||||
|
field_to_json(Obj, "hasRADIUSSessions", RADIUSSessionTracker()->HasSessions(SerialNumber));
|
||||||
#endif
|
#endif
|
||||||
field_to_json(Obj, "macAddress", MACAddress);
|
field_to_json(Obj, "macAddress", MACAddress);
|
||||||
field_to_json(Obj, "manufacturer", Manufacturer);
|
field_to_json(Obj, "manufacturer", Manufacturer);
|
||||||
@@ -54,6 +56,9 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj, "pendingConfiguration", pendingConfiguration);
|
field_to_json(Obj, "pendingConfiguration", pendingConfiguration);
|
||||||
field_to_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
|
field_to_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
|
||||||
field_to_json(Obj, "restrictionDetails", restrictionDetails);
|
field_to_json(Obj, "restrictionDetails", restrictionDetails);
|
||||||
|
field_to_json(Obj, "pendingUUID", pendingUUID);
|
||||||
|
field_to_json(Obj, "simulated", simulated);
|
||||||
|
field_to_json(Obj, "lastRecordedContact", lastRecordedContact);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
|
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
|
||||||
@@ -63,7 +68,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
ConnectionState ConState;
|
ConnectionState ConState;
|
||||||
|
|
||||||
if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
|
if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
|
||||||
ConState.to_json(Obj);
|
ConState.to_json(SerialNumber,Obj);
|
||||||
} else {
|
} else {
|
||||||
field_to_json(Obj, "ipAddress", "");
|
field_to_json(Obj, "ipAddress", "");
|
||||||
field_to_json(Obj, "txBytes", (uint64_t)0);
|
field_to_json(Obj, "txBytes", (uint64_t)0);
|
||||||
@@ -75,6 +80,13 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj, "associations_2G", (uint64_t)0);
|
field_to_json(Obj, "associations_2G", (uint64_t)0);
|
||||||
field_to_json(Obj, "associations_5G", (uint64_t)0);
|
field_to_json(Obj, "associations_5G", (uint64_t)0);
|
||||||
field_to_json(Obj, "associations_6G", (uint64_t)0);
|
field_to_json(Obj, "associations_6G", (uint64_t)0);
|
||||||
|
field_to_json(Obj, "hasRADIUSSessions", false);
|
||||||
|
field_to_json(Obj, "hasGPS", ConState.hasGPS);
|
||||||
|
field_to_json(Obj, "sanity", ConState.sanity);
|
||||||
|
field_to_json(Obj, "memoryUsed", ConState.memoryUsed);
|
||||||
|
field_to_json(Obj, "sanity", ConState.sanity);
|
||||||
|
field_to_json(Obj, "load", ConState.load);
|
||||||
|
field_to_json(Obj, "temperature", ConState.temperature);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -84,20 +96,32 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_from_json(Obj, "serialNumber", SerialNumber);
|
field_from_json(Obj, "serialNumber", SerialNumber);
|
||||||
field_from_json(Obj, "deviceType", DeviceType);
|
field_from_json(Obj, "deviceType", DeviceType);
|
||||||
field_from_json(Obj, "macAddress", MACAddress);
|
field_from_json(Obj, "macAddress", MACAddress);
|
||||||
|
field_from_json(Obj, "manufacturer", Manufacturer);
|
||||||
|
field_from_json(Obj, "UUID", UUID);
|
||||||
field_from_json(Obj, "configuration", Configuration);
|
field_from_json(Obj, "configuration", Configuration);
|
||||||
field_from_json(Obj, "notes", Notes);
|
field_from_json(Obj, "notes", Notes);
|
||||||
field_from_json(Obj, "manufacturer", Manufacturer);
|
field_from_json(Obj, "createdTimestamp", CreationTimestamp);
|
||||||
|
field_from_json(Obj, "lastConfigurationChange", LastConfigurationChange);
|
||||||
|
field_from_json(Obj, "lastConfigurationDownload", LastConfigurationDownload);
|
||||||
|
field_from_json(Obj, "lastFWUpdate", LastFWUpdate);
|
||||||
field_from_json(Obj, "owner", Owner);
|
field_from_json(Obj, "owner", Owner);
|
||||||
field_from_json(Obj, "location", Location);
|
field_from_json(Obj, "location", Location);
|
||||||
field_from_json(Obj, "venue", Venue);
|
field_from_json(Obj, "venue", Venue);
|
||||||
|
field_from_json(Obj, "firmware", Firmware);
|
||||||
field_from_json(Obj, "compatible", Compatible);
|
field_from_json(Obj, "compatible", Compatible);
|
||||||
|
field_from_json(Obj, "fwUpdatePolicy", FWUpdatePolicy);
|
||||||
|
field_from_json(Obj, "devicePassword", DevicePassword);
|
||||||
field_from_json(Obj, "subscriber", subscriber);
|
field_from_json(Obj, "subscriber", subscriber);
|
||||||
field_from_json(Obj, "entity", entity);
|
field_from_json(Obj, "entity", entity);
|
||||||
|
field_from_json(Obj, "modified", modified);
|
||||||
field_from_json(Obj, "locale", locale);
|
field_from_json(Obj, "locale", locale);
|
||||||
field_from_json(Obj, "restrictedDevice", restrictedDevice);
|
field_from_json(Obj, "restrictedDevice", restrictedDevice);
|
||||||
field_from_json(Obj, "pendingConfiguration", pendingConfiguration);
|
field_from_json(Obj, "pendingConfiguration", pendingConfiguration);
|
||||||
field_from_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
|
field_from_json(Obj, "pendingConfigurationCmd", pendingConfigurationCmd);
|
||||||
field_from_json(Obj, "restrictionDetails", restrictionDetails);
|
field_from_json(Obj, "restrictionDetails", restrictionDetails);
|
||||||
|
field_from_json(Obj, "pendingUUID", pendingUUID);
|
||||||
|
field_from_json(Obj, "simulated", simulated);
|
||||||
|
field_from_json(Obj, "lastRecordedContact", lastRecordedContact);
|
||||||
return true;
|
return true;
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
}
|
}
|
||||||
@@ -165,6 +189,8 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj, "waitingForFile", WaitingForFile);
|
field_to_json(Obj, "waitingForFile", WaitingForFile);
|
||||||
field_to_json(Obj, "attachFile", AttachDate);
|
field_to_json(Obj, "attachFile", AttachDate);
|
||||||
field_to_json(Obj, "executionTime", executionTime);
|
field_to_json(Obj, "executionTime", executionTime);
|
||||||
|
field_to_json(Obj, "lastTry", lastTry);
|
||||||
|
field_to_json(Obj, "deferred", deferred);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -198,7 +224,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConnectionState::to_json(Poco::JSON::Object &Obj) const {
|
void ConnectionState::to_json([[maybe_unused]] const std::string &SerialNumber, Poco::JSON::Object &Obj) {
|
||||||
field_to_json(Obj, "ipAddress", Address);
|
field_to_json(Obj, "ipAddress", Address);
|
||||||
field_to_json(Obj, "txBytes", TX);
|
field_to_json(Obj, "txBytes", TX);
|
||||||
field_to_json(Obj, "rxBytes", RX);
|
field_to_json(Obj, "rxBytes", RX);
|
||||||
@@ -220,6 +246,20 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj, "connectionCompletionTime", connectionCompletionTime);
|
field_to_json(Obj, "connectionCompletionTime", connectionCompletionTime);
|
||||||
field_to_json(Obj, "totalConnectionTime", Utils::Now() - started);
|
field_to_json(Obj, "totalConnectionTime", Utils::Now() - started);
|
||||||
field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate);
|
field_to_json(Obj, "certificateExpiryDate", certificateExpiryDate);
|
||||||
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
|
hasRADIUSSessions = RADIUSSessionTracker()->HasSessions(SerialNumber);
|
||||||
|
AP_WS_Server()->ExtendedAttributes(SerialNumber, hasGPS, sanity,
|
||||||
|
memoryUsed,
|
||||||
|
load,
|
||||||
|
temperature);
|
||||||
|
#endif
|
||||||
|
field_to_json(Obj, "hasRADIUSSessions", hasRADIUSSessions );
|
||||||
|
field_to_json(Obj, "hasGPS", hasGPS);
|
||||||
|
field_to_json(Obj, "sanity", sanity);
|
||||||
|
field_to_json(Obj, "memoryUsed", memoryUsed);
|
||||||
|
field_to_json(Obj, "sanity", sanity);
|
||||||
|
field_to_json(Obj, "load", load);
|
||||||
|
field_to_json(Obj, "temperature", temperature);
|
||||||
|
|
||||||
switch (VerifiedCertificate) {
|
switch (VerifiedCertificate) {
|
||||||
case NO_CERTIFICATE:
|
case NO_CERTIFICATE:
|
||||||
@@ -234,6 +274,9 @@ namespace OpenWifi::GWObjects {
|
|||||||
case VERIFIED:
|
case VERIFIED:
|
||||||
field_to_json(Obj, "verifiedCertificate", "VERIFIED");
|
field_to_json(Obj, "verifiedCertificate", "VERIFIED");
|
||||||
break;
|
break;
|
||||||
|
case SIMULATED:
|
||||||
|
field_to_json(Obj, "verifiedCertificate", "SIMULATED");
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
field_to_json(Obj, "verifiedCertificate", "NO_CERTIFICATE");
|
field_to_json(Obj, "verifiedCertificate", "NO_CERTIFICATE");
|
||||||
break;
|
break;
|
||||||
@@ -490,6 +533,29 @@ namespace OpenWifi::GWObjects {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RangeOptions::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "NO_IR", NO_IR);
|
||||||
|
field_to_json(Obj, "AUTO_BW", AUTO_BW);
|
||||||
|
field_to_json(Obj, "DFS", DFS);
|
||||||
|
field_to_json(Obj, "NO_OUTDOOR", NO_OUTDOOR);
|
||||||
|
field_to_json(Obj, "wmmrule_ETSI", wmmrule_ETSI);
|
||||||
|
field_to_json(Obj, "NO_OFDM", NO_OFDM);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FrequencyRange::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "from", from);
|
||||||
|
field_to_json(Obj, "to", to);
|
||||||
|
field_to_json(Obj, "channelWidth", channelWidth);
|
||||||
|
field_to_json(Obj, "powerDb", powerDb);
|
||||||
|
field_to_json(Obj, "options", options);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegulatoryCountryInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "country", country);
|
||||||
|
field_to_json(Obj, "domain", domain);
|
||||||
|
field_to_json(Obj, "ranges", ranges);
|
||||||
|
}
|
||||||
|
|
||||||
void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
|
void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj, "vendor", vendor);
|
field_to_json(Obj, "vendor", vendor);
|
||||||
field_to_json(Obj, "algo", algo);
|
field_to_json(Obj, "algo", algo);
|
||||||
@@ -544,4 +610,42 @@ namespace OpenWifi::GWObjects {
|
|||||||
(T.commands != commands) || (T.developer != developer) || (T.ssh != ssh) ||
|
(T.commands != commands) || (T.developer != developer) || (T.ssh != ssh) ||
|
||||||
(T.key_info != key_info) || (T.country != country));
|
(T.key_info != key_info) || (T.country != country));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RADIUSSession::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "started", started);
|
||||||
|
field_to_json(Obj, "lastTransaction", lastTransaction);
|
||||||
|
field_to_json(Obj, "destination", destination);
|
||||||
|
field_to_json(Obj, "serialNumber", serialNumber);
|
||||||
|
field_to_json(Obj, "userName", userName);
|
||||||
|
field_to_json(Obj, "accountingSessionId", accountingSessionId);
|
||||||
|
field_to_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
|
||||||
|
field_to_json(Obj, "inputPackets", inputPackets);
|
||||||
|
field_to_json(Obj, "outputPackets", outputPackets);
|
||||||
|
field_to_json(Obj, "inputOctets", inputOctets);
|
||||||
|
field_to_json(Obj, "outputOctets", outputOctets);
|
||||||
|
field_to_json(Obj, "inputGigaWords", inputGigaWords);
|
||||||
|
field_to_json(Obj, "outputGigaWords", outputGigaWords);
|
||||||
|
field_to_json(Obj, "sessionTime", sessionTime);
|
||||||
|
field_to_json(Obj, "callingStationId", callingStationId);
|
||||||
|
field_to_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
|
||||||
|
field_to_json(Obj, "interface", interface);
|
||||||
|
field_to_json(Obj, "secret", secret);
|
||||||
|
}
|
||||||
|
|
||||||
|
void RADIUSSessionList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "sessions", sessions);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RadiusCoADMParameters::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "accountingSessionId", accountingSessionId);
|
||||||
|
field_from_json(Obj, "accountingMultiSessionId", accountingMultiSessionId);
|
||||||
|
field_from_json(Obj, "callingStationId", callingStationId);
|
||||||
|
field_from_json(Obj, "chargeableUserIdentity", chargeableUserIdentity);
|
||||||
|
return true;
|
||||||
|
} catch (const Poco::Exception &E) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenWifi::GWObjects
|
} // namespace OpenWifi::GWObjects
|
||||||
|
|||||||
@@ -11,9 +11,13 @@
|
|||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
|
#include <RADIUS_helpers.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace OpenWifi::GWObjects {
|
namespace OpenWifi::GWObjects {
|
||||||
|
|
||||||
enum CertificateValidation { NO_CERTIFICATE, VALID_CERTIFICATE, MISMATCH_SERIAL, VERIFIED };
|
enum CertificateValidation { NO_CERTIFICATE, VALID_CERTIFICATE, MISMATCH_SERIAL, VERIFIED, SIMULATED };
|
||||||
|
|
||||||
struct ConnectionState {
|
struct ConnectionState {
|
||||||
uint64_t MessageCount = 0;
|
uint64_t MessageCount = 0;
|
||||||
@@ -38,8 +42,14 @@ namespace OpenWifi::GWObjects {
|
|||||||
uint64_t sessionId = 0;
|
uint64_t sessionId = 0;
|
||||||
double connectionCompletionTime = 0.0;
|
double connectionCompletionTime = 0.0;
|
||||||
std::uint64_t certificateExpiryDate = 0;
|
std::uint64_t certificateExpiryDate = 0;
|
||||||
|
bool hasRADIUSSessions = false;
|
||||||
|
bool hasGPS = false;
|
||||||
|
std::uint64_t sanity=0;
|
||||||
|
std::double_t memoryUsed=0.0;
|
||||||
|
std::double_t load=0.0;
|
||||||
|
std::double_t temperature=0.0;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(const std::string &SerialNumber, Poco::JSON::Object &Obj) ;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct DeviceRestrictionsKeyInfo {
|
struct DeviceRestrictionsKeyInfo {
|
||||||
@@ -96,6 +106,9 @@ namespace OpenWifi::GWObjects {
|
|||||||
std::string pendingConfiguration;
|
std::string pendingConfiguration;
|
||||||
std::string pendingConfigurationCmd;
|
std::string pendingConfigurationCmd;
|
||||||
DeviceRestrictions restrictionDetails;
|
DeviceRestrictions restrictionDetails;
|
||||||
|
std::uint64_t pendingUUID = 0;
|
||||||
|
bool simulated=false;
|
||||||
|
std::uint64_t lastRecordedContact=0;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
void to_json_with_status(Poco::JSON::Object &Obj) const;
|
void to_json_with_status(Poco::JSON::Object &Obj) const;
|
||||||
@@ -188,7 +201,11 @@ namespace OpenWifi::GWObjects {
|
|||||||
uint64_t AttachSize = 0;
|
uint64_t AttachSize = 0;
|
||||||
std::string AttachType;
|
std::string AttachType;
|
||||||
double executionTime = 0.0;
|
double executionTime = 0.0;
|
||||||
|
std::uint64_t lastTry = 0;
|
||||||
|
bool deferred = false;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
struct BlackListedDevice {
|
struct BlackListedDevice {
|
||||||
@@ -334,4 +351,76 @@ namespace OpenWifi::GWObjects {
|
|||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct RangeOptions {
|
||||||
|
bool NO_IR=false;
|
||||||
|
bool AUTO_BW=false;
|
||||||
|
bool DFS=false;
|
||||||
|
bool NO_OUTDOOR=false;
|
||||||
|
bool wmmrule_ETSI=false;
|
||||||
|
bool NO_OFDM=false;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct FrequencyRange {
|
||||||
|
float from = 0.0;
|
||||||
|
float to = 0.0;
|
||||||
|
int channelWidth = 0;
|
||||||
|
int powerDb = 0;
|
||||||
|
RangeOptions options;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RegulatoryCountryInfo {
|
||||||
|
std::string country;
|
||||||
|
std::string domain;
|
||||||
|
std::vector<FrequencyRange> ranges;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
using RegulatoryInfoCountryMap = std::map<std::string,RegulatoryCountryInfo>;
|
||||||
|
|
||||||
|
struct RADIUSSession {
|
||||||
|
std::uint64_t started=0,
|
||||||
|
lastTransaction=0;
|
||||||
|
std::string serialNumber,
|
||||||
|
destination,
|
||||||
|
userName,
|
||||||
|
accountingSessionId,
|
||||||
|
accountingMultiSessionId,
|
||||||
|
callingStationId,
|
||||||
|
chargeableUserIdentity,
|
||||||
|
secret,
|
||||||
|
interface;
|
||||||
|
std::uint64_t inputPackets = 0,
|
||||||
|
outputPackets = 0,
|
||||||
|
inputOctets = 0,
|
||||||
|
outputOctets = 0,
|
||||||
|
inputGigaWords = 0,
|
||||||
|
outputGigaWords = 0;
|
||||||
|
std::uint32_t sessionTime = 0;
|
||||||
|
|
||||||
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
|
RADIUS::RadiusPacket accountingPacket;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RADIUSSessionList {
|
||||||
|
std::vector<RADIUSSession> sessions;
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RadiusCoADMParameters {
|
||||||
|
std::string accountingSessionId,
|
||||||
|
accountingMultiSessionId,
|
||||||
|
callingStationId,
|
||||||
|
chargeableUserIdentity;
|
||||||
|
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
} // namespace OpenWifi::GWObjects
|
} // namespace OpenWifi::GWObjects
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenWifi {
|
|||||||
Response.set("Connection", "keep-alive");
|
Response.set("Connection", "keep-alive");
|
||||||
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
|
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
std::ostream &Answer = Response.send();
|
std::ostream &Answer = Response.send();
|
||||||
Answer << "process Alive and kicking!";
|
Answer << ALBHealthCheckServer()->CallbackText();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,8 @@ namespace OpenWifi {
|
|||||||
inline static std::atomic_uint64_t req_id_ = 1;
|
inline static std::atomic_uint64_t req_id_ = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef std::string ALBHealthMessageCallback();
|
||||||
|
|
||||||
class ALBHealthCheckServer : public SubSystemServer {
|
class ALBHealthCheckServer : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
ALBHealthCheckServer();
|
ALBHealthCheckServer();
|
||||||
@@ -48,10 +50,22 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
int Start() override;
|
int Start() override;
|
||||||
void Stop() 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:
|
private:
|
||||||
std::unique_ptr<Poco::Net::HTTPServer> Server_;
|
std::unique_ptr<Poco::Net::HTTPServer> Server_;
|
||||||
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
|
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
|
||||||
|
ALBHealthMessageCallback *Callback_= nullptr;
|
||||||
int Port_ = 0;
|
int Port_ = 0;
|
||||||
mutable std::atomic_bool Running_ = false;
|
mutable std::atomic_bool Running_ = false;
|
||||||
};
|
};
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -14,18 +14,18 @@ namespace OpenWifi {
|
|||||||
void EventBusManager::run() {
|
void EventBusManager::run() {
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
Utils::SetThreadName("fmwk:EventMgr");
|
Utils::SetThreadName("fmwk:EventMgr");
|
||||||
auto Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_JOIN);
|
auto Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_JOIN));
|
||||||
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
||||||
false);
|
false);
|
||||||
while (Running_) {
|
while (Running_) {
|
||||||
Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer());
|
Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer());
|
||||||
if (!Running_)
|
if (!Running_)
|
||||||
break;
|
break;
|
||||||
Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE);
|
Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE));
|
||||||
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
|
||||||
Msg, false);
|
Msg, false);
|
||||||
}
|
}
|
||||||
Msg = MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE);
|
Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE));
|
||||||
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
|
||||||
false);
|
false);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
#include "fmt/format.h"
|
#include "fmt/format.h"
|
||||||
#include "framework/MicroServiceFuncs.h"
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
#include "cppkafka/utils/consumer_dispatcher.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -99,9 +100,12 @@ namespace OpenWifi {
|
|||||||
try {
|
try {
|
||||||
auto Msg = dynamic_cast<KafkaMessage *>(Note.get());
|
auto Msg = dynamic_cast<KafkaMessage *>(Note.get());
|
||||||
if (Msg != nullptr) {
|
if (Msg != nullptr) {
|
||||||
Producer.produce(cppkafka::MessageBuilder(Msg->Topic())
|
auto NewMessage = cppkafka::MessageBuilder(Msg->Topic());
|
||||||
.key(Msg->Key())
|
NewMessage.key(Msg->Key());
|
||||||
.payload(Msg->Payload()));
|
NewMessage.partition(0);
|
||||||
|
NewMessage.payload(Msg->Payload());
|
||||||
|
Producer.produce(NewMessage);
|
||||||
|
Producer.flush();
|
||||||
}
|
}
|
||||||
} catch (const cppkafka::HandleException &E) {
|
} catch (const cppkafka::HandleException &E) {
|
||||||
poco_warning(Logger_,
|
poco_warning(Logger_,
|
||||||
@@ -156,43 +160,49 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
bool AutoCommit = MicroServiceConfigGetBool("openwifi.kafka.auto.commit", false);
|
// bool AutoCommit = MicroServiceConfigGetBool("openwifi.kafka.auto.commit", false);
|
||||||
auto BatchSize = MicroServiceConfigGetInt("openwifi.kafka.consumer.batchsize", 20);
|
// auto BatchSize = MicroServiceConfigGetInt("openwifi.kafka.consumer.batchsize", 100);
|
||||||
|
|
||||||
Types::StringVec Topics;
|
Types::StringVec Topics;
|
||||||
KafkaManager()->Topics(Topics);
|
std::for_each(Topics_.begin(),Topics_.end(),
|
||||||
|
[&](const std::string & T) { Topics.emplace_back(T); });
|
||||||
Consumer.subscribe(Topics);
|
Consumer.subscribe(Topics);
|
||||||
|
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
while (Running_) {
|
std::vector<cppkafka::Message> MsgVec;
|
||||||
try {
|
|
||||||
std::vector<cppkafka::Message> MsgVec =
|
Dispatcher_ = std::make_unique<cppkafka::ConsumerDispatcher>(Consumer);
|
||||||
Consumer.poll_batch(BatchSize, std::chrono::milliseconds(100));
|
|
||||||
for (auto const &Msg : MsgVec) {
|
Dispatcher_->run(
|
||||||
if (!Msg)
|
// Callback executed whenever a new message is consumed
|
||||||
continue;
|
[&](cppkafka::Message msg) {
|
||||||
if (Msg.get_error()) {
|
// Print the key (if any)
|
||||||
if (!Msg.is_eof()) {
|
std::lock_guard G(ConsumerMutex_);
|
||||||
poco_error(Logger_,
|
auto It = Notifiers_.find(msg.get_topic());
|
||||||
fmt::format("Error: {}", Msg.get_error().to_string()));
|
if (It != Notifiers_.end()) {
|
||||||
|
const auto &FL = It->second;
|
||||||
|
for (const auto &[CallbackFunc, _] : FL) {
|
||||||
|
try {
|
||||||
|
CallbackFunc(msg.get_key(), msg.get_payload());
|
||||||
|
} catch(const Poco::Exception &E) {
|
||||||
|
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
}
|
}
|
||||||
if (!AutoCommit)
|
|
||||||
Consumer.async_commit(Msg);
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
KafkaManager()->Dispatch(Msg.get_topic(), Msg.get_key(), Msg.get_payload());
|
|
||||||
if (!AutoCommit)
|
|
||||||
Consumer.async_commit(Msg);
|
|
||||||
}
|
}
|
||||||
} catch (const cppkafka::HandleException &E) {
|
Consumer.commit(msg);
|
||||||
poco_warning(Logger_,
|
},
|
||||||
fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
|
// Whenever there's an error (other than the EOF soft error)
|
||||||
} catch (const Poco::Exception &E) {
|
[&Logger_](cppkafka::Error error) {
|
||||||
Logger_.log(E);
|
poco_warning(Logger_,fmt::format("Error: {}", error.to_string()));
|
||||||
} catch (...) {
|
},
|
||||||
poco_error(Logger_, "std::exception");
|
// Whenever EOF is reached on a partition, print this
|
||||||
|
[&Logger_](cppkafka::ConsumerDispatcher::EndOfFile, const cppkafka::TopicPartition& topic_partition) {
|
||||||
|
poco_debug(Logger_,fmt::format("Partition {} EOF", topic_partition.get_partition()));
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
|
|
||||||
Consumer.unsubscribe();
|
Consumer.unsubscribe();
|
||||||
poco_information(Logger_, "Stopped...");
|
poco_information(Logger_, "Stopped...");
|
||||||
}
|
}
|
||||||
@@ -212,7 +222,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaProducer::Produce(const std::string &Topic, const std::string &Key,
|
void KafkaProducer::Produce(const char *Topic, const std::string &Key,
|
||||||
const std::string &Payload) {
|
const std::string &Payload) {
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(Mutex_);
|
||||||
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
||||||
@@ -220,7 +230,6 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void KafkaConsumer::Start() {
|
void KafkaConsumer::Start() {
|
||||||
if (!Running_) {
|
if (!Running_) {
|
||||||
Running_ = true;
|
|
||||||
Worker_.start(*this);
|
Worker_.start(*this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,29 +237,16 @@ namespace OpenWifi {
|
|||||||
void KafkaConsumer::Stop() {
|
void KafkaConsumer::Stop() {
|
||||||
if (Running_) {
|
if (Running_) {
|
||||||
Running_ = false;
|
Running_ = false;
|
||||||
Worker_.wakeUp();
|
if(Dispatcher_) {
|
||||||
|
Dispatcher_->stop();
|
||||||
|
}
|
||||||
Worker_.join();
|
Worker_.join();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaDispatcher::Start() {
|
std::uint64_t KafkaConsumer::RegisterTopicWatcher(const std::string &Topic,
|
||||||
if (!Running_) {
|
|
||||||
Running_ = true;
|
|
||||||
Worker_.start(*this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KafkaDispatcher::Stop() {
|
|
||||||
if (Running_) {
|
|
||||||
Running_ = false;
|
|
||||||
Queue_.wakeUpAll();
|
|
||||||
Worker_.join();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto KafkaDispatcher::RegisterTopicWatcher(const std::string &Topic,
|
|
||||||
Types::TopicNotifyFunction &F) {
|
Types::TopicNotifyFunction &F) {
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(ConsumerMutex_);
|
||||||
auto It = Notifiers_.find(Topic);
|
auto It = Notifiers_.find(Topic);
|
||||||
if (It == Notifiers_.end()) {
|
if (It == Notifiers_.end()) {
|
||||||
Types::TopicNotifyFunctionList L;
|
Types::TopicNotifyFunctionList L;
|
||||||
@@ -259,11 +255,12 @@ namespace OpenWifi {
|
|||||||
} else {
|
} else {
|
||||||
It->second.emplace(It->second.end(), std::make_pair(F, FunctionId_));
|
It->second.emplace(It->second.end(), std::make_pair(F, FunctionId_));
|
||||||
}
|
}
|
||||||
|
Topics_.insert(Topic);
|
||||||
return FunctionId_++;
|
return FunctionId_++;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaDispatcher::UnregisterTopicWatcher(const std::string &Topic, int Id) {
|
void KafkaConsumer::UnregisterTopicWatcher(const std::string &Topic, int Id) {
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(ConsumerMutex_);
|
||||||
auto It = Notifiers_.find(Topic);
|
auto It = Notifiers_.find(Topic);
|
||||||
if (It != Notifiers_.end()) {
|
if (It != Notifiers_.end()) {
|
||||||
Types::TopicNotifyFunctionList &L = It->second;
|
Types::TopicNotifyFunctionList &L = It->second;
|
||||||
@@ -275,56 +272,17 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaDispatcher::Dispatch(const std::string &Topic, const std::string &Key,
|
|
||||||
const std::string &Payload) {
|
|
||||||
std::lock_guard G(Mutex_);
|
|
||||||
auto It = Notifiers_.find(Topic);
|
|
||||||
if (It != Notifiers_.end()) {
|
|
||||||
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void KafkaDispatcher::run() {
|
|
||||||
Poco::Logger &Logger_ =
|
|
||||||
Poco::Logger::create("KAFKA-DISPATCHER", KafkaManager()->Logger().getChannel());
|
|
||||||
poco_information(Logger_, "Starting...");
|
|
||||||
Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
|
|
||||||
Utils::SetThreadName("kafka:dispatch");
|
|
||||||
while (Note && Running_) {
|
|
||||||
auto Msg = dynamic_cast<KafkaMessage *>(Note.get());
|
|
||||||
if (Msg != nullptr) {
|
|
||||||
auto It = Notifiers_.find(Msg->Topic());
|
|
||||||
if (It != Notifiers_.end()) {
|
|
||||||
const auto &FL = It->second;
|
|
||||||
for (const auto &[CallbackFunc, _] : FL) {
|
|
||||||
CallbackFunc(Msg->Key(), Msg->Payload());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Note = Queue_.waitDequeueNotification();
|
|
||||||
}
|
|
||||||
poco_information(Logger_, "Stopped...");
|
|
||||||
}
|
|
||||||
|
|
||||||
void KafkaDispatcher::Topics(std::vector<std::string> &T) {
|
|
||||||
T.clear();
|
|
||||||
for (const auto &[TopicName, _] : Notifiers_)
|
|
||||||
T.push_back(TopicName);
|
|
||||||
}
|
|
||||||
|
|
||||||
int KafkaManager::Start() {
|
int KafkaManager::Start() {
|
||||||
if (!KafkaEnabled_)
|
if (!KafkaEnabled_)
|
||||||
return 0;
|
return 0;
|
||||||
ConsumerThr_.Start();
|
ConsumerThr_.Start();
|
||||||
ProducerThr_.Start();
|
ProducerThr_.Start();
|
||||||
Dispatcher_.Start();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaManager::Stop() {
|
void KafkaManager::Stop() {
|
||||||
if (KafkaEnabled_) {
|
if (KafkaEnabled_) {
|
||||||
poco_information(Logger(), "Stopping...");
|
poco_information(Logger(), "Stopping...");
|
||||||
Dispatcher_.Stop();
|
|
||||||
ProducerThr_.Stop();
|
ProducerThr_.Stop();
|
||||||
ConsumerThr_.Stop();
|
ConsumerThr_.Stop();
|
||||||
poco_information(Logger(), "Stopped...");
|
poco_information(Logger(), "Stopped...");
|
||||||
@@ -332,39 +290,29 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaManager::PostMessage(const std::string &topic, const std::string &key,
|
void KafkaManager::PostMessage(const char *topic, const std::string &key,
|
||||||
const std::string &PayLoad, bool WrapMessage) {
|
const std::string & PayLoad, bool WrapMessage) {
|
||||||
if (KafkaEnabled_) {
|
if (KafkaEnabled_) {
|
||||||
ProducerThr_.Produce(topic, key, WrapMessage ? WrapSystemId(PayLoad) : PayLoad);
|
ProducerThr_.Produce(topic, key, WrapMessage ? WrapSystemId(PayLoad) : PayLoad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaManager::Dispatch(const std::string &Topic, const std::string &Key,
|
void KafkaManager::PostMessage(const char *topic, const std::string &key,
|
||||||
const std::string &Payload) {
|
const Poco::JSON::Object &Object, bool WrapMessage) {
|
||||||
Dispatcher_.Dispatch(Topic, Key, Payload);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string KafkaManager::WrapSystemId(const std::string &PayLoad) {
|
|
||||||
return SystemInfoWrapper_ + PayLoad + "}";
|
|
||||||
}
|
|
||||||
|
|
||||||
uint64_t KafkaManager::RegisterTopicWatcher(const std::string &Topic,
|
|
||||||
Types::TopicNotifyFunction &F) {
|
|
||||||
if (KafkaEnabled_) {
|
if (KafkaEnabled_) {
|
||||||
return Dispatcher_.RegisterTopicWatcher(Topic, F);
|
std::ostringstream ObjectStr;
|
||||||
} else {
|
Object.stringify(ObjectStr);
|
||||||
return 0;
|
ProducerThr_.Produce(topic, key, WrapMessage ? WrapSystemId(ObjectStr.str()) : ObjectStr.str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaManager::UnregisterTopicWatcher(const std::string &Topic, uint64_t Id) {
|
[[nodiscard]] std::string KafkaManager::WrapSystemId(const std::string & PayLoad) {
|
||||||
if (KafkaEnabled_) {
|
return fmt::format( R"lit({{ "system" : {{ "id" : {},
|
||||||
Dispatcher_.UnregisterTopicWatcher(Topic, Id);
|
"host" : "{}" }},
|
||||||
}
|
"payload" : {} }})lit", MicroServiceID(),
|
||||||
|
MicroServicePrivateEndPoint(), PayLoad ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void KafkaManager::Topics(std::vector<std::string> &T) { Dispatcher_.Topics(T); }
|
|
||||||
|
|
||||||
void KafkaManager::PartitionAssignment(const cppkafka::TopicPartitionList &partitions) {
|
void KafkaManager::PartitionAssignment(const cppkafka::TopicPartitionList &partitions) {
|
||||||
poco_information(
|
poco_information(
|
||||||
Logger(), fmt::format("Partition assigned: {}...", partitions.front().get_partition()));
|
Logger(), fmt::format("Partition assigned: {}...", partitions.front().get_partition()));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "Poco/Notification.h"
|
#include "Poco/Notification.h"
|
||||||
#include "Poco/NotificationQueue.h"
|
#include "Poco/NotificationQueue.h"
|
||||||
|
#include "Poco/JSON/Object.h"
|
||||||
#include "framework/KafkaTopics.h"
|
#include "framework/KafkaTopics.h"
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "framework/SubSystemServer.h"
|
#include "framework/SubSystemServer.h"
|
||||||
@@ -18,15 +18,15 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class KafkaMessage : public Poco::Notification {
|
class KafkaMessage : public Poco::Notification {
|
||||||
public:
|
public:
|
||||||
KafkaMessage(const std::string &Topic, const std::string &Key, const std::string &Payload)
|
KafkaMessage(const char * Topic, const std::string &Key, const std::string &Payload)
|
||||||
: Topic_(Topic), Key_(Key), Payload_(Payload) {}
|
: Topic_(Topic), Key_(Key), Payload_(Payload) {}
|
||||||
|
|
||||||
inline const std::string &Topic() { return Topic_; }
|
inline const char * Topic() { return Topic_; }
|
||||||
inline const std::string &Key() { return Key_; }
|
inline const std::string &Key() { return Key_; }
|
||||||
inline const std::string &Payload() { return Payload_; }
|
inline const std::string &Payload() { return Payload_; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string Topic_;
|
const char *Topic_;
|
||||||
std::string Key_;
|
std::string Key_;
|
||||||
std::string Payload_;
|
std::string Payload_;
|
||||||
};
|
};
|
||||||
@@ -36,10 +36,10 @@ namespace OpenWifi {
|
|||||||
void run() override;
|
void run() override;
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void Produce(const std::string &Topic, const std::string &Key, const std::string &Payload);
|
void Produce(const char *Topic, const std::string &Key, const std::string & Payload);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex Mutex_;
|
std::mutex Mutex_;
|
||||||
Poco::Thread Worker_;
|
Poco::Thread Worker_;
|
||||||
mutable std::atomic_bool Running_ = false;
|
mutable std::atomic_bool Running_ = false;
|
||||||
Poco::NotificationQueue Queue_;
|
Poco::NotificationQueue Queue_;
|
||||||
@@ -47,33 +47,22 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class KafkaConsumer : public Poco::Runnable {
|
class KafkaConsumer : public Poco::Runnable {
|
||||||
public:
|
public:
|
||||||
void run() override;
|
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex Mutex_;
|
std::mutex ConsumerMutex_;
|
||||||
Poco::Thread Worker_;
|
Types::NotifyTable Notifiers_;
|
||||||
|
Poco::Thread Worker_;
|
||||||
mutable std::atomic_bool Running_ = false;
|
mutable std::atomic_bool Running_ = false;
|
||||||
};
|
uint64_t FunctionId_ = 1;
|
||||||
|
std::unique_ptr<cppkafka::ConsumerDispatcher> Dispatcher_;
|
||||||
|
std::set<std::string> Topics_;
|
||||||
|
|
||||||
class KafkaDispatcher : public Poco::Runnable {
|
void run() override;
|
||||||
public:
|
friend class KafkaManager;
|
||||||
void Start();
|
std::uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
||||||
void Stop();
|
|
||||||
auto RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
|
||||||
void UnregisterTopicWatcher(const std::string &Topic, int Id);
|
void UnregisterTopicWatcher(const std::string &Topic, int Id);
|
||||||
void Dispatch(const std::string &Topic, const std::string &Key, const std::string &Payload);
|
|
||||||
void run() override;
|
|
||||||
void Topics(std::vector<std::string> &T);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::recursive_mutex Mutex_;
|
|
||||||
Types::NotifyTable Notifiers_;
|
|
||||||
Poco::Thread Worker_;
|
|
||||||
mutable std::atomic_bool Running_ = false;
|
|
||||||
uint64_t FunctionId_ = 1;
|
|
||||||
Poco::NotificationQueue Queue_;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class KafkaManager : public SubSystemServer {
|
class KafkaManager : public SubSystemServer {
|
||||||
@@ -91,21 +80,25 @@ namespace OpenWifi {
|
|||||||
int Start() override;
|
int Start() override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
void PostMessage(const std::string &topic, const std::string &key,
|
void PostMessage(const char *topic, const std::string &key,
|
||||||
const std::string &PayLoad, bool WrapMessage = true);
|
const std::string &PayLoad, bool WrapMessage = true);
|
||||||
void Dispatch(const std::string &Topic, const std::string &Key, const std::string &Payload);
|
void PostMessage(const char *topic, const std::string &key,
|
||||||
[[nodiscard]] std::string WrapSystemId(const std::string &PayLoad);
|
const Poco::JSON::Object &Object, bool WrapMessage = true);
|
||||||
|
|
||||||
|
[[nodiscard]] std::string WrapSystemId(const std::string & PayLoad);
|
||||||
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
||||||
uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
inline std::uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F) {
|
||||||
void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id);
|
return ConsumerThr_.RegisterTopicWatcher(Topic,F);
|
||||||
void Topics(std::vector<std::string> &T);
|
}
|
||||||
|
inline void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id) {
|
||||||
|
return ConsumerThr_.UnregisterTopicWatcher(Topic,Id);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool KafkaEnabled_ = false;
|
bool KafkaEnabled_ = false;
|
||||||
std::string SystemInfoWrapper_;
|
std::string SystemInfoWrapper_;
|
||||||
KafkaProducer ProducerThr_;
|
KafkaProducer ProducerThr_;
|
||||||
KafkaConsumer ConsumerThr_;
|
KafkaConsumer ConsumerThr_;
|
||||||
KafkaDispatcher Dispatcher_;
|
|
||||||
|
|
||||||
void PartitionAssignment(const cppkafka::TopicPartitionList &partitions);
|
void PartitionAssignment(const cppkafka::TopicPartitionList &partitions);
|
||||||
void PartitionRevocation(const cppkafka::TopicPartitionList &partitions);
|
void PartitionRevocation(const cppkafka::TopicPartitionList &partitions);
|
||||||
|
|||||||
@@ -10,32 +10,32 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
namespace OpenWifi::KafkaTopics {
|
namespace OpenWifi::KafkaTopics {
|
||||||
static const std::string HEALTHCHECK{"healthcheck"};
|
inline const char * HEALTHCHECK = "healthcheck";
|
||||||
static const std::string STATE{"state"};
|
inline const char * STATE = "state";
|
||||||
static const std::string CONNECTION{"connection"};
|
inline const char * CONNECTION = "connection";
|
||||||
static const std::string WIFISCAN{"wifiscan"};
|
inline const char * WIFISCAN = "wifiscan";
|
||||||
static const std::string ALERTS{"alerts"};
|
inline const char * ALERTS = "alerts";
|
||||||
static const std::string COMMAND{"command"};
|
inline const char * COMMAND = "command";
|
||||||
static const std::string SERVICE_EVENTS{"service_events"};
|
inline const char * SERVICE_EVENTS = "service_events";
|
||||||
static const std::string DEVICE_EVENT_QUEUE{"device_event_queue"};
|
inline const char * DEVICE_EVENT_QUEUE = "device_event_queue";
|
||||||
static const std::string DEVICE_TELEMETRY{"device_telemetry"};
|
inline const char * DEVICE_TELEMETRY = "device_telemetry";
|
||||||
static const std::string PROVISIONING_CHANGE{"provisioning_change"};
|
inline const char * PROVISIONING_CHANGE = "provisioning_change";
|
||||||
|
|
||||||
namespace ServiceEvents {
|
namespace ServiceEvents {
|
||||||
static const std::string EVENT_JOIN{"join"};
|
inline const char * EVENT_JOIN = "join";
|
||||||
static const std::string EVENT_LEAVE{"leave"};
|
inline const char * EVENT_LEAVE = "leave";
|
||||||
static const std::string EVENT_KEEP_ALIVE{"keep-alive"};
|
inline const char * EVENT_KEEP_ALIVE = "keep-alive";
|
||||||
static const std::string EVENT_REMOVE_TOKEN{"remove-token"};
|
inline const char * EVENT_REMOVE_TOKEN = "remove-token";
|
||||||
|
|
||||||
namespace Fields {
|
namespace Fields {
|
||||||
static const std::string EVENT{"event"};
|
inline const char * EVENT = "event";
|
||||||
static const std::string ID{"id"};
|
inline const char * ID = "id";
|
||||||
static const std::string TYPE{"type"};
|
inline const char * TYPE = "type";
|
||||||
static const std::string PUBLIC{"publicEndPoint"};
|
inline const char * PUBLIC = "publicEndPoint";
|
||||||
static const std::string PRIVATE{"privateEndPoint"};
|
inline const char * PRIVATE = "privateEndPoint";
|
||||||
static const std::string KEY{"key"};
|
inline const char * KEY = "key";
|
||||||
static const std::string VRSN{"version"};
|
inline const char * VRSN = "version";
|
||||||
static const std::string TOKEN{"token"};
|
inline const char * TOKEN = "token";
|
||||||
} // namespace Fields
|
} // namespace Fields
|
||||||
} // namespace ServiceEvents
|
} // namespace ServiceEvents
|
||||||
} // namespace OpenWifi::KafkaTopics
|
} // namespace OpenWifi::KafkaTopics
|
||||||
|
|||||||
@@ -129,6 +129,8 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
poco_error(logger(), "Bad bus message.");
|
poco_error(logger(), "Bad bus message.");
|
||||||
|
std::ostringstream os;
|
||||||
|
Object->stringify(std::cout);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto i = Services_.begin();
|
auto i = Services_.begin();
|
||||||
|
|||||||
@@ -5,6 +5,8 @@
|
|||||||
#include "framework/MicroServiceFuncs.h"
|
#include "framework/MicroServiceFuncs.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/MicroService.h"
|
||||||
|
|
||||||
|
#include "framework/ALBserver.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
|
const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
|
||||||
|
|
||||||
@@ -47,11 +49,11 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void MicroServiceReload(const std::string &Type) { MicroService::instance().Reload(Type); }
|
void MicroServiceReload(const std::string &Type) { MicroService::instance().Reload(Type); }
|
||||||
|
|
||||||
const Types::StringVec MicroServiceGetLogLevelNames() {
|
Types::StringVec MicroServiceGetLogLevelNames() {
|
||||||
return MicroService::instance().GetLogLevelNames();
|
return MicroService::instance().GetLogLevelNames();
|
||||||
}
|
}
|
||||||
|
|
||||||
const Types::StringVec MicroServiceGetSubSystems() {
|
Types::StringVec MicroServiceGetSubSystems() {
|
||||||
return MicroService::instance().GetSubSystems();
|
return MicroService::instance().GetSubSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +81,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::string MicroServiceGetUIURI() { return MicroService::instance().GetUIURI(); }
|
std::string MicroServiceGetUIURI() { return MicroService::instance().GetUIURI(); }
|
||||||
|
|
||||||
const SubSystemVec MicroServiceGetFullSubSystems() {
|
SubSystemVec MicroServiceGetFullSubSystems() {
|
||||||
return MicroService::instance().GetFullSubSystems();
|
return MicroService::instance().GetFullSubSystems();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,7 +89,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::uint64_t MicroServiceDaemonBusTimer() { return MicroService::instance().DaemonBusTimer(); }
|
std::uint64_t MicroServiceDaemonBusTimer() { return MicroService::instance().DaemonBusTimer(); }
|
||||||
|
|
||||||
std::string MicroServiceMakeSystemEventMessage(const std::string &Type) {
|
std::string MicroServiceMakeSystemEventMessage(const char *Type) {
|
||||||
return MicroService::instance().MakeSystemEventMessage(Type);
|
return MicroService::instance().MakeSystemEventMessage(Type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,4 +125,8 @@ namespace OpenWifi {
|
|||||||
return MicroService::instance().AllowExternalMicroServices();
|
return MicroService::instance().AllowExternalMicroServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MicroServiceALBCallback( std::string Callback()) {
|
||||||
|
return ALBHealthCheckServer()->RegisterExtendedHealthMessage(Callback);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|||||||
@@ -31,8 +31,8 @@ namespace OpenWifi {
|
|||||||
void MicroServiceLoadConfigurationFile();
|
void MicroServiceLoadConfigurationFile();
|
||||||
void MicroServiceReload();
|
void MicroServiceReload();
|
||||||
void MicroServiceReload(const std::string &Type);
|
void MicroServiceReload(const std::string &Type);
|
||||||
const Types::StringVec MicroServiceGetLogLevelNames();
|
Types::StringVec MicroServiceGetLogLevelNames();
|
||||||
const Types::StringVec MicroServiceGetSubSystems();
|
Types::StringVec MicroServiceGetSubSystems();
|
||||||
Types::StringPairVec MicroServiceGetLogLevels();
|
Types::StringPairVec MicroServiceGetLogLevels();
|
||||||
bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level);
|
bool MicroServiceSetSubsystemLogLevel(const std::string &SubSystem, const std::string &Level);
|
||||||
void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer);
|
void MicroServiceGetExtraConfiguration(Poco::JSON::Object &Answer);
|
||||||
@@ -40,10 +40,10 @@ namespace OpenWifi {
|
|||||||
std::uint64_t MicroServiceUptimeTotalSeconds();
|
std::uint64_t MicroServiceUptimeTotalSeconds();
|
||||||
std::uint64_t MicroServiceStartTimeEpochTime();
|
std::uint64_t MicroServiceStartTimeEpochTime();
|
||||||
std::string MicroServiceGetUIURI();
|
std::string MicroServiceGetUIURI();
|
||||||
const SubSystemVec MicroServiceGetFullSubSystems();
|
SubSystemVec MicroServiceGetFullSubSystems();
|
||||||
std::string MicroServiceCreateUUID();
|
std::string MicroServiceCreateUUID();
|
||||||
std::uint64_t MicroServiceDaemonBusTimer();
|
std::uint64_t MicroServiceDaemonBusTimer();
|
||||||
std::string MicroServiceMakeSystemEventMessage(const std::string &Type);
|
std::string MicroServiceMakeSystemEventMessage(const char *Type);
|
||||||
Poco::ThreadPool &MicroServiceTimerPool();
|
Poco::ThreadPool &MicroServiceTimerPool();
|
||||||
std::string MicroServiceConfigPath(const std::string &Key, const std::string &DefaultValue);
|
std::string MicroServiceConfigPath(const std::string &Key, const std::string &DefaultValue);
|
||||||
std::string MicroServiceWWWAssetsDir();
|
std::string MicroServiceWWWAssetsDir();
|
||||||
@@ -53,4 +53,5 @@ namespace OpenWifi {
|
|||||||
std::string MicroServiceGetPublicAPIEndPoint();
|
std::string MicroServiceGetPublicAPIEndPoint();
|
||||||
void MicroServiceDeleteOverrideConfiguration();
|
void MicroServiceDeleteOverrideConfiguration();
|
||||||
bool AllowExternalMicroServices();
|
bool AllowExternalMicroServices();
|
||||||
|
void MicroServiceALBCallback( std::string Callback());
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|||||||
@@ -28,6 +28,9 @@ namespace OpenWifi::Types {
|
|||||||
typedef std::string UUID_t;
|
typedef std::string UUID_t;
|
||||||
typedef std::vector<UUID_t> UUIDvec_t;
|
typedef std::vector<UUID_t> UUIDvec_t;
|
||||||
typedef std::map<std::string, std::map<uint32_t, uint64_t>> Counted3DMapSII;
|
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 {
|
struct MicroServiceMeta {
|
||||||
uint64_t Id = 0;
|
uint64_t Id = 0;
|
||||||
|
|||||||
@@ -483,6 +483,7 @@ namespace OpenWifi {
|
|||||||
Response->set("Content-Transfer-Encoding", "binary");
|
Response->set("Content-Transfer-Encoding", "binary");
|
||||||
Response->set("Accept-Ranges", "bytes");
|
Response->set("Accept-Ranges", "bytes");
|
||||||
}
|
}
|
||||||
|
Response->set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
Response->set("Content-Disposition", "attachment; filename=" + Name);
|
Response->set("Content-Disposition", "attachment; filename=" + Name);
|
||||||
Response->set("Accept-Ranges", "bytes");
|
Response->set("Accept-Ranges", "bytes");
|
||||||
Response->set("Cache-Control", "no-store");
|
Response->set("Cache-Control", "no-store");
|
||||||
@@ -491,7 +492,7 @@ namespace OpenWifi {
|
|||||||
Response->sendFile(TempAvatar.path(), MT.ContentType);
|
Response->sendFile(TempAvatar.path(), MT.ContentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void SendFileContent(const std::string &Content, const std::string &Type,
|
inline void SendFileContent(const std::string &Content, [[maybe_unused]] const std::string &Type,
|
||||||
const std::string &Name) {
|
const std::string &Name) {
|
||||||
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
|
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
|
||||||
SetCommonHeaders();
|
SetCommonHeaders();
|
||||||
@@ -500,12 +501,13 @@ namespace OpenWifi {
|
|||||||
Response->set("Content-Transfer-Encoding", "binary");
|
Response->set("Content-Transfer-Encoding", "binary");
|
||||||
Response->set("Accept-Ranges", "bytes");
|
Response->set("Accept-Ranges", "bytes");
|
||||||
}
|
}
|
||||||
|
Response->set("Access-Control-Expose-Headers", "Content-Disposition");
|
||||||
Response->set("Content-Disposition", "attachment; filename=" + Name);
|
Response->set("Content-Disposition", "attachment; filename=" + Name);
|
||||||
Response->set("Accept-Ranges", "bytes");
|
Response->set("Accept-Ranges", "bytes");
|
||||||
Response->set("Cache-Control", "no-store");
|
Response->set("Cache-Control", "no-store");
|
||||||
Response->set("Expires", "Mon, 26 Jul 2027 05:00:00 GMT");
|
Response->set("Expires", "Mon, 26 Jul 2027 05:00:00 GMT");
|
||||||
Response->setContentLength(Content.size());
|
Response->setContentLength(Content.size());
|
||||||
Response->setContentType(Type);
|
Response->setContentType(MT.ContentType);
|
||||||
auto &OutputStream = Response->send();
|
auto &OutputStream = Response->send();
|
||||||
OutputStream << Content;
|
OutputStream << Content;
|
||||||
}
|
}
|
||||||
@@ -572,7 +574,37 @@ namespace OpenWifi {
|
|||||||
Poco::JSON::Stringifier::stringify(Object, Answer);
|
Poco::JSON::Stringifier::stringify(Object, Answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void ReturnRawJSON(const std::string &json_doc) {
|
inline void ReturnObject(const std::vector<std::string> &Strings) {
|
||||||
|
Poco::JSON::Array Arr;
|
||||||
|
for(const auto &String:Strings) {
|
||||||
|
Arr.add(String);
|
||||||
|
}
|
||||||
|
std::ostringstream os;
|
||||||
|
Arr.stringify(os);
|
||||||
|
return ReturnRawJSON(os.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void ReturnObject(const std::vector<T> &Objects) {
|
||||||
|
Poco::JSON::Array Arr;
|
||||||
|
for(const auto &Object:Objects) {
|
||||||
|
Poco::JSON::Object O;
|
||||||
|
Object.to_json(O);
|
||||||
|
Arr.add(O);
|
||||||
|
}
|
||||||
|
std::ostringstream os;
|
||||||
|
Arr.stringify(os);
|
||||||
|
return ReturnRawJSON(os.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
template<class T> void ReturnObject(const T &Object) {
|
||||||
|
Poco::JSON::Object O;
|
||||||
|
Object.to_json(O);
|
||||||
|
std::ostringstream os;
|
||||||
|
O.stringify(os);
|
||||||
|
return ReturnRawJSON(os.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void ReturnRawJSON(const std::string &json_doc) {
|
||||||
PrepareResponse();
|
PrepareResponse();
|
||||||
if (Request != nullptr) {
|
if (Request != nullptr) {
|
||||||
// can we compress ???
|
// can we compress ???
|
||||||
|
|||||||
@@ -24,50 +24,63 @@ namespace OpenWifi {
|
|||||||
Server, TransactionId, Internal) {}
|
Server, TransactionId, Internal) {}
|
||||||
static auto PathName() { return std::list<std::string>{"/api/v1/system"}; }
|
static auto PathName() { return std::list<std::string>{"/api/v1/system"}; }
|
||||||
|
|
||||||
inline void DoGet() {
|
inline void DoGet() final {
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
if (HasParameter("command", Arg) && Arg == "info") {
|
if (HasParameter("command", Arg)) {
|
||||||
Poco::JSON::Object Answer;
|
if (Arg == "info") {
|
||||||
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
Poco::JSON::Object Answer;
|
||||||
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
||||||
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
||||||
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
||||||
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
||||||
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
||||||
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
||||||
|
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
||||||
|
|
||||||
Poco::JSON::Array Certificates;
|
Poco::JSON::Array Certificates;
|
||||||
auto SubSystems = MicroServiceGetFullSubSystems();
|
auto SubSystems = MicroServiceGetFullSubSystems();
|
||||||
std::set<std::string> CertNames;
|
std::set<std::string> CertNames;
|
||||||
|
|
||||||
for (const auto &i : SubSystems) {
|
for (const auto &i : SubSystems) {
|
||||||
auto Hosts = i->HostSize();
|
auto Hosts = i->HostSize();
|
||||||
for (uint64_t j = 0; j < Hosts; ++j) {
|
for (uint64_t j = 0; j < Hosts; ++j) {
|
||||||
auto CertFileName = i->Host(j).CertFile();
|
auto CertFileName = i->Host(j).CertFile();
|
||||||
if (!CertFileName.empty()) {
|
if (!CertFileName.empty()) {
|
||||||
Poco::File F1(CertFileName);
|
Poco::File F1(CertFileName);
|
||||||
if (F1.exists()) {
|
if (F1.exists()) {
|
||||||
auto InsertResult = CertNames.insert(CertFileName);
|
auto InsertResult = CertNames.insert(CertFileName);
|
||||||
if (InsertResult.second) {
|
if (InsertResult.second) {
|
||||||
Poco::JSON::Object Inner;
|
Poco::JSON::Object Inner;
|
||||||
Poco::Path F(CertFileName);
|
Poco::Path F(CertFileName);
|
||||||
Inner.set("filename", F.getFileName());
|
Inner.set("filename", F.getFileName());
|
||||||
Poco::Crypto::X509Certificate C(CertFileName);
|
Poco::Crypto::X509Certificate C(CertFileName);
|
||||||
auto ExpiresOn = C.expiresOn();
|
auto ExpiresOn = C.expiresOn();
|
||||||
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
||||||
Certificates.add(Inner);
|
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);
|
BadRequest(RESTAPI::Errors::InvalidCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,8 +14,15 @@
|
|||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "framework/utils.h"
|
#include "framework/utils.h"
|
||||||
|
|
||||||
|
#include <RESTObjects/RESTAPI_SecurityObjects.h>
|
||||||
|
|
||||||
namespace OpenWifi::RESTAPI_utils {
|
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,
|
inline void EmbedDocument(const std::string &ObjName, Poco::JSON::Object &Obj,
|
||||||
const std::string &ObjStr) {
|
const std::string &ObjStr) {
|
||||||
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
std::string D = ObjStr.empty() ? "{}" : ObjStr;
|
||||||
@@ -95,6 +102,20 @@ namespace OpenWifi::RESTAPI_utils {
|
|||||||
Obj.set(Field, A);
|
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) {
|
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::TagList &V) {
|
||||||
Poco::JSON::Array A;
|
Poco::JSON::Array A;
|
||||||
for (const auto &i : V)
|
for (const auto &i : V)
|
||||||
@@ -277,6 +298,28 @@ 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>
|
template <class T>
|
||||||
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
||||||
std::vector<T> &Value) {
|
std::vector<T> &Value) {
|
||||||
|
|||||||
@@ -22,9 +22,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class StorageClass : public SubSystemServer {
|
class StorageClass : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {}
|
|
||||||
|
|
||||||
int Start() override {
|
inline int Start() override {
|
||||||
std::lock_guard Guard(Mutex_);
|
std::lock_guard Guard(Mutex_);
|
||||||
|
|
||||||
Logger().notice("Starting.");
|
Logger().notice("Starting.");
|
||||||
@@ -40,17 +39,22 @@ namespace OpenWifi {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stop() override { Pool_->shutdown(); }
|
inline void Stop() override { Pool_->shutdown(); }
|
||||||
|
|
||||||
DBType Type() const { return dbType_; };
|
DBType Type() const { return dbType_; };
|
||||||
|
|
||||||
|
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline int Setup_SQLite();
|
inline int Setup_SQLite();
|
||||||
inline int Setup_MySQL();
|
inline int Setup_MySQL();
|
||||||
inline int Setup_PostgreSQL();
|
inline int Setup_PostgreSQL();
|
||||||
|
|
||||||
protected:
|
|
||||||
std::unique_ptr<Poco::Data::SessionPool> Pool_;
|
protected:
|
||||||
|
std::shared_ptr<Poco::Data::SessionPool> Pool_;
|
||||||
Poco::Data::SQLite::Connector SQLiteConn_;
|
Poco::Data::SQLite::Connector SQLiteConn_;
|
||||||
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
||||||
Poco::Data::MySQL::Connector MySQLConn_;
|
Poco::Data::MySQL::Connector MySQLConn_;
|
||||||
@@ -81,7 +85,7 @@ namespace OpenWifi {
|
|||||||
// Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
// Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
||||||
// (int)NumSessions,
|
// (int)NumSessions,
|
||||||
// (int)IdleTime));
|
// (int)IdleTime));
|
||||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
Pool_ = std::make_shared<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
||||||
(int)NumSessions, (int)IdleTime);
|
(int)NumSessions, (int)IdleTime);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -102,7 +106,7 @@ namespace OpenWifi {
|
|||||||
";compress=true;auto-reconnect=true";
|
";compress=true;auto-reconnect=true";
|
||||||
|
|
||||||
Poco::Data::MySQL::Connector::registerConnector();
|
Poco::Data::MySQL::Connector::registerConnector();
|
||||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
Pool_ = std::make_shared<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
||||||
NumSessions, IdleTime);
|
NumSessions, IdleTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -126,7 +130,7 @@ namespace OpenWifi {
|
|||||||
" connect_timeout=" + ConnectionTimeout;
|
" connect_timeout=" + ConnectionTimeout;
|
||||||
|
|
||||||
Poco::Data::PostgreSQL::Connector::registerConnector();
|
Poco::Data::PostgreSQL::Connector::registerConnector();
|
||||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
Pool_ = std::make_shared<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
||||||
NumSessions, IdleTime);
|
NumSessions, IdleTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ namespace OpenWifi {
|
|||||||
P.cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH";
|
P.cipherList = "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH";
|
||||||
P.dhUse2048Bits = true;
|
P.dhUse2048Bits = true;
|
||||||
P.caLocation = cas_;
|
P.caLocation = cas_;
|
||||||
|
// P.securityLevel =
|
||||||
|
|
||||||
auto Context = Poco::AutoPtr<Poco::Net::Context>(
|
auto Context = Poco::AutoPtr<Poco::Net::Context>(
|
||||||
new Poco::Net::Context(Poco::Net::Context::TLS_SERVER_USE, P));
|
new Poco::Net::Context(Poco::Net::Context::TLS_SERVER_USE, P));
|
||||||
@@ -53,7 +54,6 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
Context->useCertificate(Cert);
|
Context->useCertificate(Cert);
|
||||||
Context->addChainCertificate(Root);
|
Context->addChainCertificate(Root);
|
||||||
|
|
||||||
Context->addCertificateAuthority(Root);
|
Context->addCertificateAuthority(Root);
|
||||||
|
|
||||||
if (level_ == Poco::Net::Context::VERIFY_STRICT) {
|
if (level_ == Poco::Net::Context::VERIFY_STRICT) {
|
||||||
@@ -76,18 +76,18 @@ namespace OpenWifi {
|
|||||||
L.fatal(fmt::format("Wrong Certificate({}) for Key({})", cert_file_, key_file_));
|
L.fatal(fmt::format("Wrong Certificate({}) for Key({})", cert_file_, key_file_));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSL_CTX_set_verify(SSLCtx, SSL_VERIFY_PEER, nullptr);
|
SSL_CTX_set_verify(SSLCtx, level_==Poco::Net::Context::VERIFY_NONE ? SSL_VERIFY_NONE : SSL_VERIFY_PEER, nullptr);
|
||||||
|
|
||||||
if (level_ == Poco::Net::Context::VERIFY_STRICT) {
|
if (level_ == Poco::Net::Context::VERIFY_STRICT) {
|
||||||
SSL_CTX_set_client_CA_list(SSLCtx, SSL_load_client_CA_file(client_cas_.c_str()));
|
SSL_CTX_set_client_CA_list(SSLCtx, SSL_load_client_CA_file(client_cas_.c_str()));
|
||||||
|
SSL_CTX_enable_ct(SSLCtx, SSL_CT_VALIDATION_STRICT);
|
||||||
}
|
}
|
||||||
SSL_CTX_enable_ct(SSLCtx, SSL_CT_VALIDATION_STRICT);
|
|
||||||
SSL_CTX_dane_enable(SSLCtx);
|
SSL_CTX_dane_enable(SSLCtx);
|
||||||
|
|
||||||
Context->enableSessionCache();
|
Context->enableSessionCache();
|
||||||
Context->setSessionCacheSize(0);
|
Context->setSessionCacheSize(0);
|
||||||
Context->setSessionTimeout(60);
|
Context->setSessionTimeout(60);
|
||||||
Context->enableExtendedCertificateVerification(true);
|
Context->enableExtendedCertificateVerification( level_!= Poco::Net::Context::VERIFY_NONE );
|
||||||
Context->disableStatelessSessionResumption();
|
Context->disableStatelessSessionResumption();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
63
src/framework/default_device_types.h
Normal file
63
src/framework/default_device_types.h
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2023-04-19.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace OpenWifi {
|
||||||
|
inline const std::vector<std::pair<std::string, std::string>> DefaultDeviceTypeList{
|
||||||
|
{"actiontec_web7200", "AP"},
|
||||||
|
{"cig_wf186w", "AP"},
|
||||||
|
{"cig_wf188n", "AP"},
|
||||||
|
{"cig_wf194c4", "AP"},
|
||||||
|
{"cig_wf196", "AP"},
|
||||||
|
{"cig_wf196-ca", "AP"},
|
||||||
|
{"cig_wf196-ca-ath12", "AP"},
|
||||||
|
{"cig_wf196-us", "AP"},
|
||||||
|
{"cig_wf610d", "AP"},
|
||||||
|
{"cig_wf660a", "AP"},
|
||||||
|
{"cig_wf808", "AP"},
|
||||||
|
{"cybertan_eww622-a1", "AP"},
|
||||||
|
{"edgecore_eap101", "AP"},
|
||||||
|
{"edgecore_eap101-ath12", "AP"},
|
||||||
|
{"edgecore_eap102", "AP"},
|
||||||
|
{"edgecore_eap104", "AP"},
|
||||||
|
{"edgecore_eap104-ath12", "AP"},
|
||||||
|
{"edgecore_ecs4100-12ph", "AP"},
|
||||||
|
{"edgecore_ecw5211", "AP"},
|
||||||
|
{"edgecore_ecw5410", "AP"},
|
||||||
|
{"edgecore_oap100", "AP"},
|
||||||
|
{"edgecore_spw2ac1200", "SWITCH"},
|
||||||
|
{"edgecore_spw2ac1200-lan-poe", "SWITCH"},
|
||||||
|
{"edgecore_ssw2ac2600", "SWITCH"},
|
||||||
|
{"hfcl_ion4", "AP"},
|
||||||
|
{"hfcl_ion4x", "AP"},
|
||||||
|
{"hfcl_ion4x_2", "AP"},
|
||||||
|
{"hfcl_ion4xe", "AP"},
|
||||||
|
{"hfcl_ion4xi", "AP"},
|
||||||
|
{"indio_um-305ac", "AP"},
|
||||||
|
{"indio_um-305ax", "AP"},
|
||||||
|
{"indio_um-310ax-v1", "AP"},
|
||||||
|
{"indio_um-325ac", "AP"},
|
||||||
|
{"indio_um-510ac-v3", "AP"},
|
||||||
|
{"indio_um-510axm-v1", "AP"},
|
||||||
|
{"indio_um-510axp-v1", "AP"},
|
||||||
|
{"indio_um-550ac", "AP"},
|
||||||
|
{"linksys_e8450-ubi", "AP"},
|
||||||
|
{"linksys_ea6350-v4", "AP"},
|
||||||
|
{"linksys_ea8300", "AP"},
|
||||||
|
{"liteon_wpx8324", "AP"},
|
||||||
|
{"meshpp_s618_cp01", "AP"},
|
||||||
|
{"meshpp_s618_cp03", "AP"},
|
||||||
|
{"udaya_a5-id2", "AP"},
|
||||||
|
{"wallys_dr40x9", "AP"},
|
||||||
|
{"wallys_dr6018", "AP"},
|
||||||
|
{"wallys_dr6018_v4", "AP"},
|
||||||
|
{"x64_vm", "AP"},
|
||||||
|
{"yuncore_ax840", "AP"},
|
||||||
|
{"yuncore_fap640", "AP"},
|
||||||
|
{"yuncore_fap650", "AP"}};
|
||||||
|
}
|
||||||
@@ -40,6 +40,7 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define DBGLINE std::cout << __LINE__ << ":" << __FILE__ << ", " << __func__ << std::endl;
|
||||||
namespace OpenWifi::RESTAPI::Errors {
|
namespace OpenWifi::RESTAPI::Errors {
|
||||||
struct msg {
|
struct msg {
|
||||||
uint64_t err_num;
|
uint64_t err_num;
|
||||||
@@ -397,6 +398,35 @@ namespace OpenWifi::RESTAPI::Errors {
|
|||||||
static const struct msg FirmwareBDInProgress {
|
static const struct msg FirmwareBDInProgress {
|
||||||
1170, "Firmware DB update already in progress."
|
1170, "Firmware DB update already in progress."
|
||||||
};
|
};
|
||||||
|
static const struct msg SimulatedDeviceNotSupported {
|
||||||
|
1171, "Command not supported on simulated device."
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct msg VenuesNameAlreadyExists {
|
||||||
|
1172, "The venue name already exists."
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct msg InvalidGlobalReachAccount {
|
||||||
|
1173, "Invalid Global Reach account information."
|
||||||
|
};
|
||||||
|
static const struct msg CannotCreateCSR {
|
||||||
|
1174, "Cannot create a CSR certificate."
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct msg DefFirmwareNameExists { 1175, "Firmware name already exists." };
|
||||||
|
|
||||||
|
static const struct msg NotAValidECKey { 1176, "Not a valid Signing Key." };
|
||||||
|
|
||||||
|
static const struct msg NotAValidRadiusPoolType { 1177, "Not a valid RADIUS pool type." };
|
||||||
|
|
||||||
|
static const struct msg SimulationDoesNotExist {
|
||||||
|
7000, "Simulation Instance ID does not exist."
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct msg SimulationIsAlreadyRunning {
|
||||||
|
7001, "There is an instance of this simulation already running.."
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace OpenWifi::RESTAPI::Errors
|
} // namespace OpenWifi::RESTAPI::Errors
|
||||||
|
|
||||||
@@ -554,6 +584,7 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
static const char *HEALTHCHECK = "healthcheck";
|
static const char *HEALTHCHECK = "healthcheck";
|
||||||
static const char *LOG = "log";
|
static const char *LOG = "log";
|
||||||
static const char *CRASHLOG = "crashlog";
|
static const char *CRASHLOG = "crashlog";
|
||||||
|
static const char *REBOOTLOG = "rebootLog";
|
||||||
static const char *PING = "ping";
|
static const char *PING = "ping";
|
||||||
static const char *CFGPENDING = "cfgpending";
|
static const char *CFGPENDING = "cfgpending";
|
||||||
static const char *RECOVERY = "recovery";
|
static const char *RECOVERY = "recovery";
|
||||||
@@ -612,6 +643,8 @@ namespace OpenWifi::uCentralProtocol {
|
|||||||
static const char *DEVICEUPDATE = "deviceupdate";
|
static const char *DEVICEUPDATE = "deviceupdate";
|
||||||
static const char *FWSIGNATURE = "FWsignature";
|
static const char *FWSIGNATURE = "FWsignature";
|
||||||
static const char *SIGNATURE = "signature";
|
static const char *SIGNATURE = "signature";
|
||||||
|
static const char *INFO = "info";
|
||||||
|
static const char *DATE = "date";
|
||||||
|
|
||||||
static const char *SERIALNUMBER = "serialNumber";
|
static const char *SERIALNUMBER = "serialNumber";
|
||||||
static const char *COMPATIBLE = "compatible";
|
static const char *COMPATIBLE = "compatible";
|
||||||
@@ -642,6 +675,7 @@ namespace OpenWifi::uCentralProtocol::Events {
|
|||||||
static const char *HEALTHCHECK = "healthcheck";
|
static const char *HEALTHCHECK = "healthcheck";
|
||||||
static const char *LOG = "log";
|
static const char *LOG = "log";
|
||||||
static const char *CRASHLOG = "crashlog";
|
static const char *CRASHLOG = "crashlog";
|
||||||
|
static const char *REBOOTLOG = "rebootLog";
|
||||||
static const char *PING = "ping";
|
static const char *PING = "ping";
|
||||||
static const char *CFGPENDING = "cfgpending";
|
static const char *CFGPENDING = "cfgpending";
|
||||||
static const char *RECOVERY = "recovery";
|
static const char *RECOVERY = "recovery";
|
||||||
@@ -665,7 +699,8 @@ namespace OpenWifi::uCentralProtocol::Events {
|
|||||||
ET_VENUEBROADCAST,
|
ET_VENUEBROADCAST,
|
||||||
ET_EVENT,
|
ET_EVENT,
|
||||||
ET_WIFISCAN,
|
ET_WIFISCAN,
|
||||||
ET_ALARM
|
ET_ALARM,
|
||||||
|
ET_REBOOTLOG
|
||||||
};
|
};
|
||||||
|
|
||||||
inline EVENT_MSG EventFromString(const std::string &Method) {
|
inline EVENT_MSG EventFromString(const std::string &Method) {
|
||||||
@@ -696,8 +731,10 @@ namespace OpenWifi::uCentralProtocol::Events {
|
|||||||
else if (strcmp(WIFISCAN, Method.c_str()) == 0)
|
else if (strcmp(WIFISCAN, Method.c_str()) == 0)
|
||||||
return ET_WIFISCAN;
|
return ET_WIFISCAN;
|
||||||
else if (strcmp(ALARM, Method.c_str()) == 0)
|
else if (strcmp(ALARM, Method.c_str()) == 0)
|
||||||
return ET_WIFISCAN;
|
return ET_ALARM;
|
||||||
return ET_ALARM;
|
else if (strcmp(REBOOTLOG, Method.c_str()) == 0)
|
||||||
|
return ET_REBOOTLOG;
|
||||||
|
return ET_UNKNOWN;
|
||||||
};
|
};
|
||||||
} // namespace OpenWifi::uCentralProtocol::Events
|
} // namespace OpenWifi::uCentralProtocol::Events
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,17 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
|
#include "Poco/TemporaryFile.h"
|
||||||
|
#include "Poco/Crypto/ECKey.h"
|
||||||
#include "framework/AppServiceRegistry.h"
|
#include "framework/AppServiceRegistry.h"
|
||||||
#include "framework/utils.h"
|
#include "framework/utils.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <ctime>
|
||||||
|
#include <string>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
namespace OpenWifi::Utils {
|
namespace OpenWifi::Utils {
|
||||||
|
|
||||||
bool NormalizeMac(std::string &Mac) {
|
bool NormalizeMac(std::string &Mac) {
|
||||||
@@ -27,6 +34,10 @@ namespace OpenWifi::Utils {
|
|||||||
std::all_of(Serial.begin(), Serial.end(), [](auto i) { return std::isxdigit(i); }));
|
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) {
|
[[nodiscard]] bool ValidUUID(const std::string &UUID) {
|
||||||
if (UUID.size() > 36)
|
if (UUID.size() > 36)
|
||||||
return false;
|
return false;
|
||||||
@@ -128,6 +139,15 @@ namespace OpenWifi::Utils {
|
|||||||
return std::regex_match(Hostname, HostNameRegex);
|
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) {
|
[[nodiscard]] std::string ToHex(const std::vector<unsigned char> &B) {
|
||||||
std::string R;
|
std::string R;
|
||||||
R.reserve(B.size() * 2);
|
R.reserve(B.size() * 2);
|
||||||
@@ -437,6 +457,15 @@ namespace OpenWifi::Utils {
|
|||||||
return MediaTypeEncoding{.Encoding = PLAIN, .ContentType = "text/css"};
|
return MediaTypeEncoding{.Encoding = PLAIN, .ContentType = "text/css"};
|
||||||
if (E == "js")
|
if (E == "js")
|
||||||
return MediaTypeEncoding{.Encoding = PLAIN, .ContentType = "application/javascript"};
|
return MediaTypeEncoding{.Encoding = PLAIN, .ContentType = "application/javascript"};
|
||||||
|
if (E == "pcap")
|
||||||
|
return MediaTypeEncoding{.Encoding = BINARY, .ContentType = "application/vnd.tcpdump.pcap"};
|
||||||
|
if (E == "txt")
|
||||||
|
return MediaTypeEncoding{.Encoding = PLAIN, .ContentType = "text/plain"};
|
||||||
|
if (E == "tgz")
|
||||||
|
return MediaTypeEncoding{.Encoding = BINARY, .ContentType = "application/tar+gzip"};
|
||||||
|
if (E == "gz" || E=="gzip")
|
||||||
|
return MediaTypeEncoding{.Encoding = BINARY, .ContentType = "application/gzip"};
|
||||||
|
|
||||||
return MediaTypeEncoding{.Encoding = BINARY, .ContentType = "application/octet-stream"};
|
return MediaTypeEncoding{.Encoding = BINARY, .ContentType = "application/octet-stream"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -586,4 +615,251 @@ namespace OpenWifi::Utils {
|
|||||||
return DT.timestamp().epochTime();
|
return DT.timestamp().epochTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static std::string FileToString(const std::string &Filename) {
|
||||||
|
std::ifstream ifs(Filename.c_str(),std::ios_base::in|std::ios_base::binary);
|
||||||
|
std::ostringstream os;
|
||||||
|
Poco::StreamCopier::copyStream(ifs,os);
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CreateX509CSR(const CSRCreationParameters & Parameters, CSRCreationResults & Results) {
|
||||||
|
int ret = 0;
|
||||||
|
RSA *r = nullptr;
|
||||||
|
BIGNUM *bne = nullptr;
|
||||||
|
|
||||||
|
int nVersion = 0;
|
||||||
|
unsigned long e = RSA_F4;
|
||||||
|
|
||||||
|
X509_REQ *x509_req = nullptr;
|
||||||
|
X509_NAME *x509_name = nullptr;
|
||||||
|
EVP_PKEY *pKey = nullptr;
|
||||||
|
// RSA *tem = nullptr;
|
||||||
|
// BIO *bio_err = nullptr;
|
||||||
|
|
||||||
|
const char *szCountry = Parameters.Country.c_str();
|
||||||
|
const char *szProvince = Parameters.Province.c_str();
|
||||||
|
const char *szCity = Parameters.City.c_str();
|
||||||
|
const char *szOrganization = Parameters.Organization.c_str();
|
||||||
|
const char *szCommon = Parameters.CommonName.c_str();
|
||||||
|
|
||||||
|
Poco::TemporaryFile CsrPath, PubKey, PrivateKey;
|
||||||
|
std::string Result;
|
||||||
|
std::ifstream ifs;
|
||||||
|
std::ostringstream ss;
|
||||||
|
BIO *bp_public = nullptr,
|
||||||
|
*bp_private = nullptr,
|
||||||
|
*bp_csr = nullptr;
|
||||||
|
|
||||||
|
// 1. generate rsa key
|
||||||
|
bne = BN_new();
|
||||||
|
ret = BN_set_word(bne,e);
|
||||||
|
if(ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
r = RSA_new();
|
||||||
|
ret = RSA_generate_key_ex(r, Parameters.bits, bne, nullptr);
|
||||||
|
if(ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
bp_public = BIO_new_file(PubKey.path().c_str(), "w+");
|
||||||
|
ret = PEM_write_bio_RSAPublicKey(bp_public, r);
|
||||||
|
if(ret != 1) {
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
bp_private = BIO_new_file(PrivateKey.path().c_str(), "w+");
|
||||||
|
ret = PEM_write_bio_RSAPrivateKey(bp_private, r, NULL, NULL, 0, NULL, NULL);
|
||||||
|
if(ret != 1) {
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 2. set version of x509 req
|
||||||
|
x509_req = X509_REQ_new();
|
||||||
|
ret = X509_REQ_set_version(x509_req, nVersion);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. set subject of x509 req
|
||||||
|
x509_name = X509_REQ_get_subject_name(x509_req);
|
||||||
|
|
||||||
|
ret = X509_NAME_add_entry_by_txt(x509_name,"C", MBSTRING_ASC, (const unsigned char*)szCountry, -1, -1, 0);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = X509_NAME_add_entry_by_txt(x509_name,"ST", MBSTRING_ASC, (const unsigned char*)szProvince, -1, -1, 0);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = X509_NAME_add_entry_by_txt(x509_name,"L", MBSTRING_ASC, (const unsigned char*)szCity, -1, -1, 0);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = X509_NAME_add_entry_by_txt(x509_name,"O", MBSTRING_ASC, (const unsigned char*)szOrganization, -1, -1, 0);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = X509_NAME_add_entry_by_txt(x509_name,"CN", MBSTRING_ASC, (const unsigned char*)szCommon, -1, -1, 0);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 4. set public key of x509 req
|
||||||
|
pKey = EVP_PKEY_new();
|
||||||
|
EVP_PKEY_assign_RSA(pKey, r);
|
||||||
|
r = nullptr; // will be free rsa when EVP_PKEY_free(pKey)
|
||||||
|
|
||||||
|
ret = X509_REQ_set_pubkey(x509_req, pKey);
|
||||||
|
if (ret != 1){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 5. set sign key of x509 req
|
||||||
|
ret = X509_REQ_sign(x509_req, pKey, EVP_sha1()); // return x509_req->signature->length
|
||||||
|
if (ret <= 0){
|
||||||
|
goto free_all;
|
||||||
|
}
|
||||||
|
|
||||||
|
bp_csr = BIO_new_file(CsrPath.path().c_str(),"w");
|
||||||
|
ret = PEM_write_bio_X509_REQ(bp_csr, x509_req);
|
||||||
|
|
||||||
|
// 6. free
|
||||||
|
free_all:
|
||||||
|
X509_REQ_free(x509_req);
|
||||||
|
BIO_free_all(bp_csr);
|
||||||
|
BIO_free_all(bp_public);
|
||||||
|
BIO_free_all(bp_private);
|
||||||
|
|
||||||
|
EVP_PKEY_free(pKey);
|
||||||
|
BN_free(bne);
|
||||||
|
if(ret==1) {
|
||||||
|
Results.CSR = FileToString(CsrPath.path());
|
||||||
|
Results.PrivateKey = FileToString(PrivateKey.path());
|
||||||
|
Results.PublicKey = FileToString(PubKey.path());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VerifyECKey(const std::string &key) {
|
||||||
|
try {
|
||||||
|
Poco::TemporaryFile F;
|
||||||
|
|
||||||
|
std::ofstream of(F.path().c_str(), std::ios_base::trunc | std::ios_base::out | std::ios_base::binary);
|
||||||
|
of << key;
|
||||||
|
of.close();
|
||||||
|
|
||||||
|
auto Key = Poco::SharedPtr<Poco::Crypto::ECKey>(
|
||||||
|
new Poco::Crypto::ECKey("", F.path(),""));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (const Poco::Exception &E) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VerifyRSAKey([[
|
||||||
|
maybe_unused]] const std::string &key) {
|
||||||
|
try {
|
||||||
|
Poco::TemporaryFile F;
|
||||||
|
|
||||||
|
std::ofstream of(F.path().c_str(), std::ios_base::trunc | std::ios_base::out | std::ios_base::binary);
|
||||||
|
of << key;
|
||||||
|
of.close();
|
||||||
|
|
||||||
|
auto Key = Poco::SharedPtr<Poco::Crypto::RSAKey>(
|
||||||
|
new Poco::Crypto::RSAKey("", F.path(),""));
|
||||||
|
return true;
|
||||||
|
} catch (const Poco::Exception &E) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValidX509Certificate([[
|
||||||
|
maybe_unused]] const std::string &Cert) {
|
||||||
|
try {
|
||||||
|
Poco::TemporaryFile F;
|
||||||
|
std::ofstream of(F.path().c_str(), std::ios_base::trunc | std::ios_base::out | std::ios_base::binary);
|
||||||
|
of << Cert;
|
||||||
|
of.close();
|
||||||
|
|
||||||
|
auto Key = Poco::SharedPtr<Poco::Crypto::X509Certificate>(
|
||||||
|
new Poco::Crypto::X509Certificate(F.path()));
|
||||||
|
return true;
|
||||||
|
} catch (const Poco::Exception &E) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ValidX509Certificate([[
|
||||||
|
maybe_unused]] const std::vector<std::string> &Certs) {
|
||||||
|
auto F = [](const std::string &C) -> bool { return ValidX509Certificate(C); };
|
||||||
|
return std::all_of(Certs.begin(),Certs.end(), F);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string generateStrongPassword(int minLength, int maxLength, int numDigits, int minLowercase, int minSpecial, int minUppercase) {
|
||||||
|
// Define character sets for each category
|
||||||
|
const std::string lowercaseChars = "abcdefghijklmnopqrstuvwxyz";
|
||||||
|
const std::string uppercaseChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||||
|
const std::string digitChars = "0123456789";
|
||||||
|
const std::string specialChars = "!@#$%^&*()_+[]{}|;:,.<>?";
|
||||||
|
|
||||||
|
// Check if parameters are valid
|
||||||
|
if (minLength < 1 || minLength > maxLength || minLowercase + minUppercase + numDigits + minSpecial > maxLength) {
|
||||||
|
return "Invalid parameters";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize random seed
|
||||||
|
std::random_device rd;
|
||||||
|
std::mt19937 g(rd());
|
||||||
|
|
||||||
|
// Initialize the password string
|
||||||
|
std::string password;
|
||||||
|
|
||||||
|
// Generate the required number of each character type
|
||||||
|
for (int i = 0; i < minLowercase; ++i) {
|
||||||
|
password += lowercaseChars[g() % lowercaseChars.length()];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < minUppercase; ++i) {
|
||||||
|
password += uppercaseChars[g() % uppercaseChars.length()];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < numDigits; ++i) {
|
||||||
|
password += digitChars[g() % digitChars.length()];
|
||||||
|
}
|
||||||
|
for (int i = 0; i < minSpecial; ++i) {
|
||||||
|
password += specialChars[g() % specialChars.length()];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calculate how many more characters are needed
|
||||||
|
int remainingLength = maxLength - (int)password.length();
|
||||||
|
|
||||||
|
// Generate random characters to fill the remaining length
|
||||||
|
for (int i = 0; i < remainingLength; ++i) {
|
||||||
|
int category = g() % 4; // Randomly select a category
|
||||||
|
if (category == 0) {
|
||||||
|
password += lowercaseChars[g() % lowercaseChars.length()];
|
||||||
|
} else if (category == 1) {
|
||||||
|
password += uppercaseChars[g() % uppercaseChars.length()];
|
||||||
|
} else if (category == 2) {
|
||||||
|
password += digitChars[g() % digitChars.length()];
|
||||||
|
} else {
|
||||||
|
password += specialChars[g() % specialChars.length()];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Shuffle the password to randomize the character order
|
||||||
|
std::shuffle(password.begin(), password.end(),g);
|
||||||
|
|
||||||
|
return password;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace OpenWifi::Utils
|
} // namespace OpenWifi::Utils
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
#include <dirent.h>
|
||||||
|
|
||||||
#include "Poco/Base64Decoder.h"
|
#include "Poco/Base64Decoder.h"
|
||||||
#include "Poco/Base64Encoder.h"
|
#include "Poco/Base64Encoder.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
@@ -68,8 +70,10 @@ namespace OpenWifi::Utils {
|
|||||||
};
|
};
|
||||||
|
|
||||||
[[nodiscard]] bool ValidSerialNumber(const std::string &Serial);
|
[[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 ValidUUID(const std::string &UUID);
|
||||||
[[nodiscard]] bool ValidHostname(const std::string &hostname);
|
[[nodiscard]] bool ValidHostname(const std::string &hostname);
|
||||||
|
[[nodiscard]] bool ValidNumber(const std::string &number, bool isSigned);
|
||||||
|
|
||||||
template <typename... Args> std::string ComputeHash(Args &&...args) {
|
template <typename... Args> std::string ComputeHash(Args &&...args) {
|
||||||
Poco::SHA2Engine E;
|
Poco::SHA2Engine E;
|
||||||
@@ -146,4 +150,118 @@ namespace OpenWifi::Utils {
|
|||||||
|
|
||||||
bool ExtractBase64CompressedData(const std::string &CompressedData,
|
bool ExtractBase64CompressedData(const std::string &CompressedData,
|
||||||
std::string &UnCompressedData, uint64_t compress_sz);
|
std::string &UnCompressedData, uint64_t compress_sz);
|
||||||
|
|
||||||
|
inline bool match(const char* first, const char* second)
|
||||||
|
{
|
||||||
|
// If we reach at the end of both strings, we are done
|
||||||
|
if (*first == '\0' && *second == '\0')
|
||||||
|
return true;
|
||||||
|
|
||||||
|
// Make sure to eliminate consecutive '*'
|
||||||
|
if (*first == '*') {
|
||||||
|
while (*(first + 1) == '*')
|
||||||
|
first++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make sure that the characters after '*' are present
|
||||||
|
// in second string. This function assumes that the
|
||||||
|
// first string will not contain two consecutive '*'
|
||||||
|
if (*first == '*' && *(first + 1) != '\0'
|
||||||
|
&& *second == '\0')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// If the first string contains '?', or current
|
||||||
|
// characters of both strings match
|
||||||
|
if (*first == '?' || *first == *second)
|
||||||
|
return match(first + 1, second + 1);
|
||||||
|
|
||||||
|
// If there is *, then there are two possibilities
|
||||||
|
// a) We consider current character of second string
|
||||||
|
// b) We ignore current character of second string.
|
||||||
|
if (*first == '*')
|
||||||
|
return match(first + 1, second)
|
||||||
|
|| match(first, second + 1);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct CSRCreationParameters {
|
||||||
|
std::string Country, Province, City,
|
||||||
|
Organization, CommonName;
|
||||||
|
int bits=2048;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct CSRCreationResults {
|
||||||
|
std::string CSR, PublicKey, PrivateKey;
|
||||||
|
};
|
||||||
|
|
||||||
|
bool CreateX509CSR(const CSRCreationParameters & Parameters, CSRCreationResults & Results);
|
||||||
|
std::string generateStrongPassword(int minLength, int maxLength, int numDigits, int minLowercase, int minSpecial, int minUppercase);
|
||||||
|
bool VerifyECKey(const std::string &key);
|
||||||
|
bool VerifyRSAKey(const std::string &key);
|
||||||
|
bool ValidX509Certificate(const std::string &Cert);
|
||||||
|
bool ValidX509Certificate(const std::vector<std::string> &Certs);
|
||||||
|
|
||||||
} // namespace OpenWifi::Utils
|
} // namespace OpenWifi::Utils
|
||||||
|
|||||||
@@ -39,6 +39,9 @@ ucentral.system.commandchannel = /tmp/app.ucentralfms
|
|||||||
#
|
#
|
||||||
# Firmware Microservice Specific Section
|
# Firmware Microservice Specific Section
|
||||||
#
|
#
|
||||||
|
s3.endpointOverride = 172.31.30.127:9000
|
||||||
|
s3.endpoint.https = false
|
||||||
|
s3.useVirtualAdressing = false
|
||||||
s3.bucketname = ucentral-ap-firmware
|
s3.bucketname = ucentral-ap-firmware
|
||||||
s3.region = us-east-1
|
s3.region = us-east-1
|
||||||
s3.secret = ****************************
|
s3.secret = ****************************
|
||||||
|
|||||||
Reference in New Issue
Block a user