Compare commits

...

67 Commits

Author SHA1 Message Date
TIP Automation User
6f802f4de2 Chg: update image tag in helm values to v2.7.0-RC5 2022-10-03 11:14:29 +00:00
Dmitry Dunaev
e047b25a71 Merge pull request #37 from Telecominfraproject/main
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-10-03 14:08:49 +03:00
Dmitry Dunaev
da80ab49cd [WIFI-10581] Fix: Helm image to main
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-03 12:07:01 +03:00
Dmitry Dunaev
bf0fd21eae Merge pull request #38 from Telecominfraproject/fix/wifi-10581--postgres-client
[WIFI-10581] Add: postgresql-client in Dockerfile
2022-10-03 11:25:20 +03:00
Dmitry Dunaev
829efdfec8 [WIFI-10581] Add: postgresql-client in Dockerfile
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-10-03 11:25:07 +03:00
Stephane Bourque
d258bbb414 Merge branch 'release/v2.7.0' into main 2022-10-02 11:40:07 -07:00
Stephane Bourque
972bbbafdc Merge pull request #36 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-10-02 11:38:54 -07:00
Stephane Bourque
f0442d4c8e Merge branch 'main' into WIFI-10942 2022-10-02 11:38:48 -07:00
Stephane Bourque
f3713df910 https://telecominfraproject.atlassian.net/browse/WIFI-10942 2022-10-02 11:37:37 -07:00
Stephane Bourque
085fbfcdf3 Merge pull request #23 from Telecominfraproject/WIFI-10581-switch-images-to-debian-slim
[WIFI-10581] Switch microservice Docker images from Alpine to Debian-slim
2022-10-02 11:33:57 -07:00
TIP Automation User
e7997f28f4 Chg: update image tag in helm values to v2.7.0-RC4 2022-09-30 19:49:02 +00:00
Stephane Bourque
ef7deb3515 Merge pull request #35 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-09-30 11:17:36 -07:00
stephb9959
70444bb7ab https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-30 11:16:28 -07:00
Stephane Bourque
105bf2912b Merge pull request #34 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-09-30 11:12:22 -07:00
Stephane Bourque
87dfb313d5 Merge branch 'release/v2.7.0' into WIFI-10942 2022-09-30 11:12:15 -07:00
stephb9959
5658db43eb https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-30 11:09:43 -07:00
stephb9959
bff4db6a3a https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-30 11:08:20 -07:00
TIP Automation User
8ecc461749 Chg: update image tag in helm values to v2.7.0-RC3 2022-09-30 16:31:39 +00:00
Stephane Bourque
97377fef7b Merge pull request #33 from Telecominfraproject/WIFI-10942
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-09-30 09:04:29 -07:00
stephb9959
877f7985cd https://telecominfraproject.atlassian.net/browse/WIFI-10942
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-30 09:03:57 -07:00
TIP Automation User
9b916621a2 Chg: update image tag in helm values to v2.7.0-RC2 2022-09-29 23:27:47 +00:00
jaspreetsachdev
5e57c9a7c5 Merge pull request #32 from Telecominfraproject/main
Fixes for WIFI-10839 and others
2022-09-29 19:19:34 -04:00
Dmitry Dunaev
e9bb037ef2 Merge pull request #31 from Telecominfraproject/feature/wifi-10932--docker-support-http
[WIFI-10932] Add: restapi disable property in docker entrypoing
2022-09-28 17:26:55 +03:00
Dmitry Dunaev
054c40c7ed [WIFI-10932] Add: restapi disable property in docker entrypoing
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-28 17:26:01 +03:00
Dmitry Dunaev
99c59313ea Merge pull request #30 from Telecominfraproject/feature/wifi-10582--helm-global-cert-secret
[WIFI-10582] Add: functionality to use external existing certificates secret
2022-09-28 17:06:25 +03:00
Dmitry Dunaev
ff843f093c [WIFI-10582] Add: functionality to use external existing certificates secret
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-28 13:26:51 +03:00
Stephane Bourque
eec96dff52 Merge pull request #29 from Telecominfraproject/WIFI-10839
https://telecominfraproject.atlassian.net/browse/WIFI-10839
2022-09-22 21:47:34 -07:00
stephb9959
9c9f2cbf4f https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-22 21:47:11 -07:00
Stephane Bourque
98342bb626 Merge pull request #28 from Telecominfraproject/WIFI-10839
https://telecominfraproject.atlassian.net/browse/WIFI-10839
2022-09-22 20:39:23 -07:00
stephb9959
93890a1e99 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-22 20:39:01 -07:00
Stephane Bourque
f9111bab7b Merge pull request #27 from Telecominfraproject/WIFI-10839
https://telecominfraproject.atlassian.net/browse/WIFI-10839
2022-09-21 19:50:38 -07:00
stephb9959
8f9e954f20 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-21 19:49:34 -07:00
TIP Automation User
a568fce901 Chg: update image tag in helm values to v2.7.0-RC1 2022-09-16 19:55:07 +00:00
Stephane Bourque
6e2a21c831 Merge pull request #26 from Telecominfraproject/WIFI-10839
https://telecominfraproject.atlassian.net/browse/WIFI-10839
2022-09-14 12:28:05 -07:00
stephb9959
da8a9e14cf https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 12:27:02 -07:00
stephb9959
075b83a7d5 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 12:17:36 -07:00
stephb9959
3c35ec1523 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 12:13:48 -07:00
stephb9959
b65f33c975 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 11:55:34 -07:00
stephb9959
cbd5b09cdf https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 11:51:48 -07:00
stephb9959
0a145c8501 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 11:38:55 -07:00
stephb9959
2ed88569d0 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 11:27:14 -07:00
stephb9959
58c2269893 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 09:43:04 -07:00
stephb9959
a708cc2be0 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 09:34:55 -07:00
Stephane Bourque
9c8f7ed6f9 Merge pull request #25 from Telecominfraproject/WIFI-10839
https://telecominfraproject.atlassian.net/browse/WIFI-10839
2022-09-14 08:59:24 -07:00
stephb9959
b79a3b6c12 https://telecominfraproject.atlassian.net/browse/WIFI-10839
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
2022-09-14 08:58:32 -07:00
Dmitry Dunaev
2c3b7711b3 Merge pull request #24 from Telecominfraproject/feature/wifi-10069--add-wait-postgres-initcontainer
[WIFI-10069] Add: helm - wait-postgres init container
2022-09-02 14:33:07 +03:00
Dmitry Dunaev
831e144869 [WIFI-10069] Add: helm - wait-postgres init container
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-09-02 14:32:42 +03:00
Johann Hoffmann
25397c80c9 Fix self-signed cert file extension for Debian
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-08-19 17:18:59 +02:00
Johann Hoffmann
2e046340e3 Create necessary library links in Docker image
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-08-19 16:06:39 +02:00
Johann Hoffmann
61dff87583 Fix curl-dev package name
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-08-18 16:35:05 +02:00
Johann Hoffmann
c73fd21b94 Switch to Debian-slim base images
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-08-18 14:15:38 +02:00
Dmitry Dunaev
8049291138 Merge pull request #22 from Telecominfraproject/fix/wifi-10413--cve-fix
[WIFI-10413] Fix: vulnerable base Docker image version
2022-08-15 13:31:08 +03:00
Dmitry Dunaev
613fa2e2bb [WIFI-10413] Fix: vulnerable base Docker image version
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-08-15 11:20:31 +03:00
Stephane Bourque
eb9a748836 Merge pull request #21 from Telecominfraproject/WIFI-10547
https://telecominfraproject.atlassian.net/browse/WIFI-10547Wifi 10547
2022-08-11 21:37:29 -07:00
Stephane Bourque
e01f985974 Merge pull request #20 from Telecominfraproject/WIFI-10245
https://telecominfraproject.atlassian.net/browse/WIFI-10245
2022-08-10 16:40:52 -07:00
Stephane Bourque
52e1bf8817 Merge pull request #19 from Telecominfraproject/feature/wifi-10388--versioning
[WIFI-10388] Chg: use Docker build arg to define dependency version
2022-08-08 12:12:01 -07:00
Dmitry Dunaev
a8b0028af6 [WIFI-10388] Chg: use Docker build arg to define dependency version
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-08-08 17:46:38 +03:00
Stephane Bourque
7976602d17 Merge pull request #18 from Telecominfraproject/WIFI-10388
https://telecominfraproject.atlassian.net/browse/WIFI-10388
2022-08-07 22:30:59 -07:00
Stephane Bourque
1da468e52c Merge pull request #17 from Telecominfraproject/WIFI-10388
https://telecominfraproject.atlassian.net/browse/WIFI-10388
2022-08-04 06:59:03 -07:00
Stephane Bourque
d396a104ff Merge pull request #16 from Telecominfraproject/WIFI-10388
https://telecominfraproject.atlassian.net/browse/WIFI-10388
2022-08-03 08:02:06 -07:00
Stephane Bourque
c1f06ec784 Merge pull request #15 from Telecominfraproject/WIFI-10388
https://telecominfraproject.atlassian.net/browse/WIFI-10388
2022-08-01 09:37:46 -07:00
Dmitry Dunaev
432d0ed52b Merge pull request #14 from Telecominfraproject/feature/wifi-9772--test-systeminfo
[WIFI-9772] Chg: fix test scripts to make requests to owanalytics instead of owprov
2022-07-21 15:43:52 +03:00
Dmitry Dunaev
fe247c6093 [WIFI-9772] Chg: fix test scripts to make requests to owanalytics instead of owprov
Signed-off-by: Dmitry Dunaev <dmitry@opsfleet.com>
2022-07-21 15:43:13 +03:00
Stephane Bourque
4c1daf84cf Merge pull request #13 from Telecominfraproject/WIFI-10040
Fix: https://telecominfraproject.atlassian.net/browse/WIFI-10040
2022-07-04 14:19:21 -07:00
Stephane Bourque
d0c4030289 Merge pull request #11 from Telecominfraproject/WIFI-10040
Fix: https://telecominfraproject.atlassian.net/browse/WIFI-10040
2022-07-01 09:58:01 -07:00
Johann Hoffmann
0856e256e9 Merge pull request #9 from Telecominfraproject/WIFI-9920-rttys-not-working-after-upgrade
[WIFI-9920] Always re-generate config file if TEMPLATE_CONFIG is set to true
2022-06-24 18:22:20 +02:00
Johann Hoffmann
228b2162bc Always re-generate config file if TEMPLATE_CONFIG is set to true
Signed-off-by: Johann Hoffmann <johann.hoffmann@mailbox.org>
2022-06-24 18:19:41 +02:00
34 changed files with 23292 additions and 268 deletions

1
.gitignore vendored
View File

@@ -32,6 +32,7 @@
*.app
test_scripts/curl/token.json
test_scripts/curl/result.json
.vscode/c_cpp_properties.json
test_scripts/curl/result.json
*.swp

View File

@@ -63,6 +63,8 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
add_definitions(-DPOCO_LOG_DEBUG="1")
add_executable(owanalytics
build
src/ow_version.h.in
@@ -75,7 +77,9 @@ add_executable(owanalytics
src/framework/ConfigurationValidator.cpp
src/framework/ConfigurationValidator.h
src/framework/ow_constants.h
src/framework/MicroServiceErrorHandler.h
src/framework/WebSocketClientNotifications.h
src/framework/MicroServiceErrorHandler.h
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
src/RESTObjects/RESTAPI_ProvObjects.cpp src/RESTObjects/RESTAPI_ProvObjects.h
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp

View File

@@ -1,16 +1,23 @@
FROM alpine:3.15 AS build-base
ARG DEBIAN_VERSION=11.4-slim
ARG POCO_VERSION=poco-tip-v1
ARG FMTLIB_VERSION=9.0.0
ARG CPPKAFKA_VERSION=tip-v1
ARG JSON_VALIDATOR_VERSION=2.1.0
RUN apk add --update --no-cache \
FROM debian:$DEBIAN_VERSION AS build-base
RUN apt-get update && apt-get install --no-install-recommends -y \
make cmake g++ git \
unixodbc-dev postgresql-dev mariadb-dev \
librdkafka-dev boost-dev openssl-dev \
zlib-dev nlohmann-json \
curl-dev
libpq-dev libmariadb-dev libmariadbclient-dev-compat \
librdkafka-dev libboost-all-dev libssl-dev \
zlib1g-dev nlohmann-json3-dev ca-certificates libcurl4-openssl-dev
FROM build-base AS poco-build
ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/poco-tip-v1 version.json
RUN git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1 /poco
ARG POCO_VERSION
ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/${POCO_VERSION} version.json
RUN git clone https://github.com/AriliaWireless/poco --branch ${POCO_VERSION} /poco
WORKDIR /poco
RUN mkdir cmake-build
@@ -19,22 +26,12 @@ RUN cmake ..
RUN cmake --build . --config Release -j8
RUN cmake --build . --target install
FROM build-base AS cppkafka-build
ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/tip-v1 version.json
RUN git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1 /cppkafka
WORKDIR /cppkafka
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake ..
RUN cmake --build . --config Release -j8
RUN cmake --build . --target install
FROM build-base AS fmtlib-build
ADD https://api.github.com/repos/fmtlib/fmt/git/refs/tags/9.0.0 version.json
RUN git clone https://github.com/fmtlib/fmt --branch 9.0.0 /fmtlib
ARG FMTLIB_VERSION
ADD https://api.github.com/repos/fmtlib/fmt/git/refs/tags/${FMTLIB_VERSION} version.json
RUN git clone https://github.com/fmtlib/fmt --branch ${FMTLIB_VERSION} /fmtlib
WORKDIR /fmtlib
RUN mkdir cmake-build
@@ -43,10 +40,26 @@ RUN cmake ..
RUN make
RUN make install
FROM build-base AS cppkafka-build
ARG CPPKAFKA_VERSION
ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
RUN git clone https://github.com/AriliaWireless/cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
WORKDIR /cppkafka
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake ..
RUN cmake --build . --config Release -j8
RUN cmake --build . --target install
FROM build-base AS json-schema-validator-build
ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/tags/2.1.0 version.json
RUN git clone https://github.com/pboettch/json-schema-validator --branch 2.1.0 /json-schema-validator
ARG JSON_VALIDATOR_VERSION
ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/tags/${JSON_VALIDATOR_VERSION} version.json
RUN git clone https://github.com/pboettch/json-schema-validator --branch ${JSON_VALIDATOR_VERSION} /json-schema-validator
WORKDIR /json-schema-validator
RUN mkdir cmake-build
@@ -77,21 +90,21 @@ WORKDIR /owanalytics/cmake-build
RUN cmake ..
RUN cmake --build . --config Release -j8
FROM alpine:3.15
FROM debian:$DEBIAN_VERSION
ENV OWANALYTICS_USER=owanalytics \
OWANALYTICS_ROOT=/owanalytics-data \
OWANALYTICS_CONFIG=/owanalytics-data
RUN addgroup -S "$OWANALYTICS_USER" && \
adduser -S -G "$OWANALYTICS_USER" "$OWANALYTICS_USER"
RUN useradd "$OWANALYTICS_USER"
RUN mkdir /openwifi
RUN mkdir -p "$OWANALYTICS_ROOT" "$OWANALYTICS_CONFIG" && \
chown "$OWANALYTICS_USER": "$OWANALYTICS_ROOT" "$OWANALYTICS_CONFIG"
RUN apk add --update --no-cache librdkafka su-exec gettext ca-certificates bash jq curl \
mariadb-connector-c libpq unixodbc postgresql-client
RUN apt-get update && apt-get install --no-install-recommends -y \
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
libmariadb-dev-compat libpq5 unixodbc postgresql-client
COPY readiness_check /readiness_check
COPY test_scripts/curl/cli /cli
@@ -100,12 +113,14 @@ COPY owanalytics.properties.tmpl /
COPY docker-entrypoint.sh /
COPY wait-for-postgres.sh /
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.pem
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
COPY --from=owanalytics-build /owanalytics/cmake-build/owanalytics /openwifi/owanalytics
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/* /usr/local/lib
COPY --from=poco-build /poco/cmake-build/lib/* /usr/local/lib
RUN ldconfig
EXPOSE 16009 17009 16109
ENTRYPOINT ["/docker-entrypoint.sh"]

2
build
View File

@@ -1 +1 @@
10
22

View File

@@ -1,11 +1,11 @@
#!/bin/sh
#!/bin/bash
set -e
if [ "$SELFSIGNED_CERTS" = 'true' ]; then
update-ca-certificates
fi
if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWANALYTICS_CONFIG"/owanalytics.properties ]]; then
if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then
RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWANALYTICS_ROOT/certs/restapi-ca.pem"} \
RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16009"} \
RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWANALYTICS_ROOT/certs/restapi-cert.pem"} \
@@ -24,6 +24,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWANALYTICS_CONFIG"/owanalytics.prop
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17009"} \
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16009"} \
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \
KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \
KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \
KAFKA_SSL_CA_LOCATION=${KAFKA_SSL_CA_LOCATION:-""} \
@@ -48,7 +49,7 @@ if [ "$1" = '/openwifi/owanalytics' -a "$(id -u)" = '0' ]; then
if [ "$RUN_CHOWN" = 'true' ]; then
chown -R "$OWANALYTICS_USER": "$OWANALYTICS_ROOT" "$OWANALYTICS_CONFIG"
fi
exec su-exec "$OWANALYTICS_USER" "$@"
exec gosu "$OWANALYTICS_USER" "$@"
fi
exec "$@"

2
helm/.gitignore vendored
View File

@@ -1 +1,3 @@
*.swp
Chart.lock
charts/

View File

@@ -70,8 +70,8 @@ The following table lists the configurable parameters of the chart and their def
| persistence.size | string | Defines PV size | `'10Gi'` |
| public_env_variables | hash | Defines list of environment variables to be passed to the Analytics | |
| configProperties | hash | Configuration properties that should be passed to the application in `owanalytics.properties`. May be passed by key in set (i.e. `configProperties."rtty\.token"`) | |
| certs | hash | Defines files (keys and certificates) that should be passed to the Analytics (PEM format is adviced to be used) (see `volumes.owanalytics` on where it is mounted) | |
| existingCertsSecret | string | Existing Kubernetes secret containing all required certificates and private keys for microservice operation. If set, certificates from `certs` key are ignored | `""` |
| certs | hash | Defines files (keys and certificates) that should be passed to the Gateway (PEM format is adviced to be used) (see `volumes.owanalytics` on where it is mounted). If `existingCertsSecret` is set, certificates passed this way will not be used. | |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

View File

@@ -1,4 +1,5 @@
{{- $root := . -}}
{{- $storageType := index .Values.configProperties "storage.type" -}}
---
apiVersion: apps/v1
kind: Deployment
@@ -46,6 +47,39 @@ spec:
- -timeout
- 600s
{{- if eq $storageType "postgresql" }}
- name: wait-postgres
image: "{{ .Values.images.owanalytics.repository }}:{{ .Values.images.owanalytics.tag }}"
imagePullPolicy: {{ .Values.images.owanalytics.pullPolicy }}
command:
- /wait-for-postgres.sh
- {{ index .Values.configProperties "storage.type.postgresql.host" }}
- echo
- "PostgreSQL is ready"
env:
- name: KUBERNETES_DEPLOYED
value: "{{ now }}"
{{- range $key, $value := .Values.public_env_variables }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range $key, $value := .Values.secret_env_variables }}
- name: {{ $key }}
valueFrom:
secretKeyRef:
name: {{ include "owanalytics.fullname" $root }}-env
key: {{ $key }}
{{- end }}
volumeMounts:
{{- range .Values.volumes.owanalytics }}
- name: {{ .name }}
mountPath: {{ .mountPath }}
{{- if .subPath }}
subPath: {{ .subPath }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: owanalytics

View File

@@ -9,7 +9,7 @@ fullnameOverride: ""
images:
owanalytics:
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owanalytics
tag: main
tag: v2.7.0-RC5
pullPolicy: Always
# regcred:
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
@@ -71,7 +71,7 @@ volumes:
mountPath: /owanalytics-data/certs
volumeDefinition: |
secret:
secretName: {{ include "owanalytics.fullname" . }}-certs
secretName: {{ if .Values.existingCertsSecret }}{{ .Values.existingCertsSecret }}{{ else }}{{ include "owanalytics.fullname" . }}-certs{{ end }}
# Change this if you want to use another volume type
- name: persist
mountPath: /owanalytics-data/persist
@@ -198,6 +198,9 @@ configProperties:
storage.type.mysql.username: stephb
storage.type.mysql.password: snoopy99
# NOTE: List of required certificates may be found in "certs" key. Alternative way to pass required certificates is to create external secret with all required certificates and set secret name in "existingCertsSecret" key. Details may be found in https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/main/chart#tldr
existingCertsSecret: ""
certs:
# restapi-ca.pem: ""
# restapi-cert.pem: ""

View File

@@ -34,6 +34,7 @@ openwifi.system.uri.private = https://localhost:17009
openwifi.system.uri.public = https://ucentral.dpaas.arilia.com:16009
openwifi.system.commandchannel = /tmp/app.owanalytics
openwifi.system.uri.ui = owprov-ui.arilia.com
openwifi.security.restapi.disable = false
#############################
# Generic information for all micro services
@@ -101,4 +102,4 @@ storage.type.mysql.connectiontimeout = 60
########################################################################
logging.type = file
logging.path = $OWANALYTICS_ROOT/logs
logging.level = debug
logging.level = debug

View File

@@ -39,6 +39,7 @@ openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE}
openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
openwifi.system.commandchannel = /tmp/app.owanalytics
openwifi.system.uri.ui = ${SYSTEM_URI_UI}
openwifi.security.restapi.disable = ${SECURITY_RESTAPI_DISABLE}
#############################
# Generic information for all micro services

View File

@@ -93,7 +93,7 @@ namespace OpenWifi {
DI_.connected =true;
AnalyticsObjects::DeviceTimePoint DTP;
Logger().information(fmt::format("{}: stats message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: stats message.", DI_.serialNumber));
// find radios first to get associations.
try {
@@ -158,6 +158,7 @@ namespace OpenWifi {
auto interfaces = (*State)["interfaces"];
DI_.associations_2g = DI_.associations_5g = DI_.associations_6g = 0;
for(const auto &interface:interfaces) {
std::string InterfaceName = fmt::format("{}: {}", DI_.serialNumber, interface.contains("name") ? to_string(interface["name"]) : "unknown");
if(interface.contains("counters")) {
auto counters = interface["counters"];
GetJSON("collisions", counters, DTP.ap_data.collisions, (uint64_t) 0);
@@ -172,6 +173,34 @@ namespace OpenWifi {
GetJSON("tx_packets", counters, DTP.ap_data.tx_packets, (uint64_t) 0);
}
InterfaceClientEntryMap_t ICEM;
if(interface.contains("clients") && interface["clients"].is_array()) {
try {
auto Clients = interface["clients"];
for(const auto & client: Clients) {
if(client.contains("mac") && client["mac"].is_string()) {
InterfaceClientEntry E;
if(client.contains("ipv4_addresses") && client["ipv4_addresses"].is_array()) {
for(const auto &ip:client["ipv4_addresses"]) {
E.ipv4_addresses.push_back(ip);
}
}
if(client.contains("ipv6_addresses") && client["ipv6_addresses"].is_array()) {
for(const auto &ip:client["ipv6_addresses"]) {
E.ipv6_addresses.push_back(ip);
}
}
auto M = mac_filter(client["mac"]);
ICEM[M] = E;
}
}
} catch(...) {
std::cout << "Exception will parsing clients: " << InterfaceName << std::endl;
}
} else {
// std::cout <<"Interface: No clients: " << InterfaceName << std::endl;
}
if(interface.contains("ssids")) {
auto ssids = interface["ssids"];
for (const auto &ssid: ssids) {
@@ -243,8 +272,19 @@ namespace OpenWifi {
GetJSON("rx_packets",association,WFH.rx_packets,(uint64_t)0);
GetJSON("tx_packets",association,WFH.tx_packets,(uint64_t)0);
WFH.ipv4 = "---";
WFH.ipv6 = "----";
// try to locate the IP addresses
auto ClientInfo = ICEM.find(WFH.station_id);
if(ClientInfo!=end(ICEM)) {
if(!ClientInfo->second.ipv4_addresses.empty()) {
WFH.ipv4 = ClientInfo->second.ipv4_addresses[0];
}
if(!ClientInfo->second.ipv6_addresses.empty()) {
WFH.ipv6 = ClientInfo->second.ipv6_addresses[0];
}
std::cout << __LINE__ << ": " << InterfaceName << " Mac Found: " << ICEM.size() << " entries. " << WFH.station_id << std::endl;
} else {
std::cout << __LINE__ << ": " << InterfaceName << " Mac NOT found: " << ICEM.size() << " entries. " << WFH.station_id << std::endl;
}
for(const auto &rd:DTP.radio_data) {
if(rd.band == SSIDTP.band) {
@@ -311,7 +351,7 @@ namespace OpenWifi {
}
DTP.device_info = DI_;
} catch (...) {
Logger().information(fmt::format("{}: stats failed parsing.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: stats failed parsing.", DI_.serialNumber));
}
if(got_base) {
@@ -477,7 +517,7 @@ namespace OpenWifi {
GetJSON("locale", ConnectionData, DI_.locale, std::string{} );
}
} catch (...) {
Logger().information(fmt::format("{}: error parsing connection message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: error parsing connection message.", DI_.serialNumber));
}
}
@@ -488,7 +528,7 @@ namespace OpenWifi {
GetJSON("sanity", *Health, DI_.health, (uint64_t)0 );
poco_debug(Logger(),fmt::format("{}: health message.", DI_.serialNumber));
} catch(...) {
Logger().information(fmt::format("{}: error parsing health message.", DI_.serialNumber));
poco_information(Logger(),fmt::format("{}: error parsing health message.", DI_.serialNumber));
}
}
}

View File

@@ -11,6 +11,13 @@
namespace OpenWifi {
struct InterfaceClientEntry {
std::vector<std::string> ipv4_addresses;
std::vector<std::string> ipv6_addresses;
};
using InterfaceClientEntryMap_t = std::map<std::string,InterfaceClientEntry>;
class AP {
public:
explicit AP(uint64_t mac, const std::string &venue_id, const std::string &BoardId, Poco::Logger &L) :

View File

@@ -45,17 +45,25 @@ namespace OpenWifi {
}
int main(int argc, char **argv) {
try {
auto App = OpenWifi::Daemon::instance();
auto ExitCode = App->run(argc, argv);
delete App;
int ExitCode;
try {
Poco::Net::SSLManager::instance().initializeServer(nullptr, nullptr, nullptr);
auto App = OpenWifi::Daemon::instance();
ExitCode = App->run(argc, argv);
Poco::Net::SSLManager::instance().shutdown();
} catch (Poco::Exception &exc) {
ExitCode = Poco::Util::Application::EXIT_SOFTWARE;
std::cout << exc.displayText() << std::endl;
} catch (std::exception &exc) {
ExitCode = Poco::Util::Application::EXIT_TEMPFAIL;
std::cout << exc.what() << std::endl;
} catch (...) {
ExitCode = Poco::Util::Application::EXIT_TEMPFAIL;
std::cout << "Exception on closure" << std::endl;
}
return ExitCode;
} catch (Poco::Exception &exc) {
std::cerr << exc.displayText() << std::endl;
return Poco::Util::Application::EXIT_SOFTWARE;
}
std::cout << "Exitcode: " << ExitCode << std::endl;
return ExitCode;
}
// end of namespace

View File

@@ -20,10 +20,9 @@ namespace OpenWifi {
}
if(GetBoolParameter("macsOnly")) {
auto macFilter = GetParameter("macFilter","");
std::vector<uint64_t> Macs;
WifiClientCache()->FindNumbers(venue,macFilter,500,Macs);
WifiClientCache()->FindNumbers(venue,macFilter,QB_.Offset, QB_.Limit, Macs);
Poco::JSON::Array Arr;
for(const auto &mac: Macs)
Arr.add(Utils::IntToSerialNumber(mac));

View File

@@ -203,6 +203,10 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"kafkaClients", kafkaClients);
field_to_json(Obj,"kafkaPackets", kafkaPackets);
field_to_json(Obj,"locale", locale);
field_to_json(Obj,"started", started);
field_to_json(Obj,"sessionId", sessionId);
field_to_json(Obj,"connectionCompletionTime", connectionCompletionTime);
field_to_json(Obj,"totalConnectionTime", OpenWifi::Now() - started);
switch(VerifiedCertificate) {
case NO_CERTIFICATE:
@@ -218,6 +222,21 @@ namespace OpenWifi::GWObjects {
}
}
void DeviceConnectionStatistics::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"averageConnectionTime", averageConnectionTime);
field_to_json(Obj,"connectedDevices", connectedDevices );
}
bool DeviceConnectionStatistics::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"averageConnectionTime", averageConnectionTime);
field_from_json(Obj,"connectedDevices", connectedDevices );
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void RttySessionDetails::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber", SerialNumber);
field_to_json(Obj,"server", Server);
@@ -293,7 +312,6 @@ namespace OpenWifi::GWObjects {
} catch (const Poco::Exception &E) {
}
return false;
}
void RadiusProxyPoolList::to_json(Poco::JSON::Object &Obj) const {
@@ -314,6 +332,8 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"description",description);
field_to_json(Obj,"authConfig",authConfig);
field_to_json(Obj,"acctConfig",acctConfig);
field_to_json(Obj,"coaConfig",coaConfig);
field_to_json(Obj,"useByDefault",useByDefault);
}
bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -322,6 +342,8 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"description",description);
field_from_json(Obj,"authConfig",authConfig);
field_from_json(Obj,"acctConfig",acctConfig);
field_from_json(Obj,"coaConfig",coaConfig);
field_from_json(Obj,"useByDefault",useByDefault);
return true;
} catch (const Poco::Exception &E) {
}
@@ -329,7 +351,7 @@ namespace OpenWifi::GWObjects {
}
void RadiusProxyServerConfig::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"policy",strategy);
field_to_json(Obj,"strategy",strategy);
field_to_json(Obj,"monitor",monitor);
field_to_json(Obj,"monitorMethod",monitorMethod);
field_to_json(Obj,"methodParameters",methodParameters);
@@ -338,7 +360,7 @@ namespace OpenWifi::GWObjects {
bool RadiusProxyServerConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"policy",strategy);
field_from_json(Obj,"strategy",strategy);
field_from_json(Obj,"monitor",monitor);
field_from_json(Obj,"monitorMethod",monitorMethod);
field_from_json(Obj,"methodParameters",methodParameters);
@@ -354,6 +376,16 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"ip",ip);
field_to_json(Obj,"port",port);
field_to_json(Obj,"weight",weight);
field_to_json(Obj,"secret",secret);
field_to_json(Obj,"certificate",certificate);
field_to_json(Obj,"radsec",radsec);
field_to_json(Obj,"radsecPort",radsecPort);
field_to_json(Obj,"radsecSecret",radsecSecret);
field_to_json(Obj,"radsecCacerts",radsecCacerts);
field_to_json(Obj,"radsecCert",radsecCert);
field_to_json(Obj,"radsecKey",radsecKey);
field_to_json(Obj,"radsecRealms",radsecRealms);
field_to_json(Obj,"ignore",ignore);
}
bool RadiusProxyServerEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -362,6 +394,16 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"ip",ip);
field_from_json(Obj,"port",port);
field_from_json(Obj,"weight",weight);
field_from_json(Obj,"secret",secret);
field_from_json(Obj,"certificate",certificate);
field_from_json(Obj,"radsec",radsec);
field_from_json(Obj,"radsecSecret",radsecSecret);
field_from_json(Obj,"radsecPort",radsecPort);
field_from_json(Obj,"radsecCacerts",radsecCacerts);
field_from_json(Obj,"radsecCert",radsecCert);
field_from_json(Obj,"radsecKey",radsecKey);
field_from_json(Obj,"radsecRealms",radsecRealms);
field_from_json(Obj,"ignore",ignore);
return true;
} catch (const Poco::Exception &E) {
}

View File

@@ -38,6 +38,10 @@ namespace OpenWifi::GWObjects {
uint64_t kafkaPackets=0;
uint64_t websocketPackets=0;
std::string locale;
uint64_t started=0;
uint64_t sessionId=0;
double connectionCompletionTime=0.0;
void to_json(Poco::JSON::Object &Obj) const;
};
@@ -71,6 +75,13 @@ namespace OpenWifi::GWObjects {
void Print() const;
};
struct DeviceConnectionStatistics {
std::uint64_t connectedDevices = 0;
std::uint64_t averageConnectionTime = 0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct Statistics {
std::string SerialNumber;
uint64_t UUID = 0 ;
@@ -216,6 +227,16 @@ namespace OpenWifi::GWObjects {
std::string ip;
uint16_t port=0;
uint64_t weight=0;
std::string secret;
std::string certificate;
bool radsec=false;
uint16_t radsecPort=2083;
std::string radsecSecret;
std::string radsecKey;
std::string radsecCert;
std::vector<std::string> radsecCacerts;
std::vector<std::string> radsecRealms;
bool ignore=false;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -237,6 +258,8 @@ namespace OpenWifi::GWObjects {
std::string description;
RadiusProxyServerConfig authConfig;
RadiusProxyServerConfig acctConfig;
RadiusProxyServerConfig coaConfig;
bool useByDefault=false;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -12,6 +12,7 @@
namespace OpenWifi {
int Storage::Start() {
poco_notice(Logger(),"Starting...");
std::lock_guard Guard(Mutex_);
StorageClass::Start();
@@ -43,14 +44,14 @@ namespace OpenWifi {
uint64_t start = 0 ;
bool done = false;
const uint64_t batch=100;
Logger().information("Starting cleanup of TimePoint Database");
poco_information(Logger(),"Starting cleanup of TimePoint Database");
while(!done) {
if(!BoardsDB().GetRecords(start,batch,BoardList)) {
for(const auto &board:BoardList) {
for(const auto &venue:board.venueList) {
auto now = OpenWifi::Now();
auto lower_bound = now - venue.retention;
Logger().information(fmt::format("Removing old records for board '{}'",board.info.name));
poco_information(Logger(),fmt::format("Removing old records for board '{}'",board.info.name));
BoardsDB().DeleteRecords(fmt::format(" boardId='{}' and timestamp<{}", board.info.id, lower_bound));
}
}
@@ -60,9 +61,9 @@ namespace OpenWifi {
auto MaxDays = MicroService::instance().ConfigGetInt("wificlient.age.limit",14);
auto LowerDate = OpenWifi::Now() - (MaxDays*60*60*24);
Logger().information(fmt::format("Removing WiFi Clients history older than {} days.", MaxDays));
poco_information(Logger(),fmt::format("Removing WiFi Clients history older than {} days.", MaxDays));
StorageService()->WifiClientHistoryDB().DeleteRecords(fmt::format(" timestamp<{} ", LowerDate));
Logger().information(fmt::format("Done cleanup of databases. Next run in {} seconds.", PeriodicCleanup_));
poco_information(Logger(),fmt::format("Done cleanup of databases. Next run in {} seconds.", PeriodicCleanup_));
}
void Storage::run() {
@@ -81,11 +82,12 @@ namespace OpenWifi {
}
void Storage::Stop() {
poco_notice(Logger(),"Stopping...");
Running_=false;
Timer_.stop();
Updater_.wakeUp();
Updater_.join();
Logger().notice("Stopping.");
poco_notice(Logger(),"Stopped...");
}
}

View File

@@ -11,6 +11,7 @@
namespace OpenWifi {
int VenueCoordinator::Start() {
poco_notice(Logger(),"Starting...");
GetBoardList();
Worker_.start(*this);
@@ -26,29 +27,31 @@ namespace OpenWifi {
std::lock_guard G(Mutex_);
Utils::SetThreadName("brd-refresh");
Logger().information("Starting to reconcile board information.");
poco_information(Logger(),"Starting to reconcile board information.");
for(const auto &[board_id, watcher]:Watchers_) {
Logger().information(fmt::format("Updating: {}", board_id));
poco_information(Logger(),fmt::format("Updating: {}", board_id));
UpdateBoard(board_id);
}
Logger().information("Finished reconciling board information.");
poco_information(Logger(),"Finished reconciling board information.");
}
void VenueCoordinator::GetBoardList() {
BoardsToWatch_.clear();
auto F = [&](const AnalyticsObjects::BoardInfo &B) ->bool {
BoardsToWatch_.insert(B);
// Logger().information(fmt::format("Starting watch for {}.", B.info.name));
// poco_information(Logger(),fmt::format("Starting watch for {}.", B.info.name));
return true;
};
StorageService()->BoardsDB().Iterate(F);
}
void VenueCoordinator::Stop() {
poco_notice(Logger(),"Stopping...");
Running_=false;
Worker_.wakeUp();
Worker_.wakeUp();
Worker_.join();
poco_notice(Logger(),"Stopped...");
}
void VenueCoordinator::run() {
@@ -116,7 +119,7 @@ namespace OpenWifi {
ExistingBoards_[B.info.id] = Devices;
Watchers_[B.info.id] = std::make_shared<VenueWatcher>(B.info.id, B.venueList[0].id, Logger(), Devices);
Watchers_[B.info.id]->Start();
Logger().information(fmt::format("Started board {} for venue {}", B.info.name,B.venueList[0].id ));
poco_information(Logger(),fmt::format("Started board {} for venue {}", B.info.name,B.venueList[0].id ));
return true;
}
@@ -125,7 +128,7 @@ namespace OpenWifi {
return false;
}
Logger().information(fmt::format("Could not start board {}",B.info.name));
poco_information(Logger(),fmt::format("Could not start board {}",B.info.name));
return false;
}
@@ -154,9 +157,9 @@ namespace OpenWifi {
it2->second->ModifySerialNumbers(Devices);
}
ExistingBoards_[id] = Devices;
Logger().information(fmt::format("Modified board {}",B.info.name));
poco_information(Logger(),fmt::format("Modified board {}",B.info.name));
} else {
Logger().information(fmt::format("No device changes in board {}",B.info.name));
poco_information(Logger(),fmt::format("No device changes in board {}",B.info.name));
}
}
return;
@@ -167,7 +170,7 @@ namespace OpenWifi {
return;
}
Logger().information(fmt::format("Could not modify board {}",B.info.name));
poco_information(Logger(),fmt::format("Could not modify board {}",B.info.name));
}
}
@@ -183,7 +186,7 @@ namespace OpenWifi {
if(StorageService()->BoardsDB().GetRecord("id",id,B))
BoardsToWatch_.insert(B);
else
Logger().information(fmt::format("Board {} does not seem to exist",id));
poco_information(Logger(),fmt::format("Board {} does not seem to exist",id));
}
void VenueCoordinator::GetDevices(std::string &id, AnalyticsObjects::DeviceInfoList &DIL) {

View File

@@ -10,6 +10,7 @@
namespace OpenWifi {
void VenueWatcher::Start() {
poco_notice(Logger(),"Starting...");
for(const auto &mac:SerialNumbers_) {
auto ap = std::make_shared<AP>(mac, venue_id_, boardId_, Logger());
APs_[mac ] = ap;
@@ -24,6 +25,7 @@ namespace OpenWifi {
}
void VenueWatcher::Stop() {
poco_notice(Logger(),"Stopping...");
Running_ = false;
Queue_.wakeUpAll();
Worker_.join();
@@ -31,6 +33,7 @@ namespace OpenWifi {
StateReceiver()->DeRegister(i,this);
DeviceStatusReceiver()->DeRegister(this);
HealthReceiver()->DeRegister(this);
poco_notice(Logger(),"Stopped...");
}
void VenueWatcher::run() {

View File

@@ -10,6 +10,7 @@
namespace OpenWifi {
int WifiClientCache::Start() {
poco_notice(Logger(),"Starting...");
TimerCallback_ = std::make_unique<Poco::TimerCallback<WifiClientCache>>(*this,&WifiClientCache::onTimer);
Timer_.setStartInterval( 30 * 1000); // first run in 20 seconds
Timer_.setPeriodicInterval( 60 * 60 * 1000); // 1 hours
@@ -18,7 +19,9 @@ namespace OpenWifi {
}
void WifiClientCache::Stop() {
poco_notice(Logger(),"Stopping...");
Timer_.stop();
poco_notice(Logger(),"Stopped...");
}
void WifiClientCache::onTimer([[maybe_unused]] Poco::Timer & timer) {
@@ -124,32 +127,36 @@ namespace OpenWifi {
}
}
void WifiClientCache::FindNumbers(const std::string &venue_id, const std::string &S, uint HowMany, std::vector<uint64_t> &A) {
void WifiClientCache::FindNumbers(const std::string &venueId, const std::string &SerialNumber, std::uint64_t StartingOffset, std::uint64_t HowMany, std::vector<uint64_t> &A) {
std::lock_guard G(Mutex_);
A.clear();
auto VenueIt = Cache_.find(venue_id);
auto VenueIt = Cache_.find(venueId);
if(VenueIt==Cache_.end())
return;
if(S.empty()) {
if(SerialNumber.empty()) {
auto Start = VenueIt->second.SNs_.begin();
std::uint64_t Offset=0;
while(HowMany && Start!=VenueIt->second.SNs_.end()) {
A.push_back(*Start);
if(Offset>=StartingOffset) {
A.push_back(*Start);
HowMany--;
}
Start++;
HowMany--;
Offset++;
}
return;
}
if (S[0] == '*') {
if (SerialNumber[0] == '*') {
std::string Reversed;
std::copy(rbegin(S), rend(S)-1, std::back_inserter(Reversed));
std::copy(rbegin(SerialNumber), rend(SerialNumber)-1, std::back_inserter(Reversed));
if(Reversed.empty())
return;
return ReturnNumbers(Reversed, HowMany, VenueIt->second.Reverse_SNs_, A, true);
} else {
return ReturnNumbers(S, HowMany, VenueIt->second.SNs_, A, false);
return ReturnNumbers(SerialNumber, HowMany, VenueIt->second.SNs_, A, false);
}
}
}

View File

@@ -20,7 +20,7 @@ namespace OpenWifi {
void Stop() override;
void AddSerialNumber(const std::string &venueId, const std::string &SerialNumber);
void DeleteSerialNumber(const std::string &venueId, const std::string &SerialNumber);
void FindNumbers(const std::string &venueId, const std::string &SerialNumber, uint HowMany, std::vector<uint64_t> &A);
void FindNumbers(const std::string &venueId, const std::string &SerialNumber, std::uint64_t start, std::uint64_t HowMany, std::vector<uint64_t> &A);
inline bool NumberExists(const std::string &venueId, uint64_t SerialNumber) {
std::lock_guard G(Mutex_);
auto It = Cache_.find(venueId);

View File

@@ -44,7 +44,7 @@ static json DefaultUCentralSchema = R"(
"switch": {
"$ref": "#/$defs/switch"
},
"radios": {
"radiosgrep": {
"type": "array",
"items": {
"$ref": "#/$defs/radio"

View File

@@ -23,6 +23,13 @@
#include <queue>
#include <variant>
// This must be defined for poco_debug and poco_trace macros to function.
#ifndef POCO_LOG_DEBUG
#define POCO_LOG_DEBUG true
#endif
namespace OpenWifi {
inline uint64_t Now() { return std::time(nullptr); };
}
@@ -89,8 +96,10 @@ using namespace std::chrono_literals;
#include "Poco/NObserver.h"
#include "Poco/Net/SocketNotification.h"
#include "Poco/Base64Decoder.h"
#include "Poco/ThreadLocal.h"
#include "cppkafka/cppkafka.h"
#include "framework/MicroServiceErrorHandler.h"
#include "framework/OpenWifiTypes.h"
#include "framework/KafkaTopics.h"
#include "framework/ow_constants.h"
@@ -660,6 +669,19 @@ namespace OpenWifi::RESTAPI_utils {
namespace OpenWifi::Utils {
inline bool NormalizeMac(std::string & Mac) {
Poco::replaceInPlace(Mac,":","");
Poco::replaceInPlace(Mac,"-","");
if(Mac.size()!=12)
return false;
for(const auto &i:Mac) {
if(!std::isxdigit(i))
return false;
}
Poco::toLowerInPlace(Mac);
return true;
}
inline void SetThreadName(const char *name) {
#ifdef __linux__
Poco::Thread::current()->setName(name);
@@ -1339,36 +1361,19 @@ namespace OpenWifi {
Poco::ExpireLRUCache<KeyType,Record> Cache_{Size,Expiry};
};
class MyErrorHandler : public Poco::ErrorHandler {
public:
explicit MyErrorHandler(Poco::Util::Application &App) : App_(App) {}
inline void exception(const Poco::Exception & E) {
Poco::Thread * CurrentThread = Poco::Thread::current();
App_.logger().log(E);
App_.logger().error(fmt::format("Exception occurred in {}",CurrentThread->getName()));
}
inline void exception(const std::exception & E) {
Poco::Thread * CurrentThread = Poco::Thread::current();
App_.logger().warning(fmt::format("std::exception in {}: {}",CurrentThread->getName(),E.what()));
}
inline void exception() {
Poco::Thread * CurrentThread = Poco::Thread::current();
App_.logger().warning(fmt::format("exception in {}",CurrentThread->getName()));
}
private:
Poco::Util::Application &App_;
};
class BusEventManager : public Poco::Runnable {
public:
explicit BusEventManager(Poco::Logger &L) : Logger_(L) {
}
inline void run() final;
inline void Start();
inline void Stop();
inline Poco::Logger & Logger() { return Logger_; }
private:
mutable std::atomic_bool Running_ = false;
Poco::Thread Thread_;
Poco::Logger &Logger_;
};
class MyPrivateKeyPassphraseHandler : public Poco::Net::PrivateKeyPassphraseHandler {
@@ -1382,6 +1387,7 @@ namespace OpenWifi {
Logger_.information("Returning key passphrase.");
privateKey = Password_;
};
inline Poco::Logger & Logger() { return Logger_; }
private:
std::string Password_;
Poco::Logger & Logger_;
@@ -1650,14 +1656,14 @@ namespace OpenWifi {
class SubSystemServer : public Poco::Util::Application::Subsystem {
public:
SubSystemServer(std::string Name, const std::string &LoggingPrefix,
std::string SubSystemConfigPrefix);
SubSystemServer(const std::string & Name, const std::string &LoggingPrefix,
const std::string & SubSystemConfigPrefix);
inline void initialize(Poco::Util::Application &self) override;
inline void uninitialize() override {
}
inline void reinitialize([[maybe_unused]] Poco::Util::Application &self) override {
Logger().information("Reloading of this subsystem is not supported.");
Logger_->L_.information("Reloading of this subsystem is not supported.");
}
inline void defineOptions([[maybe_unused]] Poco::Util::OptionSet &options) override {
}
@@ -1666,30 +1672,30 @@ namespace OpenWifi {
inline const PropertiesFileServerEntry & Host(uint64_t index) { return ConfigServersList_[index]; };
inline uint64_t HostSize() const { return ConfigServersList_.size(); }
inline Poco::Logger &Logger() { if(Log_)
return Log_->L;
return Poco::Logger::get("tmp");
};
inline void SetLoggingLevel(Poco::Message::Priority NewPriority) { Logger().setLevel(NewPriority); }
inline int GetLoggingLevel() { return Logger().getLevel(); }
inline Poco::Logger & Logger() const { return Logger_->L_; }
inline void SetLoggingLevel(const std::string & levelName) {
Logger_->L_.setLevel(Poco::Logger::parseLevel(levelName));
}
inline int GetLoggingLevel() { return Logger_->L_.getLevel(); }
virtual int Start() = 0;
virtual void Stop() = 0;
struct LoggerWrapper {
Poco::Logger &L;
explicit inline LoggerWrapper(Poco::Logger &Logger) : L(Logger) {}
};
struct LoggerWrapper {
Poco::Logger & L_;
LoggerWrapper(Poco::Logger &L) :
L_(L) {}
};
protected:
std::recursive_mutex Mutex_;
std::vector<PropertiesFileServerEntry> ConfigServersList_;
private:
std::unique_ptr<LoggerWrapper> Log_;
// Poco::Logger &Logger_;
std::string Name_;
std::string LoggerPrefix_;
std::string SubSystemConfigPrefix_;
std::unique_ptr<LoggerWrapper> Logger_;
std::string Name_;
std::string LoggerPrefix_;
std::string SubSystemConfigPrefix_;
};
class RESTAPI_GenericServer {
@@ -1823,7 +1829,7 @@ namespace OpenWifi {
E->Count++;
Cache_.update(H,E);
if(E->Count > MaxCalls) {
Logger().warning(fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
poco_warning(Logger(),fmt::format("RATE-LIMIT-EXCEEDED: from '{}'", R.clientAddress().toString()));
return true;
}
return false;
@@ -2165,12 +2171,16 @@ namespace OpenWifi {
SetCommonHeaders(CloseConnection);
}
inline void BadRequest(const OpenWifi::RESTAPI::Errors::msg &E) {
inline void BadRequest(const OpenWifi::RESTAPI::Errors::msg &E, const std::string & Extra="") {
PrepareResponse(Poco::Net::HTTPResponse::HTTP_BAD_REQUEST);
Poco::JSON::Object ErrorObject;
ErrorObject.set("ErrorCode",400);
ErrorObject.set("ErrorDetails",Request->getMethod());
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
if(Extra.empty())
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
else
ErrorObject.set("ErrorDescription",fmt::format("{}: {} ({})",E.err_num,E.err_txt, Extra)) ;
std::ostream &Answer = Response->send();
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
}
@@ -2214,7 +2224,7 @@ namespace OpenWifi {
ErrorObject.set("ErrorDescription",fmt::format("{}: {}",E.err_num,E.err_txt)) ;
std::ostream &Answer = Response->send();
Poco::JSON::Stringifier::stringify(ErrorObject, Answer);
Logger_.debug(fmt::format("RES-NOTFOUND: User='{}@{}' Method='{}' Path='{}",
poco_debug(Logger_,fmt::format("RES-NOTFOUND: User='{}@{}' Method='{}' Path='{}",
UserInfo_.userinfo.email,
Utils::FormatIPv6(Request->clientAddress().toString()),
Request->getMethod(),
@@ -2783,9 +2793,11 @@ namespace OpenWifi {
inline void Stop() override {
if(KafkaEnabled_) {
poco_information(Logger(),"Stopping...");
Dispatcher_.Stop();
ProducerThr_.Stop();
ConsumerThr_.Stop();
poco_information(Logger(),"Stopped...");
return;
}
}
@@ -2863,12 +2875,13 @@ namespace OpenWifi {
}
inline void Stop() override {
poco_information(Logger(),"Stopping...");
std::lock_guard G(Mutex_);
Cache_.clear();
poco_information(Logger(),"Stopped...");
}
inline void RemovedCachedToken(const std::string &Token) {
std::lock_guard G(Mutex_);
Cache_.remove(Token);
}
@@ -2878,6 +2891,7 @@ namespace OpenWifi {
inline bool RetrieveTokenInformation(const std::string & SessionToken,
SecurityObjects::UserInfoAndPolicy & UInfo,
std::uint64_t TID,
bool & Expired, bool & Contacted, bool Sub=false) {
try {
Types::StringPairVec QueryData;
@@ -2903,7 +2917,6 @@ namespace OpenWifi {
return false;
}
Expired = false;
std::lock_guard G(Mutex_);
Cache_.update(SessionToken, UInfo);
return true;
} else {
@@ -2911,14 +2924,15 @@ namespace OpenWifi {
}
}
} catch (...) {
poco_error(Logger(),fmt::format("Failed to retrieve token={} for TID={}", SessionToken, TID));
}
Expired = false;
return false;
}
inline bool IsAuthorized(const std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo,
std::uint64_t TID,
bool & Expired, bool & Contacted, bool Sub = false) {
std::lock_guard G(Mutex_);
auto User = Cache_.get(SessionToken);
if(!User.isNull()) {
if(IsTokenExpired(User->webtoken)) {
@@ -2929,7 +2943,7 @@ namespace OpenWifi {
UInfo = *User;
return true;
}
return RetrieveTokenInformation(SessionToken, UInfo, Expired, Contacted, Sub);
return RetrieveTokenInformation(SessionToken, UInfo, TID, Expired, Contacted, Sub);
}
private:
@@ -2947,12 +2961,12 @@ namespace OpenWifi {
{
}
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
{
Utils::SetThreadName("alb-request");
try {
if((id_ % 100) == 0) {
Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.",
poco_debug(Logger_,fmt::format("ALB-REQUEST({}): ALB Request {}.",
Request.clientAddress().toString(), id_));
}
Response.setChunkedTransferEncoding(true);
@@ -3010,8 +3024,10 @@ namespace OpenWifi {
inline int Start() override;
inline void Stop() override {
poco_information(Logger(),"Stopping...");
if(Running_)
Server_->stop();
Server_->stopAll(true);
poco_information(Logger(),"Stopped...");
}
private:
@@ -3040,10 +3056,11 @@ namespace OpenWifi {
inline void Stop() override {
Logger().information("Stopping...");
for( const auto & svr : RESTServers_ )
svr->stop();
svr->stopAll(true);
Pool_.stopAll();
Pool_.joinAll();
RESTServers_.clear();
Logger().information("Stopped...");
}
@@ -3058,7 +3075,7 @@ namespace OpenWifi {
private:
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
Poco::ThreadPool Pool_{"x-rest",2,32};
Poco::ThreadPool Pool_{"x-rest",32,128};
RESTAPI_GenericServer Server_;
RESTAPI_ExtServer() noexcept:
@@ -3075,15 +3092,16 @@ namespace OpenWifi {
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
try {
Poco::URI uri(Request.getURI());
Utils::SetThreadName(fmt::format("x-rest:{}",TransactionId_).c_str());
return RESTAPI_ExtServer()->CallServer(uri.getPath(), TransactionId_++);
auto TID = NextTransactionId_++;
Utils::SetThreadName(fmt::format("x-rest:{}",TID).c_str());
return RESTAPI_ExtServer()->CallServer(uri.getPath(), TID);
} catch (...) {
}
return nullptr;
}
private:
static inline std::atomic_uint64_t TransactionId_ = 1;
static inline std::atomic_uint64_t NextTransactionId_ = 1;
};
class LogMuxer : public Poco::Channel {
@@ -3175,9 +3193,10 @@ namespace OpenWifi {
inline void Stop() override {
Logger().information("Stopping...");
for( const auto & svr : RESTServers_ )
svr->stop();
svr->stopAll(true);
Pool_.stopAll();
Pool_.joinAll();
Logger().information("Stopped...");
}
inline void reinitialize(Poco::Util::Application &self) override;
@@ -3187,11 +3206,10 @@ namespace OpenWifi {
Utils::SetThreadName(fmt::format("i-rest:{}",Id).c_str());
return RESTAPI_IntRouter(Path, Bindings, Logger(), Server_, Id);
}
const Poco::ThreadPool & Pool() { return Pool_; }
private:
std::vector<std::unique_ptr<Poco::Net::HTTPServer>> RESTServers_;
Poco::ThreadPool Pool_{"i-rest",2,16};
Poco::ThreadPool Pool_{"i-rest",32,96};
RESTAPI_GenericServer Server_;
RESTAPI_IntServer() noexcept:
@@ -3206,12 +3224,13 @@ namespace OpenWifi {
public:
inline IntRequestHandlerFactory() = default;
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
Utils::SetThreadName(fmt::format("i-rest:{}",TransactionId_).c_str());
auto TID=NextTransactionId_++;
Utils::SetThreadName(fmt::format("i-rest:{}",TID).c_str());
Poco::URI uri(Request.getURI());
return RESTAPI_IntServer()->CallServer(uri.getPath(), TransactionId_);
return RESTAPI_IntServer()->CallServer(uri.getPath(), TID);
}
private:
static inline std::atomic_uint64_t TransactionId_ = 1;
static inline std::atomic_uint64_t NextTransactionId_ = 1;
};
struct MicroServiceMeta {
@@ -3272,7 +3291,7 @@ namespace OpenWifi {
return ((RandomEngine_() % (max-min)) + min);
}
inline Poco::Logger & GetLogger(const std::string &Name) {
/* inline Poco::Logger & GetLogger(const std::string &Name) {
static auto initialized = false;
if(!initialized) {
@@ -3281,7 +3300,7 @@ namespace OpenWifi {
}
return Poco::Logger::get(Name);
}
*/
virtual void GetExtraConfiguration(Poco::JSON::Object & Cfg) {
Cfg.set("additionalConfiguration",false);
}
@@ -3374,7 +3393,6 @@ namespace OpenWifi {
std::string MyPublicEndPoint_;
std::string UIURI_;
std::string Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH };
BusEventManager BusEventManager_;
std::recursive_mutex InfraMutex_;
std::default_random_engine RandomEngine_;
Poco::Util::PropertyFileConfiguration * PropConfigurationFile_ = nullptr;
@@ -3388,7 +3406,8 @@ namespace OpenWifi {
bool NoBuiltInCrypto_=false;
Poco::JWT::Signer Signer_;
Poco::Logger &Logger_;
Poco::ThreadPool TimerPool_{"timer:pool",2,16};
Poco::ThreadPool TimerPool_{"timer:pool",2,16};
std::unique_ptr<BusEventManager> BusEventManager_;
};
inline void MicroService::Exit(int Reason) {
@@ -3469,7 +3488,7 @@ namespace OpenWifi {
}
} catch (const Poco::Exception &E) {
Logger_.log(E);
logger().log(E);
}
}
@@ -3552,7 +3571,7 @@ namespace OpenWifi {
auto LoggingDestination = MicroService::instance().ConfigGetString("logging.type", "file");
auto LoggingFormat = MicroService::instance().ConfigGetString("logging.format",
"%Y-%m-%d %H:%M:%S %s: [%p] %t");
"%Y-%m-%d %H:%M:%S.%i %s: [%p][thr:%I] %t");
if (LoggingDestination == "console") {
Poco::AutoPtr<Poco::ConsoleChannel> Console(new Poco::ConsoleChannel);
Poco::AutoPtr<Poco::AsyncChannel> Async(new Poco::AsyncChannel(Console));
@@ -3609,7 +3628,9 @@ namespace OpenWifi {
SubSystems_.push_back(ALBHealthCheckServer());
SubSystems_.push_back(RESTAPI_ExtServer());
SubSystems_.push_back(RESTAPI_IntServer());
#ifndef TIP_SECURITY_SERVICE
SubSystems_.push_back(AuthClient());
#endif
Poco::Net::initializeSSL();
Poco::Net::HTTPStreamFactory::registerFactory();
Poco::Net::HTTPSStreamFactory::registerFactory();
@@ -3720,8 +3741,9 @@ namespace OpenWifi {
}
inline void MicroService::InitializeSubSystemServers() {
for(auto i:SubSystems_)
addSubsystem(i);
for(auto i:SubSystems_) {
addSubsystem(i);
}
}
inline void MicroService::StartSubSystemServers() {
@@ -3729,12 +3751,13 @@ namespace OpenWifi {
for(auto i:SubSystems_) {
i->Start();
}
BusEventManager_.Start();
BusEventManager_ = std::make_unique<BusEventManager>(Poco::Logger::create("BusEventManager",Poco::Logger::root().getChannel(),Poco::Logger::root().getLevel()));
BusEventManager_->Start();
}
inline void MicroService::StopSubSystemServers() {
AddActivity("Stopping");
BusEventManager_.Stop();
BusEventManager_->Stop();
for(auto i=SubSystems_.rbegin(); i!=SubSystems_.rend(); ++i) {
(*i)->Stop();
}
@@ -3911,14 +3934,15 @@ namespace OpenWifi {
}
}
inline SubSystemServer::SubSystemServer(std::string Name, const std::string &LoggingPrefix,
std::string SubSystemConfigPrefix):
Name_(std::move(Name)),
LoggerPrefix_(LoggingPrefix),
SubSystemConfigPrefix_(std::move(SubSystemConfigPrefix)) {
inline SubSystemServer::SubSystemServer(const std::string &Name, const std::string &LoggingPrefix,
const std::string &SubSystemConfigPrefix):
Name_(Name),
LoggerPrefix_(LoggingPrefix),
SubSystemConfigPrefix_(SubSystemConfigPrefix) {
}
inline int RESTAPI_ExtServer::Start() {
Logger().information("Starting.");
Server_.InitLogging();
for(const auto & Svr: ConfigServersList_) {
@@ -3934,8 +3958,6 @@ namespace OpenWifi {
}
Poco::Net::HTTPServerParams::Ptr Params = new Poco::Net::HTTPServerParams;
Params->setMaxThreads(50);
Params->setMaxQueued(200);
Params->setKeepAlive(true);
Params->setName("ws:xrest");
@@ -3950,7 +3972,6 @@ namespace OpenWifi {
NewServer->start();
RESTServers_.push_back(std::move(NewServer));
}
return 0;
}
@@ -3971,8 +3992,6 @@ namespace OpenWifi {
}
auto Params = new Poco::Net::HTTPServerParams;
Params->setMaxThreads(50);
Params->setMaxQueued(200);
Params->setKeepAlive(true);
Params->setName("ws:irest");
@@ -3992,7 +4011,7 @@ namespace OpenWifi {
}
inline int MicroService::main([[maybe_unused]] const ArgVec &args) {
MyErrorHandler ErrorHandler(*this);
MicroServiceErrorHandler ErrorHandler(*this);
Poco::ErrorHandler::set(&ErrorHandler);
if (!HelpRequested_) {
@@ -4040,7 +4059,11 @@ namespace OpenWifi {
auto i = 0;
bool good = true;
Log_ = std::make_unique<LoggerWrapper>(Poco::Logger::get(LoggerPrefix_));
auto NewLevel = MicroService::instance().ConfigGetString("logging.level." + Name_, "");
if(NewLevel.empty())
Logger_ = std::make_unique<LoggerWrapper>(Poco::Logger::create(LoggerPrefix_, Poco::Logger::root().getChannel(), Poco::Logger::root().getLevel()));
else
Logger_ = std::make_unique<LoggerWrapper>(Poco::Logger::create(LoggerPrefix_, Poco::Logger::root().getChannel(), Poco::Logger::parseLevel(NewLevel)));
ConfigServersList_.clear();
while (good) {
@@ -4130,9 +4153,11 @@ namespace OpenWifi {
inline void BusEventManager::Stop() {
if(KafkaManager()->Enabled()) {
poco_information(Logger(),"Stopping...");
Running_ = false;
Thread_.wakeUp();
Thread_.join();
poco_information(Logger(),"Stopped...");
}
}
@@ -4144,37 +4169,37 @@ namespace OpenWifi {
inline void KafkaLoggerFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int level, const std::string & facility, const std::string &message) {
switch ((cppkafka::LogLevel) level) {
case cppkafka::LogLevel::LogNotice: {
KafkaManager()->Logger().notice(fmt::format("kafka-log: facility: {} message: {}",facility, message));
poco_notice(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
case cppkafka::LogLevel::LogDebug: {
KafkaManager()->Logger().debug(fmt::format("kafka-log: facility: {} message: {}",facility, message));
poco_debug(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
case cppkafka::LogLevel::LogInfo: {
KafkaManager()->Logger().information(fmt::format("kafka-log: facility: {} message: {}",facility, message));
poco_information(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
case cppkafka::LogLevel::LogWarning: {
KafkaManager()->Logger().warning(fmt::format("kafka-log: facility: {} message: {}",facility, message));
case cppkafka::LogLevel::LogWarning: {
poco_warning(KafkaManager()->Logger(), fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
case cppkafka::LogLevel::LogAlert:
case cppkafka::LogLevel::LogCrit: {
KafkaManager()->Logger().critical(fmt::format("kafka-log: facility: {} message: {}",facility, message));
poco_critical(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
case cppkafka::LogLevel::LogErr:
case cppkafka::LogLevel::LogEmerg:
default: {
KafkaManager()->Logger().error(fmt::format("kafka-log: facility: {} message: {}",facility, message));
poco_error(KafkaManager()->Logger(),fmt::format("kafka-log: facility: {} message: {}",facility, message));
}
break;
}
}
inline void KafkaErrorFun([[maybe_unused]] cppkafka::KafkaHandleBase & handle, int error, const std::string &reason) {
KafkaManager()->Logger().error(fmt::format("kafka-error: {}, reason: {}", error, reason));
poco_error(KafkaManager()->Logger(),fmt::format("kafka-error: {}, reason: {}", error, reason));
}
inline void AddKafkaSecurity(cppkafka::Configuration & Config) {
@@ -4223,11 +4248,11 @@ namespace OpenWifi {
cppkafka::MessageBuilder(Msg->Topic()).key(Msg->Key()).payload(Msg->Payload()));
}
} catch (const cppkafka::HandleException &E) {
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (producer): {}", E.what()));
poco_warning(KafkaManager()->Logger(),fmt::format("Caught a Kafka exception (producer): {}", E.what()));
} catch( const Poco::Exception &E) {
KafkaManager()->Logger().log(E);
} catch (...) {
KafkaManager()->Logger().error("std::exception");
poco_error(KafkaManager()->Logger(),"std::exception");
}
Note = Queue_.waitDequeueNotification();
}
@@ -4287,7 +4312,7 @@ namespace OpenWifi {
continue;
if (Msg.get_error()) {
if (!Msg.is_eof()) {
KafkaManager()->Logger().error(fmt::format("Error: {}", Msg.get_error().to_string()));
poco_error(KafkaManager()->Logger(),fmt::format("Error: {}", Msg.get_error().to_string()));
}
if(!AutoCommit)
Consumer.async_commit(Msg);
@@ -4298,11 +4323,11 @@ namespace OpenWifi {
Consumer.async_commit(Msg);
}
} catch (const cppkafka::HandleException &E) {
KafkaManager()->Logger().warning(fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
poco_warning(KafkaManager()->Logger(),fmt::format("Caught a Kafka exception (consumer): {}", E.what()));
} catch (const Poco::Exception &E) {
KafkaManager()->Logger().log(E);
} catch (...) {
KafkaManager()->Logger().error("std::exception");
poco_error(KafkaManager()->Logger(),"std::exception");
}
}
Consumer.unsubscribe();
@@ -4746,7 +4771,7 @@ namespace OpenWifi {
}
#ifdef TIP_SECURITY_SERVICE
[[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, bool & Expired , bool Sub );
[[nodiscard]] bool AuthServiceIsAuthorized(Poco::Net::HTTPServerRequest & Request,std::string &SessionToken, SecurityObjects::UserInfoAndPolicy & UInfo, std::uint64_t TID, bool & Expired , bool Sub );
#endif
inline bool RESTAPIHandler::IsAuthorized( bool & Expired , [[maybe_unused]] bool & Contacted , bool Sub ) {
if(Internal_ && Request->has("X-INTERNAL-NAME")) {
@@ -4754,17 +4779,20 @@ namespace OpenWifi {
Contacted = true;
if(!Allowed) {
if(Server_.LogBadTokens(false)) {
Logger_.debug(fmt::format("I-REQ-DENIED({}): Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()),
Request->getMethod(), Request->getURI()));
poco_debug(Logger_,fmt::format("I-REQ-DENIED({}): TID={} Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()),
TransactionId_,
Request->getMethod(), Request->getURI()));
}
} else {
auto Id = Request->get("X-INTERNAL-NAME", "unknown");
REST_Requester_ = Id;
if(Server_.LogIt(Request->getMethod(),true)) {
Logger_.debug(fmt::format("I-REQ-ALLOWED({}): User='{}' Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()), Id,
Request->getMethod(), Request->getURI()));
poco_debug(Logger_,fmt::format("I-REQ-ALLOWED({}): TID={} User='{}' Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()),
TransactionId_,
Id,
Request->getMethod(), Request->getURI()));
}
}
return Allowed;
@@ -4780,25 +4808,28 @@ namespace OpenWifi {
}
}
#ifdef TIP_SECURITY_SERVICE
if (AuthServiceIsAuthorized(*Request, SessionToken_, UserInfo_, Expired, Sub)) {
if (AuthServiceIsAuthorized(*Request, SessionToken_, UserInfo_, TransactionId_, Expired, Sub)) {
#else
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired, Contacted, Sub)) {
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, TransactionId_, Expired, Contacted, Sub)) {
#endif
REST_Requester_ = UserInfo_.userinfo.email;
if(Server_.LogIt(Request->getMethod(),true)) {
Logger_.debug(fmt::format("X-REQ-ALLOWED({}): User='{}@{}' Method={} Path={}",
UserInfo_.userinfo.email,
Utils::FormatIPv6(Request->clientAddress().toString()),
Request->clientAddress().toString(),
Request->getMethod(),
Request->getURI()));
poco_debug(Logger_,fmt::format("X-REQ-ALLOWED({}): TID={} User='{}@{}' Method={} Path={}",
UserInfo_.userinfo.email,
TransactionId_,
Utils::FormatIPv6(Request->clientAddress().toString()),
Request->clientAddress().toString(),
Request->getMethod(),
Request->getURI()));
}
return true;
} else {
if(Server_.LogBadTokens(true)) {
Logger_.debug(fmt::format("X-REQ-DENIED({}): Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()),
Request->getMethod(), Request->getURI()));
poco_debug(Logger_,fmt::format("X-REQ-DENIED({}): TID={} Method={} Path={}",
Utils::FormatIPv6(Request->clientAddress().toString()),
TransactionId_,
Request->getMethod(),
Request->getURI()));
}
}
return false;
@@ -4867,7 +4898,7 @@ namespace OpenWifi {
void run() override;
// MyParallelSocketReactor &ReactorPool();
Poco::Net::SocketReactor & Reactor() { return Reactor_; }
void NewClient(Poco::Net::WebSocket &WS, const std::string &Id);
void NewClient(Poco::Net::WebSocket &WS, const std::string &Id, const std::string &UserName);
bool Register(WebSocketClient *Client, const std::string &Id);
void SetProcessor(WebSocketClientProcessor *F);
void UnRegister(const std::string &Id);
@@ -4918,18 +4949,22 @@ namespace OpenWifi {
class WebSocketClient {
public:
explicit WebSocketClient(Poco::Net::WebSocket &WS, const std::string &Id, Poco::Logger &L,
WebSocketClientProcessor *Processor);
explicit WebSocketClient(Poco::Net::WebSocket &WS,
const std::string &Id,
const std::string &UserName,
Poco::Logger &L,
WebSocketClientProcessor *Processor);
virtual ~WebSocketClient();
[[nodiscard]] inline const std::string &Id();
[[nodiscard]] Poco::Logger &Logger();
inline bool Send(const std::string &Payload);
private:
std::unique_ptr<Poco::Net::WebSocket> WS_;
Poco::Net::SocketReactor &Reactor_;
std::string Id_;
Poco::Logger &Logger_;
bool Authenticated_ = false;
Poco::Net::SocketReactor &Reactor_;
std::string Id_;
std::string UserName_;
Poco::Logger &Logger_;
std::atomic_bool Authenticated_ = false;
SecurityObjects::UserInfoAndPolicy UserInfo_;
WebSocketClientProcessor *Processor_ = nullptr;
void OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf);
@@ -4937,33 +4972,9 @@ namespace OpenWifi {
void OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf);
};
/* inline MyParallelSocketReactor::MyParallelSocketReactor(uint32_t NumReactors) :
NumReactors_(NumReactors)
{
Reactors_ = new Poco::Net::SocketReactor[NumReactors_];
for(uint32_t i=0;i<NumReactors_;i++) {
ReactorPool_.start(Reactors_[i]);
}
}
inline MyParallelSocketReactor::~MyParallelSocketReactor() {
for(uint32_t i=0;i<NumReactors_;i++) {
Reactors_[i].stop();
}
ReactorPool_.stopAll();
ReactorPool_.joinAll();
delete [] Reactors_;
}
inline Poco::Net::SocketReactor & MyParallelSocketReactor::Reactor() {
return Reactors_[ rand() % NumReactors_ ];
}
// inline MyParallelSocketReactor & WebSocketClientServer::ReactorPool() { return *ReactorPool_; }
*/
inline void WebSocketClientServer::NewClient(Poco::Net::WebSocket & WS, const std::string &Id) {
inline void WebSocketClientServer::NewClient(Poco::Net::WebSocket & WS, const std::string &Id, const std::string &UserName ) {
std::lock_guard G(Mutex_);
auto Client = new WebSocketClient(WS,Id,Logger(), Processor_);
auto Client = new WebSocketClient(WS,Id,UserName,Logger(), Processor_);
Clients_[Id] = std::make_pair(Client,"");
}
@@ -5080,6 +5091,7 @@ namespace OpenWifi {
auto Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
if (n == 0) {
poco_debug(Logger(),fmt::format("CLOSE({}): {} UI Client is closing WS connection.", Id_, UserName_));
return delete this;
}
@@ -5092,7 +5104,7 @@ namespace OpenWifi {
case Poco::Net::WebSocket::FRAME_OP_PONG: {
} break;
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
Logger().warning(Poco::format("CLOSE(%s): UI Client is closing its connection.", Id_));
poco_debug(Logger(),fmt::format("CLOSE({}): {} UI Client is closing WS connection.", Id_, UserName_));
Done = true;
} break;
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
@@ -5102,8 +5114,10 @@ namespace OpenWifi {
auto Tokens = Utils::Split(Frame, ':');
bool Expired = false, Contacted = false;
if (Tokens.size() == 2 &&
AuthClient()->IsAuthorized(Tokens[1], UserInfo_, Expired, Contacted)) {
AuthClient()->IsAuthorized(Tokens[1], UserInfo_, 0, Expired, Contacted)) {
Authenticated_ = true;
UserName_ = UserInfo_.userinfo.email;
poco_debug(Logger(),fmt::format("START({}): {} UI Client is starting WS connection.", Id_, UserName_));
std::string S{"Welcome! Bienvenue! Bienvenidos!"};
WS_->sendFrame(S.c_str(), S.size());
WebSocketClientServer()->SetUser(Id_, UserInfo_.userinfo.email);
@@ -5149,9 +5163,10 @@ namespace OpenWifi {
}
inline WebSocketClient::WebSocketClient( Poco::Net::WebSocket & WS , const std::string &Id, Poco::Logger & L, WebSocketClientProcessor * Processor) :
inline WebSocketClient::WebSocketClient( Poco::Net::WebSocket & WS , const std::string &Id, const std::string &UserName, Poco::Logger & L, WebSocketClientProcessor * Processor) :
Reactor_(WebSocketClientServer()->Reactor()),
Id_(Id),
UserName_(UserName),
Logger_(L),
Processor_(Processor) {
try {
@@ -5165,7 +5180,10 @@ namespace OpenWifi {
Reactor_.addEventHandler(*WS_,
Poco::NObserver<WebSocketClient, Poco::Net::ErrorNotification>(
*this, &WebSocketClient::OnSocketError));
// WebSocketClientServer()->Register(this, Id_);
WS_->setNoDelay(true);
WS_->setKeepAlive(true);
WS_->setBlocking(false);
} catch (...) {
delete this;
}
@@ -5185,7 +5203,6 @@ namespace OpenWifi {
Poco::Net::ErrorNotification>(*this,&WebSocketClient::OnSocketError));
(*WS_).shutdown();
(*WS_).close();
WebSocketClientServer()->UnRegister(Id_);
} catch(...) {
}
@@ -5231,9 +5248,8 @@ namespace OpenWifi {
try
{
Poco::Net::WebSocket WS(*Request, *Response);
Logger().information("UI-WebSocket connection established.");
auto Id = MicroService::CreateUUID();
WebSocketClientServer()->NewClient(WS,Id);
WebSocketClientServer()->NewClient(WS,Id,UserInfo_.userinfo.email);
}
catch (...) {
std::cout << "Cannot create websocket client..." << std::endl;

View File

@@ -0,0 +1,169 @@
//
// Created by stephane bourque on 2022-09-29.
//
#pragma once
#include "fmt/format.h"
#include "Poco/Util/Application.h"
#include "Poco/ErrorHandler.h"
#include "Poco/Net/NetException.h"
#include "Poco/Net/SSLException.h"
#include "Poco/JSON/Template.h"
#include "Poco/Thread.h"
namespace OpenWifi {
class MicroServiceErrorHandler : public Poco::ErrorHandler {
public:
explicit MicroServiceErrorHandler(Poco::Util::Application &App) : App_(App) {
}
inline void exception(const Poco::Exception & Base) override {
try {
if(Poco::Thread::current()!= nullptr) {
t_name = Poco::Thread::current()->getName();
t_id = Poco::Thread::current()->id();
} else {
t_name = "startup_code";
t_id = 0;
}
App_.logger().log(Base);
Base.rethrow();
} catch (const Poco::Net::InvalidCertificateException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::InvalidCertificateException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::InvalidSocketException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::InvalidSocketException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::WebSocketException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::WebSocketException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::ConnectionResetException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::ConnectionResetException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::CertificateValidationException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::CertificateValidationException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::SSLConnectionUnexpectedlyClosedException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::SSLConnectionUnexpectedlyClosedException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::SSLContextException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::SSLContextException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::SSLException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::SSLException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::InvalidAddressException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::InvalidAddressException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Net::NetException &E) {
poco_error(App_.logger(), fmt::format("Poco::Net::NetException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::IOException &E) {
poco_error(App_.logger(), fmt::format("Poco::IOException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::RuntimeException &E) {
poco_error(App_.logger(), fmt::format("Poco::RuntimeException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::JSON::JSONTemplateException &E) {
poco_error(App_.logger(), fmt::format("Poco::JSON::JSONTemplateException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::JSON::JSONException &E) {
poco_error(App_.logger(), fmt::format("Poco::JSON::JSONException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::ApplicationException &E) {
poco_error(App_.logger(), fmt::format("Poco::ApplicationException thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (const Poco::Exception &E) {
poco_error(App_.logger(), fmt::format("Poco::Exception thr_name={} thr_id={} code={} text={} msg={} what={}",
t_name, t_id, E.code(),
E.displayText(),
E.message(),
E.what()));
} catch (...) {
poco_error(App_.logger(), fmt::format("Poco:Generic thr_name={}",t_name, t_id));
}
}
inline void exception(const std::exception & E) override {
if(Poco::Thread::current()!= nullptr) {
t_name = Poco::Thread::current()->getName();
t_id = Poco::Thread::current()->id();
} else {
t_name = "startup_code";
t_id = 0;
}
poco_warning(App_.logger(), fmt::format("std::exception in {}: {} thr_id={}",
t_name,E.what(),
t_id));
}
inline void exception() override {
if(Poco::Thread::current()!= nullptr) {
t_name = Poco::Thread::current()->getName();
t_id = Poco::Thread::current()->id();
} else {
t_name = "startup_code";
t_id = 0;
}
poco_warning(App_.logger(), fmt::format("generic exception in {} thr_id={}",
t_name, t_id));
}
private:
Poco::Util::Application &App_;
std::string t_name;
int t_id=0;
};
}

View File

@@ -33,7 +33,6 @@ namespace OpenWifi {
int Start() override {
std::lock_guard Guard(Mutex_);
Logger().setLevel(Poco::Message::PRIO_INFORMATION);
Logger().notice("Starting.");
std::string DBType = MicroService::instance().ConfigGetString("storage.type");

View File

@@ -146,6 +146,10 @@ namespace OpenWifi {
WebSocketClientServer()->SendUserNotification(User,N);
}
/////
/////
/////
struct WebSocketNotificationRebootList {
std::string title,
details,
@@ -189,5 +193,58 @@ namespace OpenWifi {
WebSocketClientServer()->SendUserNotification(User,N);
}
/////
/////
/////
struct WebSocketNotificationUpgradeList {
std::string title,
details,
jobId;
std::vector<std::string> success,
skipped,
no_firmware,
not_connected;
uint64_t timeStamp=OpenWifi::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef WebSocketNotification<WebSocketNotificationUpgradeList> WebSocketClientNotificationVenueUpgradeList_t;
inline void WebSocketNotificationUpgradeList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"title",title);
RESTAPI_utils::field_to_json(Obj,"jobId",jobId);
RESTAPI_utils::field_to_json(Obj,"success",success);
RESTAPI_utils::field_to_json(Obj,"notConnected",not_connected);
RESTAPI_utils::field_to_json(Obj,"noFirmware",no_firmware);
RESTAPI_utils::field_to_json(Obj,"skipped",skipped);
RESTAPI_utils::field_to_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_to_json(Obj,"details",details);
}
inline bool WebSocketNotificationUpgradeList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"title",title);
RESTAPI_utils::field_from_json(Obj,"jobId",jobId);
RESTAPI_utils::field_from_json(Obj,"success",success);
RESTAPI_utils::field_from_json(Obj,"notConnected",not_connected);
RESTAPI_utils::field_from_json(Obj,"noFirmware",no_firmware);
RESTAPI_utils::field_from_json(Obj,"skipped",skipped);
RESTAPI_utils::field_from_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_from_json(Obj,"details",details);
return true;
} catch(...) {
}
return false;
}
inline void WebSocketClientNotificationVenueUpgradeCompletionToUser( const std::string & User, WebSocketClientNotificationVenueUpgradeList_t &N) {
N.type = "venue_upgrader";
WebSocketClientServer()->SendUserNotification(User,N);
}
} // namespace OpenWifi

View File

@@ -196,6 +196,8 @@ namespace OpenWifi::RESTAPI::Errors {
static const struct msg InvalidRadiusServerEntry{1142,"RADIUS Server IP address invalid or port missing."};
static const struct msg InvalidRadiusServerWeigth{1143,"RADIUS Server IP weight cannot be 0."};
static const struct msg MaximumRTTYSessionsReached{1144,"Too many RTTY sessions currently active"};
static const struct msg DeviceIsAlreadyBusy{1145,"Device is already executing a command. Please try later."};
}
@@ -428,6 +430,7 @@ namespace OpenWifi::uCentralProtocol {
static const char *RADIUSDATA = "data";
static const char *RADIUSACCT = "acct";
static const char *RADIUSAUTH = "auth";
static const char *RADIUSCOA = "coa";
static const char *RADIUSDST = "dst";
static const char *IES = "ies";
}
@@ -444,6 +447,7 @@ namespace OpenWifi::uCentralProtocol::Events {
static const char *RECOVERY = "recovery";
static const char *TELEMETRY = "telemetry";
static const char *DEVICEUPDATE = "deviceupdate";
static const char *VENUE_BROADCAST = "venue_broadcast";
enum EVENT_MSG {
ET_UNKNOWN,
@@ -456,7 +460,8 @@ namespace OpenWifi::uCentralProtocol::Events {
ET_CFGPENDING,
ET_RECOVERY,
ET_DEVICEUPDATE,
ET_TELEMETRY
ET_TELEMETRY,
ET_VENUEBROADCAST
};
inline EVENT_MSG EventFromString(const std::string & Method) {
@@ -480,6 +485,8 @@ namespace OpenWifi::uCentralProtocol::Events {
return ET_RECOVERY;
else if(strcmp(TELEMETRY,Method.c_str())==0)
return ET_TELEMETRY;
else if(strcmp(VENUE_BROADCAST,Method.c_str())==0)
return ET_VENUEBROADCAST;
return ET_UNKNOWN;
};
}

7552
src/last_stats_2.json Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

7554
stats_sample/last_stats.json Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -144,25 +144,9 @@ logout() {
rm -rf token.json
}
venuecount() {
curl ${FLAGS} "https://${OWPROV}/api/v1/venue?countOnly=true" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "accept: application/json" > ${result_file}
jq < ${result_file}
}
contactcount() {
curl ${FLAGS} "https://${OWPROV}/api/v1/contact?countOnly=true" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
-H "Accept: application/json" > ${result_file}
jq < ${result_file}
}
setloglevel() {
payload="{ \"command\" : \"setloglevel\" , \"subsystems\" : [ { \"tag\" : \"$1\" , \"value\" : \"$2\" } ] }"
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWANALYTICS}/api/v1/system" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -171,7 +155,7 @@ setloglevel() {
getloglevels() {
payload="{ \"command\" : \"getloglevels\" }"
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWANALYTICS}/api/v1/system" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -180,7 +164,7 @@ getloglevels() {
getloglevelnames() {
payload="{ \"command\" : \"getloglevelnames\" }"
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWANALYTICS}/api/v1/system" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -189,7 +173,7 @@ getloglevelnames() {
getsubsystemnames() {
payload="{ \"command\" : \"getsubsystemnames\" }"
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWANALYTICS}/api/v1/system" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -197,7 +181,7 @@ getsubsystemnames() {
}
systeminfo() {
curl ${FLAGS} -X GET "https://${OWPROV}/api/v1/system?command=info" \
curl ${FLAGS} -X GET "https://${OWANALYTICS}/api/v1/system?command=info" \
-H "Accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -205,7 +189,7 @@ systeminfo() {
reloadsubsystem() {
payload="{ \"command\" : \"reload\", \"subsystems\" : [ \"$1\" ] }"
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWANALYTICS}/api/v1/system" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \

View File

@@ -1 +0,0 @@
{"children":[{"children":[{"children":[{"children":[],"name":"Ottawa Operations","type":"entity","uuid":"323054d0-3ff0-11ec-82ff-061b87871e04","venues":[{"children":[],"name":"Living Lab","type":"venue","uuid":"4159ea84-3ff0-11ec-9edb-061b87871e04"}]}],"name":"Ontario","type":"entity","uuid":"21dfa464-3ff0-11ec-9a86-061b87871e04","venues":[]},{"children":[{"children":[],"name":"Quebec","type":"entity","uuid":"27b74e1b-52d7-4414-a1b4-47574c799beb","venues":[]},{"children":[],"name":"Ontario","type":"entity","uuid":"3cb15a80-3550-11ec-9a22-061b87871e04","venues":[{"children":[],"name":"CN Tower","type":"venue","uuid":"3cb28f0e-3550-11ec-acfa-061b87871e04"},{"children":[],"name":"Rogers Center","type":"venue","uuid":"3cb3c798-3550-11ec-8c1a-061b87871e04"}]},{"children":[],"name":"BC","type":"entity","uuid":"3cb503c4-3550-11ec-b436-061b87871e04","venues":[{"children":[],"name":"BC Place","type":"venue","uuid":"3cb76452-3550-11ec-a5ab-061b87871e04"},{"children":[],"name":"Stanley Park","type":"venue","uuid":"3cb8b230-3550-11ec-bbe6-061b87871e04"},{"children":[],"name":"MegaLab","type":"venue","uuid":"a73a23c4-6f3d-4031-bc92-d28c205f2d85"},{"children":[],"name":"Bowen Development","type":"venue","uuid":"d656500b-9f00-4c09-9096-e209085c2a3e"}]}],"name":"Provinces","type":"entity","uuid":"3cac92ca-3550-11ec-b360-061b87871e04","venues":[]}],"name":"Canada","type":"entity","uuid":"3cab2c32-3550-11ec-8a03-061b87871e04","venues":[]},{"children":[],"name":"USA","type":"entity","uuid":"6392c6b3-ef48-4b81-8785-1b5b4888bbd2","venues":[]},{"children":[{"children":[],"name":"Hamburg","type":"entity","uuid":"5939f995-e059-439d-ab0c-29a6f7c0a495","venues":[]}],"name":"Germany","type":"entity","uuid":"6fb5662d-dc48-4fbd-b8f9-69d0308bb902","venues":[]},{"children":[],"name":"Test Land","type":"entity","uuid":"70161a6f-98af-45d7-b0ed-e6b15ba5d84e","venues":[{"children":[],"name":"Test","type":"venue","uuid":"1d06b289-449e-4669-abc9-1f2dcdd1fbbc"}]}],"name":"World","type":"entity","uuid":"0000-0000-0000","venues":[]}

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# wait-for-postgres.sh
set -e
@@ -20,7 +20,7 @@ if [ "$1" = '/openwifi/owanalytics' -a "$(id -u)" = '0' ]; then
if [ "$RUN_CHOWN" = 'true' ]; then
chown -R "$OWANALYTICS_USER": "$OWANALYTICS_ROOT" "$OWANALYTICS_CONFIG"
fi
exec su-exec "$OWANALYTICS_USER" "$@"
exec gosu "$OWANALYTICS_USER" "$@"
fi
exec "$@"