mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralgw.git
synced 2025-12-24 14:27:00 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7766fe08cd |
34
.github/workflows/ci.yml
vendored
34
.github/workflows/ci.yml
vendored
@@ -39,16 +39,6 @@ jobs:
|
||||
registry_user: ucentral
|
||||
registry_password: ${{ secrets.DOCKER_REGISTRY_PASSWORD }}
|
||||
|
||||
- name: Notify on failure via Slack
|
||||
if: failure() && github.ref == 'refs/heads/master'
|
||||
uses: rtCamp/action-slack-notify@v2
|
||||
env:
|
||||
SLACK_USERNAME: GitHub Actions failure notifier
|
||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
|
||||
SLACK_COLOR: "${{ job.status }}"
|
||||
SLACK_ICON: https://raw.githubusercontent.com/quintessence/slack-icons/master/images/github-logo-slack-icon.png
|
||||
SLACK_TITLE: Docker build failed for OWGW service
|
||||
|
||||
trigger-testing:
|
||||
if: startsWith(github.ref, 'refs/pull/')
|
||||
runs-on: ubuntu-latest
|
||||
@@ -75,26 +65,4 @@ jobs:
|
||||
workflow: ow_docker-compose.yml
|
||||
token: ${{ secrets.WLAN_TESTING_PAT }}
|
||||
ref: master
|
||||
inputs: '{"deployment_version": "${{ env.BASE_BRANCH }}", "owgw_version": "${{ github.sha }}", "owsec_version": "${{ env.BASE_BRANCH }}", "owfms_version": "${{ env.BASE_BRANCH }}", "owprov_version": "${{ env.BASE_BRANCH }}", "owanalytics_version": "${{ env.BASE_BRANCH }}", "owsub_version": "${{ env.BASE_BRANCH }}", "microservice": "owgw"}'
|
||||
|
||||
trigger-deploy-to-dev:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/master'
|
||||
needs:
|
||||
- docker
|
||||
steps:
|
||||
- name: Checkout actions repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: Telecominfraproject/.github
|
||||
path: github
|
||||
|
||||
- name: Trigger deployment of the latest version to dev instance and wait for result
|
||||
uses: ./github/composite-actions/trigger-workflow-and-wait
|
||||
with:
|
||||
owner: Telecominfraproject
|
||||
repo: wlan-testing
|
||||
workflow: ucentralgw-dev-deployment.yaml
|
||||
token: ${{ secrets.WLAN_TESTING_PAT }}
|
||||
ref: master
|
||||
inputs: '{"force_latest": "true"}'
|
||||
inputs: '{"owgw_version": "${{ github.sha }}", "owgwui_version": "${{ env.BASE_BRANCH }}", "owsec_version": "${{ env.BASE_BRANCH }}", "owfms_version": "${{ env.BASE_BRANCH }}", "owprov_version": "main", "owprovui_version": "main"}'
|
||||
|
||||
46
.github/workflows/release.yml
vendored
46
.github/workflows/release.yml
vendored
@@ -1,46 +0,0 @@
|
||||
name: Release chart package
|
||||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- 'v*'
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: bash
|
||||
|
||||
jobs:
|
||||
helm-package:
|
||||
runs-on: ubuntu-20.04
|
||||
env:
|
||||
HELM_REPO_URL: https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral-helm/
|
||||
HELM_REPO_USERNAME: ucentral
|
||||
steps:
|
||||
- name: Checkout uCentral assembly chart repo
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: wlan-cloud-ucentralgw
|
||||
|
||||
- name: Build package
|
||||
working-directory: wlan-cloud-ucentralgw/chart
|
||||
run: |
|
||||
helm plugin install https://github.com/aslafy-z/helm-git --version 0.10.0
|
||||
helm repo add bitnami https://charts.bitnami.com/bitnami
|
||||
helm repo update
|
||||
helm dependency update
|
||||
mkdir dist
|
||||
helm package . -d dist
|
||||
|
||||
- name: Generate GitHub release body
|
||||
working-directory: wlan-cloud-ucentralgw/chart
|
||||
run: |
|
||||
pip3 install yq -q
|
||||
echo "Docker image - tip-tip-wlan-cloud-ucentral.jfrog.io/owgw:$GITHUB_REF_NAME" > release.txt
|
||||
echo "Helm charted may be attached to this release" >> release.txt
|
||||
echo "Deployment artifacts may be found in https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/$GITHUB_REF_NAME" >> release.txt
|
||||
|
||||
- name: Create GitHub release
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
body_path: wlan-cloud-ucentralgw/chart/release.txt
|
||||
files: wlan-cloud-ucentralgw/chart/dist/*
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(owgw VERSION 2.6.0)
|
||||
project(owgw VERSION 2.5.0)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
@@ -44,9 +44,12 @@ endif()
|
||||
|
||||
add_definitions(-DTIP_GATEWAY_SERVICE="1")
|
||||
|
||||
set(Boost_USE_STATIC_LIBS OFF)
|
||||
set(Boost_USE_MULTITHREADED ON)
|
||||
set(Boost_USE_STATIC_RUNTIME OFF)
|
||||
find_package(Boost REQUIRED system)
|
||||
find_package(OpenSSL REQUIRED)
|
||||
find_package(ZLIB REQUIRED)
|
||||
find_package(fmt REQUIRED)
|
||||
find_package(nlohmann_json REQUIRED)
|
||||
find_package(nlohmann_json_schema_validator REQUIRED)
|
||||
|
||||
@@ -63,12 +66,6 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu
|
||||
|
||||
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
||||
|
||||
add_compile_options(-Wall -Wextra)
|
||||
if(ASAN)
|
||||
add_compile_options(-fsanitize=address)
|
||||
add_link_options(-fsanitize=address)
|
||||
endif()
|
||||
|
||||
add_executable( owgw
|
||||
build
|
||||
src/ow_version.h.in
|
||||
@@ -77,7 +74,10 @@ add_executable( owgw
|
||||
src/framework/MicroService.h
|
||||
src/framework/OpenWifiTypes.h
|
||||
src/framework/orm.h
|
||||
src/framework/RESTAPI_errors.h
|
||||
src/framework/RESTAPI_protocol.h
|
||||
src/framework/StorageClass.h
|
||||
src/framework/uCentral_Protocol.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
|
||||
@@ -117,7 +117,7 @@ add_executable( owgw
|
||||
src/TelemetryStream.cpp src/TelemetryStream.h
|
||||
src/framework/ConfigurationValidator.cpp src/framework/ConfigurationValidator.h
|
||||
src/ConfigurationCache.h
|
||||
src/CapabilitiesCache.h src/FindCountry.h src/rttys/RTTYS_server.cpp src/rttys/RTTYS_server.h src/rttys/RTTYS_device.cpp src/rttys/RTTYS_device.h src/rttys/RTTYS_ClientConnection.cpp src/rttys/RTTYS_ClientConnection.h src/rttys/RTTYS_WebServer.cpp src/rttys/RTTYS_WebServer.h src/RESTAPI/RESTAPI_device_helper.h src/SDKcalls.cpp src/SDKcalls.h src/StateUtils.cpp src/StateUtils.h src/WS_ReactorPool.h src/WS_Connection.h src/WS_Connection.cpp src/TelemetryClient.h src/TelemetryClient.cpp src/RESTAPI/RESTAPI_iptocountry_handler.cpp src/RESTAPI/RESTAPI_iptocountry_handler.h src/framework/ow_constants.h)
|
||||
src/CapabilitiesCache.h src/FindCountry.h src/rttys/RTTYS_server.cpp src/rttys/RTTYS_server.h src/rttys/RTTYS_device.cpp src/rttys/RTTYS_device.h src/rttys/RTTYS_ClientConnection.cpp src/rttys/RTTYS_ClientConnection.h src/rttys/RTTYS_WebServer.cpp src/rttys/RTTYS_WebServer.h src/RESTAPI/RESTAPI_device_helper.h src/SDKcalls.cpp src/SDKcalls.h src/StateUtils.cpp src/StateUtils.h src/WS_ReactorPool.h src/WS_Connection.h src/WS_Connection.cpp src/TelemetryClient.h src/TelemetryClient.cpp src/RESTAPI/RESTAPI_iptocountry_handler.cpp src/RESTAPI/RESTAPI_iptocountry_handler.h)
|
||||
|
||||
if(NOT SMALL_BUILD)
|
||||
|
||||
@@ -128,15 +128,12 @@ INSTALL(TARGETS owgw
|
||||
)
|
||||
|
||||
target_link_libraries(owgw PUBLIC
|
||||
${Poco_LIBRARIES}
|
||||
${ZLIB_LIBRARIES})
|
||||
|
||||
${Poco_LIBRARIES} ${Boost_LIBRARIES} ${ZLIB_LIBRARIES})
|
||||
if(NOT SMALL_BUILD)
|
||||
target_link_libraries(owgw PUBLIC
|
||||
${MySQL_LIBRARIES} ${ZLIB_LIBRARIES}
|
||||
CppKafka::cppkafka
|
||||
nlohmann_json_schema_validator
|
||||
fmt::fmt
|
||||
)
|
||||
if(UNIX AND NOT APPLE)
|
||||
target_link_libraries(owgw PUBLIC PocoJSON)
|
||||
|
||||
15
Dockerfile
15
Dockerfile
@@ -18,18 +18,6 @@ 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/heads/master version.json
|
||||
RUN git clone https://github.com/fmtlib/fmt /fmtlib
|
||||
|
||||
WORKDIR /fmtlib
|
||||
RUN mkdir cmake-build
|
||||
WORKDIR cmake-build
|
||||
RUN cmake ..
|
||||
RUN make
|
||||
RUN make install
|
||||
|
||||
FROM build-base AS cppkafka-build
|
||||
|
||||
ADD https://api.github.com/repos/stephb9959/cppkafka/git/refs/heads/master version.json
|
||||
@@ -67,8 +55,6 @@ COPY --from=cppkafka-build /usr/local/include /usr/local/include
|
||||
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
|
||||
COPY --from=json-schema-validator-build /usr/local/include /usr/local/include
|
||||
COPY --from=json-schema-validator-build /usr/local/lib /usr/local/lib
|
||||
COPY --from=fmtlib-build /usr/local/include /usr/local/include
|
||||
COPY --from=fmtlib-build /usr/local/lib /usr/local/lib
|
||||
|
||||
WORKDIR /owgw
|
||||
RUN mkdir cmake-build
|
||||
@@ -98,7 +84,6 @@ COPY test_scripts/curl/cli /cli
|
||||
COPY owgw.properties.tmpl /
|
||||
COPY docker-entrypoint.sh /
|
||||
COPY wait-for-postgres.sh /
|
||||
COPY rtty_ui /dist/rtty_ui
|
||||
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
|
||||
|
||||
|
||||
@@ -446,7 +446,6 @@ Controller sends this command when it needs the device to perform a WiFi Scan.
|
||||
"bands" : [ "2","5","5l","5u",6" ], <optional this is a list of bands to scan: on or more bands >
|
||||
"channels" : [ 1,2,3...] , <optional list of discreet channels to scan >
|
||||
"verbose" : <optional boolean: true or false> (by default false),
|
||||
"bandwidth" : <optional int: 20,40,80 in MHz>
|
||||
"active" : 0 or 1 (to select passive or active scan)
|
||||
},
|
||||
"id" : <some number>
|
||||
|
||||
BIN
cmake-build-debug/ucentralgw
Executable file
BIN
cmake-build-debug/ucentralgw
Executable file
Binary file not shown.
637
cmake-build-debug/ucentralgw.cbp
Normal file
637
cmake-build-debug/ucentralgw.cbp
Normal file
@@ -0,0 +1,637 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<CodeBlocks_project_file>
|
||||
<FileVersion major="1" minor="6"/>
|
||||
<Project>
|
||||
<Option title="ucentralgw"/>
|
||||
<Option makefile_is_custom="1"/>
|
||||
<Option compiler="gcc"/>
|
||||
<Option virtualFolders="CMake Files\;CMake Files\..\;CMake Files\..\..\;CMake Files\..\..\..\;CMake Files\..\..\..\..\;CMake Files\..\..\..\..\..\;CMake Files\..\..\..\..\..\..\;CMake Files\..\..\..\..\..\..\usr\;CMake Files\..\..\..\..\..\..\usr\local\;CMake Files\..\..\..\..\..\..\usr\local\lib\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Boost-1.75.0\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_headers-1.75.0\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\CppKafka\;CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\;CMake Files\cmake\;CMake Files\cmake-build-debug\;"/>
|
||||
<Build>
|
||||
<Target title="all">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 all"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="install/local">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 install/local"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="rebuild_cache">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 rebuild_cache"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="edit_cache">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 edit_cache"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="install/strip">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 install/strip"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="install">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 install"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="list_install_components">
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option type="4"/>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 list_install_components"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="ucentralgw">
|
||||
<Option output="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/ucentralgw" prefix_auto="0" extension_auto="0"/>
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option object_output="./"/>
|
||||
<Option type="1"/>
|
||||
<Option compiler="gcc"/>
|
||||
<Compiler>
|
||||
<Add option="-DAPP_VERSION="0.7.0""/>
|
||||
<Add option="-DBUILD_NUMBER="120""/>
|
||||
<Add option="-DTIP_GATEWAY_SERVICE="1""/>
|
||||
<Add option="-D_DEBUG"/>
|
||||
<Add option="-DPOCO_ENABLE_CPP14"/>
|
||||
<Add option="-DPOCO_ENABLE_CPP11"/>
|
||||
<Add option="-DPOCO_OS_FAMILY_UNIX"/>
|
||||
<Add option="-DPOCO_HAVE_IPv6"/>
|
||||
<Add option="-DPOCO_NO_STAT64"/>
|
||||
<Add option="-DXML_DTD"/>
|
||||
<Add option="-DTHREADSAFE"/>
|
||||
<Add option="-DNO_TCL"/>
|
||||
<Add option="-DBOOST_ALL_NO_LIB"/>
|
||||
<Add directory="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src"/>
|
||||
<Add directory="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/include/kafka"/>
|
||||
<Add directory="/usr/local/opt/mysql-client/include"/>
|
||||
<Add directory="/usr/local/include"/>
|
||||
<Add directory="/usr/local/opt/openssl/include"/>
|
||||
<Add directory="/usr/local/opt/mysql-client/include/mysql"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"/>
|
||||
<Add directory="/System/Library/Frameworks"/>
|
||||
<Add directory="/Library/Frameworks"/>
|
||||
</Compiler>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 ucentralgw"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
<Target title="ucentralgw/fast">
|
||||
<Option output="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/ucentralgw" prefix_auto="0" extension_auto="0"/>
|
||||
<Option working_dir="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug"/>
|
||||
<Option object_output="./"/>
|
||||
<Option type="1"/>
|
||||
<Option compiler="gcc"/>
|
||||
<Compiler>
|
||||
<Add option="-DAPP_VERSION="0.7.0""/>
|
||||
<Add option="-DBUILD_NUMBER="120""/>
|
||||
<Add option="-DTIP_GATEWAY_SERVICE="1""/>
|
||||
<Add option="-D_DEBUG"/>
|
||||
<Add option="-DPOCO_ENABLE_CPP14"/>
|
||||
<Add option="-DPOCO_ENABLE_CPP11"/>
|
||||
<Add option="-DPOCO_OS_FAMILY_UNIX"/>
|
||||
<Add option="-DPOCO_HAVE_IPv6"/>
|
||||
<Add option="-DPOCO_NO_STAT64"/>
|
||||
<Add option="-DXML_DTD"/>
|
||||
<Add option="-DTHREADSAFE"/>
|
||||
<Add option="-DNO_TCL"/>
|
||||
<Add option="-DBOOST_ALL_NO_LIB"/>
|
||||
<Add directory="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src"/>
|
||||
<Add directory="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/include/kafka"/>
|
||||
<Add directory="/usr/local/opt/mysql-client/include"/>
|
||||
<Add directory="/usr/local/include"/>
|
||||
<Add directory="/usr/local/opt/openssl/include"/>
|
||||
<Add directory="/usr/local/opt/mysql-client/include/mysql"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.5/include"/>
|
||||
<Add directory="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include"/>
|
||||
<Add directory="/System/Library/Frameworks"/>
|
||||
<Add directory="/Library/Frameworks"/>
|
||||
</Compiler>
|
||||
<MakeCommands>
|
||||
<Build command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 ucentralgw/fast"/>
|
||||
<CompileFile command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 "$file""/>
|
||||
<Clean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
<DistClean command="/usr/local/bin/gmake -j16 -f "/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/Makefile" VERBOSE=1 clean"/>
|
||||
</MakeCommands>
|
||||
</Target>
|
||||
</Build>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/build">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/ALBHealthCheckServer.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/AuthClient.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/AuthClient.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CentralConfig.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CentralConfig.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CommandChannel.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CommandChannel.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CommandManager.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/CommandManager.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/Daemon.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/Daemon.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/DeviceRegistry.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/DeviceRegistry.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/FileUploader.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/FileUploader.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/KafkaManager.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/KafkaManager.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/Kafka_topics.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/MicroService.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/MicroService.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/OUIServer.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/OUIServer.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/OpenAPIRequest.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/OpenAPIRequest.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_BlackList.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_BlackList.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_GWobjects.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_GWobjects.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_InternalServer.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_InternalServer.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_RPC.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_RPC.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_SecurityObjects.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_SecurityObjects.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_command.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_command.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_commands.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_commands.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_default_configuration.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_default_configuration.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_default_configurations.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_default_configurations.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_device_commandHandler.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_device_commandHandler.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_device_handler.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_device_handler.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_devices_handler.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_devices_handler.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_file.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_file.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_handler.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_handler.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_ouis.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_ouis.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_protocol.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_server.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_server.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_system_command.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_system_command.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_utils.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/RESTAPI_utils.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StateProcessor.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StateProcessor.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StorageArchiver.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StorageArchiver.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StorageService.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/StorageService.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/SubSystemServer.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/SubSystemServer.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/Utils.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/Utils.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/WebSocketServer.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/WebSocketServer.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_blacklist.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_capabilities.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_command.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_defconfig.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_device.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_healthcheck.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_lifetime_stats.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_logs.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_mysql.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_pgql.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_sqlite.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_statistics.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/storage_tables.cpp">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/uCentralProtocol.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/src/uCentralTypes.h">
|
||||
<Option target="ucentralgw"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/CMakeLists.txt">
|
||||
<Option virtualFolder="CMake Files\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/BoostDetectToolset-1.75.0.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Boost-1.75.0/BoostConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Boost-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Boost-1.75.0/BoostConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Boost-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_headers-1.75.0/boost_headers-config-version.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_headers-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_headers-1.75.0/boost_headers-config.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_headers-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/boost_system-config-version.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/boost_system-config.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/libboost_system-variant-mt-shared.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/libboost_system-variant-mt-static.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/libboost_system-variant-shared.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/boost_system-1.75.0/libboost_system-variant-static.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\boost_system-1.75.0\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/CppKafka/CppKafkaConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\CppKafka\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/CppKafka/CppKafkaConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\CppKafka\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/CppKafka/CppKafkaTargets-noconfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\CppKafka\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/CppKafka/CppKafkaTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\CppKafka\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoCryptoConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoCryptoConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoCryptoTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoCryptoTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataMySQLConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataMySQLConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataMySQLTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataMySQLTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataPostgreSQLConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataPostgreSQLConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataPostgreSQLTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataPostgreSQLTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataSQLiteConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataSQLiteConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataSQLiteTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataSQLiteTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoDataTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoFoundationConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoFoundationConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoFoundationTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoFoundationTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJSONConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJSONConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJSONTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJSONTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJWTConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJWTConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJWTTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoJWTTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetSSLConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetSSLConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetSSLTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetSSLTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoNetTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoUtilConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoUtilConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoUtilTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoUtilTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoXMLConfig.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoXMLConfigVersion.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoXMLTargets-relwithdebinfo.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/../../../../../../usr/local/lib/cmake/Poco/PocoXMLTargets.cmake">
|
||||
<Option virtualFolder="CMake Files\..\..\..\..\..\..\usr\local\lib\cmake\Poco\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake/FindMySQL.cmake">
|
||||
<Option virtualFolder="CMake Files\cmake\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake/FindPostgreSQL.cmake">
|
||||
<Option virtualFolder="CMake Files\cmake\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake/FindRdKafka.cmake">
|
||||
<Option virtualFolder="CMake Files\cmake\"/>
|
||||
</Unit>
|
||||
<Unit filename="/Users/stephb/Desktop/Dropbox/clion/wlan-cloud-ucentralgw/cmake-build-debug/rdkafka_version_test.cpp">
|
||||
<Option virtualFolder="CMake Files\cmake-build-debug\"/>
|
||||
</Unit>
|
||||
</Project>
|
||||
</CodeBlocks_project_file>
|
||||
@@ -6,85 +6,64 @@ if [ "$SELFSIGNED_CERTS" = 'true' ]; then
|
||||
fi
|
||||
|
||||
if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWGW_CONFIG"/owgw.properties ]]; then
|
||||
WEBSOCKET_HOST_ROOTCA=${WEBSOCKET_HOST_ROOTCA:-"\$OWGW_ROOT/certs/root.pem"} \
|
||||
WEBSOCKET_HOST_ISSUER=${WEBSOCKET_HOST_ISSUER:-"\$OWGW_ROOT/certs/issuer.pem"} \
|
||||
WEBSOCKET_HOST_CERT=${WEBSOCKET_HOST_CERT:-"\$OWGW_ROOT/certs/websocket-cert.pem"} \
|
||||
WEBSOCKET_HOST_KEY=${WEBSOCKET_HOST_KEY:-"\$OWGW_ROOT/certs/websocket-key.pem"} \
|
||||
WEBSOCKET_HOST_CLIENTCAS=${WEBSOCKET_HOST_CLIENTCAS:-"\$OWGW_ROOT/certs/clientcas.pem"} \
|
||||
WEBSOCKET_HOST_CAS=${WEBSOCKET_HOST_CAS:-"\$OWGW_ROOT/certs/cas"} \
|
||||
WEBSOCKET_HOST_PORT=${WEBSOCKET_HOST_PORT:-"15002"} \
|
||||
WEBSOCKET_HOST_KEY_PASSWORD=${WEBSOCKET_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16002"} \
|
||||
RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
RESTAPI_HOST_KEY=${RESTAPI_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
RESTAPI_HOST_KEY_PASSWORD=${RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
INTERNAL_RESTAPI_HOST_ROOTCA=${INTERNAL_RESTAPI_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_PORT=${INTERNAL_RESTAPI_HOST_PORT:-"17002"} \
|
||||
INTERNAL_RESTAPI_HOST_CERT=${INTERNAL_RESTAPI_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_KEY=${INTERNAL_RESTAPI_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_KEY_PASSWORD=${INTERNAL_RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
FILEUPLOADER_HOST_ROOTCA=${FILEUPLOADER_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
FILEUPLOADER_HOST_NAME=${FILEUPLOADER_HOST_NAME:-"localhost"} \
|
||||
FILEUPLOADER_HOST_PORT=${FILEUPLOADER_HOST_PORT:-"16003"} \
|
||||
FILEUPLOADER_HOST_CERT=${FILEUPLOADER_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
FILEUPLOADER_HOST_KEY=${FILEUPLOADER_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
FILEUPLOADER_HOST_KEY_PASSWORD=${FILEUPLOADER_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
FILEUPLOADER_PATH=${FILEUPLOADER_PATH:-"\$OWGW_ROOT/uploads"} \
|
||||
FILEUPLOADER_URI=${FILEUPLOADER_URI:-"https://localhost:16003"} \
|
||||
SERVICE_KEY=${SERVICE_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
SERVICE_KEY_PASSWORD=${SERVICE_KEY_PASSWORD:-"mypassword"} \
|
||||
SYSTEM_DATA=${SYSTEM_DATA:-"\$OWGW_ROOT/data"} \
|
||||
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17002"} \
|
||||
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16002"} \
|
||||
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
|
||||
SIMULATORID=${SIMULATORID:-""} \
|
||||
RTTY_INTERNAL=${RTTY_INTERNAL:-"true"} \
|
||||
RTTY_ENABLED=${RTTY_ENABLED:-"true"} \
|
||||
RTTY_SERVER=${RTTY_SERVER:-"localhost"} \
|
||||
RTTY_PORT=${RTTY_PORT:-"5912"} \
|
||||
RTTY_TOKEN=${RTTY_TOKEN:-""} \
|
||||
RTTY_TIMEOUT=${RTTY_TIMEOUT:-"60"} \
|
||||
RTTY_VIEWPORT=${RTTY_VIEWPORT:-"5913"} \
|
||||
RTTY_ASSETS=${RTTY_ASSETS:-"\$OWGW_ROOT/rtty_ui"} \
|
||||
KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \
|
||||
KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \
|
||||
KAFKA_SSL_CA_LOCATION=${KAFKA_SSL_CA_LOCATION:-""} \
|
||||
KAFKA_SSL_CERTIFICATE_LOCATION=${KAFKA_SSL_CERTIFICATE_LOCATION:-""} \
|
||||
KAFKA_SSL_KEY_LOCATION=${KAFKA_SSL_KEY_LOCATION:-""} \
|
||||
KAFKA_SSL_KEY_PASSWORD=${KAFKA_SSL_KEY_PASSWORD:-""} \
|
||||
STORAGE_TYPE=${STORAGE_TYPE:-"sqlite"} \
|
||||
STORAGE_TYPE_POSTGRESQL_HOST=${STORAGE_TYPE_POSTGRESQL_HOST:-"localhost"} \
|
||||
STORAGE_TYPE_POSTGRESQL_USERNAME=${STORAGE_TYPE_POSTGRESQL_USERNAME:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_PASSWORD=${STORAGE_TYPE_POSTGRESQL_PASSWORD:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_DATABASE=${STORAGE_TYPE_POSTGRESQL_DATABASE:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_PORT=${STORAGE_TYPE_POSTGRESQL_PORT:-"5432"} \
|
||||
STORAGE_TYPE_MYSQL_HOST=${STORAGE_TYPE_MYSQL_HOST:-"localhost"} \
|
||||
STORAGE_TYPE_MYSQL_USERNAME=${STORAGE_TYPE_MYSQL_USERNAME:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_PASSWORD=${STORAGE_TYPE_MYSQL_PASSWORD:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_DATABASE=${STORAGE_TYPE_MYSQL_DATABASE:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \
|
||||
envsubst < /owgw.properties.tmpl > $OWGW_CONFIG/owgw.properties
|
||||
fi
|
||||
|
||||
# Check if rtty_ui directory exists
|
||||
export RTTY_ASSETS=$(grep 'rtty.assets' $OWGW_CONFIG/owgw.properties | awk -F '=' '{print $2}' | xargs | envsubst)
|
||||
|
||||
if [ -z "$RTTY_ASSETS" ]; then
|
||||
export RTTY_ASSETS="$OWGW_ROOT/rtty_ui"
|
||||
fi
|
||||
|
||||
if [[ ! -d "$(dirname $RTTY_ASSETS)" ]]; then
|
||||
mkdir -p $(dirname $RTTY_ASSETS)
|
||||
fi
|
||||
|
||||
if [[ ! -d "$RTTY_ASSETS" ]]; then
|
||||
cp -r /dist/rtty_ui $RTTY_ASSETS
|
||||
WEBSOCKET_HOST_ROOTCA=${WEBSOCKET_HOST_ROOTCA:-"\$OWGW_ROOT/certs/root.pem"} \
|
||||
WEBSOCKET_HOST_ISSUER=${WEBSOCKET_HOST_ISSUER:-"\$OWGW_ROOT/certs/issuer.pem"} \
|
||||
WEBSOCKET_HOST_CERT=${WEBSOCKET_HOST_CERT:-"\$OWGW_ROOT/certs/websocket-cert.pem"} \
|
||||
WEBSOCKET_HOST_KEY=${WEBSOCKET_HOST_KEY:-"\$OWGW_ROOT/certs/websocket-key.pem"} \
|
||||
WEBSOCKET_HOST_CLIENTCAS=${WEBSOCKET_HOST_CLIENTCAS:-"\$OWGW_ROOT/certs/clientcas.pem"} \
|
||||
WEBSOCKET_HOST_CAS=${WEBSOCKET_HOST_CAS:-"\$OWGW_ROOT/certs/cas"} \
|
||||
WEBSOCKET_HOST_PORT=${WEBSOCKET_HOST_PORT:-"15002"} \
|
||||
WEBSOCKET_HOST_KEY_PASSWORD=${WEBSOCKET_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16002"} \
|
||||
RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
RESTAPI_HOST_KEY=${RESTAPI_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
RESTAPI_HOST_KEY_PASSWORD=${RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
INTERNAL_RESTAPI_HOST_ROOTCA=${INTERNAL_RESTAPI_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_PORT=${INTERNAL_RESTAPI_HOST_PORT:-"17002"} \
|
||||
INTERNAL_RESTAPI_HOST_CERT=${INTERNAL_RESTAPI_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_KEY=${INTERNAL_RESTAPI_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
INTERNAL_RESTAPI_HOST_KEY_PASSWORD=${INTERNAL_RESTAPI_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
FILEUPLOADER_HOST_ROOTCA=${FILEUPLOADER_HOST_ROOTCA:-"\$OWGW_ROOT/certs/restapi-ca.pem"} \
|
||||
FILEUPLOADER_HOST_NAME=${FILEUPLOADER_HOST_NAME:-"localhost"} \
|
||||
FILEUPLOADER_HOST_PORT=${FILEUPLOADER_HOST_PORT:-"16003"} \
|
||||
FILEUPLOADER_HOST_CERT=${FILEUPLOADER_HOST_CERT:-"\$OWGW_ROOT/certs/restapi-cert.pem"} \
|
||||
FILEUPLOADER_HOST_KEY=${FILEUPLOADER_HOST_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
FILEUPLOADER_HOST_KEY_PASSWORD=${FILEUPLOADER_HOST_KEY_PASSWORD:-"mypassword"} \
|
||||
FILEUPLOADER_PATH=${FILEUPLOADER_PATH:-"\$OWGW_ROOT/uploads"} \
|
||||
FILEUPLOADER_URI=${FILEUPLOADER_URI:-"https://localhost:16003"} \
|
||||
SERVICE_KEY=${SERVICE_KEY:-"\$OWGW_ROOT/certs/restapi-key.pem"} \
|
||||
SERVICE_KEY_PASSWORD=${SERVICE_KEY_PASSWORD:-"mypassword"} \
|
||||
SYSTEM_DATA=${SYSTEM_DATA:-"\$OWGW_ROOT/data"} \
|
||||
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17002"} \
|
||||
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16002"} \
|
||||
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
|
||||
SIMULATORID=${SIMULATORID:-""} \
|
||||
RTTY_ENABLED=${RTTY_ENABLED:-"false"} \
|
||||
RTTY_SERVER=${RTTY_SERVER:-"localhost"} \
|
||||
RTTY_PORT=${RTTY_PORT:-"5912"} \
|
||||
RTTY_TOKEN=${RTTY_TOKEN:-"96181c567b4d0d98c50f127230068fa8"} \
|
||||
RTTY_TIMEOUT=${RTTY_TIMEOUT:-"60"} \
|
||||
RTTY_VIEWPORT=${RTTY_VIEWPORT:-"5913"} \
|
||||
KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \
|
||||
KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \
|
||||
STORAGE_TYPE=${STORAGE_TYPE:-"sqlite"} \
|
||||
STORAGE_TYPE_POSTGRESQL_HOST=${STORAGE_TYPE_POSTGRESQL_HOST:-"localhost"} \
|
||||
STORAGE_TYPE_POSTGRESQL_USERNAME=${STORAGE_TYPE_POSTGRESQL_USERNAME:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_PASSWORD=${STORAGE_TYPE_POSTGRESQL_PASSWORD:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_DATABASE=${STORAGE_TYPE_POSTGRESQL_DATABASE:-"owgw"} \
|
||||
STORAGE_TYPE_POSTGRESQL_PORT=${STORAGE_TYPE_POSTGRESQL_PORT:-"5432"} \
|
||||
STORAGE_TYPE_MYSQL_HOST=${STORAGE_TYPE_MYSQL_HOST:-"localhost"} \
|
||||
STORAGE_TYPE_MYSQL_USERNAME=${STORAGE_TYPE_MYSQL_USERNAME:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_PASSWORD=${STORAGE_TYPE_MYSQL_PASSWORD:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_DATABASE=${STORAGE_TYPE_MYSQL_DATABASE:-"owgw"} \
|
||||
STORAGE_TYPE_MYSQL_PORT=${STORAGE_TYPE_MYSQL_PORT:-"3306"} \
|
||||
envsubst < /owgw.properties.tmpl > $OWGW_CONFIG/owgw.properties
|
||||
fi
|
||||
|
||||
if [ "$1" = '/openwifi/owgw' -a "$(id -u)" = '0' ]; then
|
||||
if [ "$RUN_CHOWN" = 'true' ]; then
|
||||
chown -R "$OWGW_USER": "$OWGW_ROOT" "$OWGW_CONFIG"
|
||||
chown -R "$OWGW_USER": "$OWGW_ROOT" "$OWGW_CONFIG"
|
||||
fi
|
||||
exec su-exec "$OWGW_USER" "$@"
|
||||
fi
|
||||
|
||||
@@ -30,13 +30,3 @@ Create chart name and version as used by the chart label.
|
||||
{{- define "owgw.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "owgw.ingress.apiVersion" -}}
|
||||
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" -}}
|
||||
{{- print "networking.k8s.io/v1" -}}
|
||||
{{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}}
|
||||
{{- print "networking.k8s.io/v1beta1" -}}
|
||||
{{- else -}}
|
||||
{{- print "extensions/v1beta1" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
{{- range $ingress, $ingressValue := .Values.ingresses }}
|
||||
{{- if $ingressValue.enabled }}
|
||||
---
|
||||
apiVersion: {{ include "owgw.ingress.apiVersion" $root }}
|
||||
apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ include "owgw.fullname" $root }}-{{ $ingress }}
|
||||
@@ -36,23 +36,9 @@ spec:
|
||||
paths:
|
||||
{{- range $ingressValue.paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if $root.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
|
||||
pathType: {{ .pathType | default "ImplementationSpecific" }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if $root.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
|
||||
service:
|
||||
name: {{ include "owgw.fullname" $root }}-{{ .serviceName }}
|
||||
port:
|
||||
{{- if kindIs "string" .servicePort }}
|
||||
name: {{ .servicePort }}
|
||||
{{- else }}
|
||||
number: {{ .servicePort }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
serviceName: {{ include "owgw.fullname" $root }}-{{ .serviceName }}
|
||||
servicePort: {{ .servicePort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
||||
images:
|
||||
owgw:
|
||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owgw
|
||||
tag: master
|
||||
tag: v2.5.0-RC1
|
||||
pullPolicy: Always
|
||||
# regcred:
|
||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||
@@ -40,12 +40,6 @@ services:
|
||||
servicePort: 16003
|
||||
targetPort: 16003
|
||||
protocol: TCP
|
||||
rttys:
|
||||
servicePort: 5912
|
||||
targetPort: 5912
|
||||
rttys-view:
|
||||
servicePort: 5913
|
||||
targetPort: 5913
|
||||
|
||||
checks:
|
||||
owgw:
|
||||
@@ -68,7 +62,6 @@ ingresses:
|
||||
- restapi.chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
serviceName: owgw
|
||||
servicePort: restapi
|
||||
fileuploader:
|
||||
@@ -80,7 +73,6 @@ ingresses:
|
||||
- fileuploader.chart-example.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
serviceName: owgw
|
||||
servicePort: fileuploader
|
||||
|
||||
@@ -223,13 +215,11 @@ configProperties:
|
||||
openwifi.callback.0.remote: localhost:15055
|
||||
openwifi.callback.0.topics: owfws
|
||||
# rtty
|
||||
rtty.internal: "true"
|
||||
rtty.enabled: "true"
|
||||
rtty.server: localhost
|
||||
rtty.port: 5912
|
||||
rtty.timeout: 60
|
||||
rtty.viewport: 5913
|
||||
rtty.assets: $OWGW_ROOT/rtty_ui
|
||||
# ALB
|
||||
alb.enable: "true"
|
||||
alb.port: 16102
|
||||
@@ -240,10 +230,6 @@ configProperties:
|
||||
openwifi.kafka.brokerlist: localhost:9092
|
||||
openwifi.kafka.auto.commit: false
|
||||
openwifi.kafka.queue.buffering.max.ms: 50
|
||||
openwifi.kafka.ssl.ca.location: ""
|
||||
openwifi.kafka.ssl.certificate.location: ""
|
||||
openwifi.kafka.ssl.key.location: ""
|
||||
openwifi.kafka.ssl.key.password: ""
|
||||
# Storage
|
||||
storage.type: sqlite # (sqlite|postgresql|mysql|odbc)
|
||||
## SQLite
|
||||
|
||||
@@ -139,19 +139,6 @@ components:
|
||||
type: string
|
||||
devicePassword:
|
||||
type: string
|
||||
subscriber:
|
||||
type: string
|
||||
format: uuid
|
||||
entity:
|
||||
type: string
|
||||
format: uuid
|
||||
modified:
|
||||
type: integer
|
||||
format: int64
|
||||
locale:
|
||||
type: string
|
||||
minLength: 2
|
||||
maxLength: 2
|
||||
|
||||
DeviceWithStatus:
|
||||
type: object
|
||||
@@ -222,19 +209,6 @@ components:
|
||||
lastContact:
|
||||
type: integer
|
||||
format: int64
|
||||
subscriber:
|
||||
type: string
|
||||
format: uuid
|
||||
entity:
|
||||
type: string
|
||||
format: uuid
|
||||
modified:
|
||||
type: integer
|
||||
format: int64
|
||||
locale:
|
||||
type: string
|
||||
minLength: 2
|
||||
maxLength: 2
|
||||
|
||||
DeviceList:
|
||||
type: object
|
||||
|
||||
@@ -74,7 +74,7 @@ openwifi.autoprovisioning = true
|
||||
openwifi.devicetypes.0 = AP:linksys_ea8300,edgecore_eap101,linksys_e8450-ubi
|
||||
openwifi.devicetypes.1 = SWITCH:edgecore_ecs4100-12ph
|
||||
openwifi.devicetypes.2 = IOT:esp32
|
||||
oui.download.uri = https://standards-oui.ieee.org/oui/oui.txt
|
||||
oui.download.uri = https://linuxnet.ca/ieee/oui.txt
|
||||
|
||||
iptocountry.default = US
|
||||
iptocountry.provider = ipinfo
|
||||
@@ -115,11 +115,6 @@ openwifi.kafka.brokerlist = a1.arilia.com:9092
|
||||
openwifi.kafka.auto.commit = false
|
||||
openwifi.kafka.queue.buffering.max.ms = 50
|
||||
|
||||
openwifi.kafka.ssl.ca.location =
|
||||
openwifi.kafka.ssl.certificate.location =
|
||||
openwifi.kafka.ssl.key.location =
|
||||
openwifi.kafka.ssl.key.password =
|
||||
|
||||
#
|
||||
# This section select which form of persistence you need
|
||||
# Only one selected at a time. If you select multiple, this service will die if a horrible
|
||||
|
||||
@@ -74,21 +74,19 @@ openwifi.autoprovisioning = true
|
||||
openwifi.devicetypes.0 = AP:linksys_ea8300,edgecore_eap101,linksys_e8450-ubi
|
||||
openwifi.devicetypes.1 = SWITCH:edgecore_ecs4100-12ph
|
||||
openwifi.devicetypes.2 = IOT:esp32
|
||||
oui.download.uri = https://standards-oui.ieee.org/oui/oui.txt
|
||||
oui.download.uri = https://linuxnet.ca/ieee/oui.txt
|
||||
firmware.autoupdate.policy.default = auto
|
||||
simulatorid = ${SIMULATORID}
|
||||
|
||||
#
|
||||
# rtty
|
||||
#
|
||||
rtty.internal = ${RTTY_INTERNAL}
|
||||
rtty.enabled = ${RTTY_ENABLED}
|
||||
rtty.server = ${RTTY_SERVER}
|
||||
rtty.port = ${RTTY_PORT}
|
||||
rtty.token = ${RTTY_TOKEN}
|
||||
rtty.timeout = ${RTTY_TIMEOUT}
|
||||
rtty.viewport = ${RTTY_VIEWPORT}
|
||||
rtty.assets = ${RTTY_ASSETS}
|
||||
|
||||
#############################
|
||||
# Generic information for all micro services
|
||||
@@ -108,10 +106,6 @@ openwifi.kafka.enable = ${KAFKA_ENABLE}
|
||||
openwifi.kafka.brokerlist = ${KAFKA_BROKERLIST}
|
||||
openwifi.kafka.auto.commit = false
|
||||
openwifi.kafka.queue.buffering.max.ms = 50
|
||||
openwifi.kafka.ssl.ca.location = ${KAFKA_SSL_CA_LOCATION}
|
||||
openwifi.kafka.ssl.certificate.location = ${KAFKA_SSL_CERTIFICATE_LOCATION}
|
||||
openwifi.kafka.ssl.key.location = ${KAFKA_SSL_KEY_LOCATION}
|
||||
openwifi.kafka.ssl.key.password = ${KAFKA_SSL_KEY_PASSWORD}
|
||||
|
||||
#
|
||||
# This section select which form of persistence you need
|
||||
|
||||
@@ -1,26 +1 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible">
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<title>RTTYs</title>
|
||||
<link href="/css/app.0e046291.css" rel="preload" as="style">
|
||||
<link href="/css/chunk-vendors.b221ddbd.css" rel="preload" as="style">
|
||||
<link href="/css/chunk-vendors.b221ddbd.css" rel="stylesheet">
|
||||
<link href="/css/app.0e046291.css" rel="stylesheet">
|
||||
<link href="/js/app.79bf330a.js" rel="preload" as="script">
|
||||
<link href="/js/chunk-vendors.7fd2577a.js" rel="preload" as="script">
|
||||
</head>
|
||||
<body>
|
||||
<noscript>
|
||||
<strong>We're sorry but Rttys doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
|
||||
</noscript>
|
||||
<div id="app"></div>
|
||||
<script src="/js/chunk-vendors.7fd2577a.js">
|
||||
</script><script src="/js/app.79bf330a.js">
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html><html lang=""><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><link rel="icon" href="/favicon.ico"><title>Rttys</title><link href="/css/app.0e046291.css" rel="preload" as="style"><link href="/css/chunk-vendors.b221ddbd.css" rel="preload" as="style"><link href="/js/app.79bf330a.js" rel="preload" as="script"><link href="/js/chunk-vendors.7fd2577a.js" rel="preload" as="script"><link href="/css/chunk-vendors.b221ddbd.css" rel="stylesheet"><link href="/css/app.0e046291.css" rel="stylesheet"></head><body><noscript><strong>We're sorry but Rttys doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id="app"></div><script src="/js/chunk-vendors.7fd2577a.js"></script><script src="/js/app.79bf330a.js"></script></body></html>
|
||||
@@ -15,74 +15,69 @@
|
||||
#include "RESTObjects//RESTAPI_GWobjects.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/MicroService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/uCentral_Protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
void CommandManager::run() {
|
||||
Running_ = true;
|
||||
Poco::AutoPtr<Poco::Notification> NextMsg(ResponseQueue_.waitDequeueNotification());
|
||||
while(NextMsg && Running_) {
|
||||
auto Resp = dynamic_cast<RPCResponseNotification*>(NextMsg.get());
|
||||
if(Resp!= nullptr) {
|
||||
const Poco::JSON::Object & Payload = Resp->Payload_;
|
||||
const std::string & SerialNumber = Resp->SerialNumber_;
|
||||
while(Running_)
|
||||
{
|
||||
Poco::Thread::trySleep(30000);
|
||||
if(!Running_)
|
||||
break;
|
||||
|
||||
if(!Payload.has(uCentralProtocol::ID)){
|
||||
Logger().error(fmt::format("({}): Invalid RPC response.", SerialNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t ID = Payload.get(uCentralProtocol::ID);
|
||||
if(ID<2) {
|
||||
Logger().debug(fmt::format("({}): Ignoring RPC response.", SerialNumber));
|
||||
return;
|
||||
}
|
||||
auto Idx = CommandTagIndex{.Id = ID, .SerialNumber = SerialNumber};
|
||||
auto RPC = OutStandingRequests_.find(Idx);
|
||||
if (RPC == OutStandingRequests_.end()) {
|
||||
Logger().warning(fmt::format("({}): Outdated RPC {}", SerialNumber, ID));
|
||||
return;
|
||||
}
|
||||
std::chrono::duration<double, std::milli> rpc_execution_time = std::chrono::high_resolution_clock::now() - RPC->second->submitted;
|
||||
StorageService()->CommandCompleted(RPC->second->uuid, Payload, rpc_execution_time, true);
|
||||
if(RPC->second->rpc_entry) {
|
||||
RPC->second->rpc_entry->set_value(Payload);
|
||||
}
|
||||
OutstandingUUIDs_.erase(RPC->second->uuid);
|
||||
OutStandingRequests_.erase(Idx);
|
||||
Logger().information(fmt::format("({}): Received RPC answer {}", SerialNumber, ID));
|
||||
}
|
||||
NextMsg = ResponseQueue_.waitDequeueNotification();
|
||||
}
|
||||
}
|
||||
std::vector<GWObjects::CommandDetails> Commands;
|
||||
if(StorageService()->GetReadyToExecuteCommands(0,200,Commands))
|
||||
{
|
||||
for(auto & Cmd: Commands)
|
||||
{
|
||||
if(!Running_)
|
||||
break;
|
||||
try {
|
||||
Poco::JSON::Parser P;
|
||||
bool Sent;
|
||||
Logger().information(Poco::format("Parsing: %s", Cmd.UUID));
|
||||
auto Params = P.parse(Cmd.Details).extract<Poco::JSON::Object::Ptr>();
|
||||
Logger().information(Poco::format("Parsed: %s", Cmd.UUID));
|
||||
auto Result = PostCommandDisk( Cmd.SerialNumber,
|
||||
Cmd.Command,
|
||||
*Params,
|
||||
Cmd.UUID,
|
||||
Sent);
|
||||
if(Sent) {
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
Logger().information(Poco::format("%s: Sent command '%s-%s'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
} else {
|
||||
Logger().information(Poco::format("%s: Could not send command '%s-%s'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().information(Poco::format("%s: Failed command '%s-%s'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
Logger().log(E);
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
} catch (...) {
|
||||
Logger().information(Poco::format("%s: Exception - hard fail - Failed command '%s-%s'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int CommandManager::Start() {
|
||||
Logger().notice("Starting...");
|
||||
ManagerThread.start(*this);
|
||||
JanitorCallback_ = std::make_unique<Poco::TimerCallback<CommandManager>>(*this,&CommandManager::onJanitorTimer);
|
||||
JanitorTimer_.setStartInterval( 10000 );
|
||||
JanitorTimer_.setPeriodicInterval(10 * 60 * 1000); // 1 hours
|
||||
JanitorTimer_.start(*JanitorCallback_);
|
||||
|
||||
CommandRunnerCallback_ = std::make_unique<Poco::TimerCallback<CommandManager>>(*this,&CommandManager::onCommandRunnerTimer);
|
||||
CommandRunnerTimer_.setStartInterval( 10000 );
|
||||
CommandRunnerTimer_.setPeriodicInterval(30 * 1000); // 1 hours
|
||||
CommandRunnerTimer_.start(*CommandRunnerCallback_);
|
||||
|
||||
// RPCResponseQueue_->Readable_ += Poco::delegate(this,&CommandManager::onRPCAnswer);
|
||||
// RPCResponseQueue_->Writable_ += Poco::delegate(this,&CommandManager::onRPCAnswer);
|
||||
JanitorCallback_ = std::make_unique<Poco::TimerCallback<CommandManager>>(*this,&CommandManager::onTimer);
|
||||
Timer_.setStartInterval( 10000 );
|
||||
Timer_.setPeriodicInterval(5 * 60 * 1000); // 1 hours
|
||||
Timer_.start(*JanitorCallback_);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CommandManager::Stop() {
|
||||
Logger().notice("Stopping...");
|
||||
// RPCResponseQueue_->Readable_ -= Poco::delegate(this,&CommandManager::onRPCAnswer);
|
||||
// RPCResponseQueue_->Writable_ -= Poco::delegate(this,&CommandManager::onRPCAnswer);
|
||||
Running_ = false;
|
||||
JanitorTimer_.stop();
|
||||
CommandRunnerTimer_.stop();
|
||||
ResponseQueue_.wakeUpAll();
|
||||
Timer_.stop();
|
||||
ManagerThread.wakeUp();
|
||||
ManagerThread.join();
|
||||
}
|
||||
@@ -92,17 +87,13 @@ namespace OpenWifi {
|
||||
ManagerThread.wakeUp();
|
||||
}
|
||||
|
||||
void CommandManager::onJanitorTimer([[maybe_unused]] Poco::Timer & timer) {
|
||||
void CommandManager::onTimer(Poco::Timer & timer) {
|
||||
std::lock_guard G(Mutex_);
|
||||
Logger().information(
|
||||
fmt::format("Removing expired commands: start. {} outstanding-requests {} outstanding-uuids commands.",
|
||||
OutStandingRequests_.size(), OutstandingUUIDs_.size() ));
|
||||
auto now = std::chrono::high_resolution_clock::now();
|
||||
Logger().information("Removing expired commands: start");
|
||||
auto Now = std::chrono::high_resolution_clock::now();
|
||||
for(auto i=OutStandingRequests_.begin();i!=OutStandingRequests_.end();) {
|
||||
std::chrono::duration<double, std::milli> delta = now - i->second->submitted;
|
||||
std::chrono::duration<double, std::milli> delta = Now - i->second->submitted;
|
||||
if(delta > 120000ms) {
|
||||
Logger().debug(fmt::format("Timing out {}", i->second->uuid));
|
||||
OutstandingUUIDs_.erase(i->second->uuid);
|
||||
i = OutStandingRequests_.erase(i);
|
||||
} else {
|
||||
++i;
|
||||
@@ -111,50 +102,6 @@ namespace OpenWifi {
|
||||
Logger().information("Removing expired commands: done");
|
||||
}
|
||||
|
||||
void CommandManager::onCommandRunnerTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||
std::vector<GWObjects::CommandDetails> Commands;
|
||||
if(StorageService()->GetReadyToExecuteCommands(0,200,Commands))
|
||||
{
|
||||
for(auto & Cmd: Commands)
|
||||
{
|
||||
if(!Running_)
|
||||
break;
|
||||
try {
|
||||
{
|
||||
std::lock_guard M(Mutex_);
|
||||
if(OutstandingUUIDs_.find(Cmd.UUID)!=OutstandingUUIDs_.end())
|
||||
continue;
|
||||
}
|
||||
|
||||
Poco::JSON::Parser P;
|
||||
bool Sent;
|
||||
Logger().information(fmt::format("Parsing: {}", Cmd.UUID));
|
||||
auto Params = P.parse(Cmd.Details).extract<Poco::JSON::Object::Ptr>();
|
||||
Logger().information(fmt::format("Parsed: {}", Cmd.UUID));
|
||||
auto Result = PostCommandDisk( Cmd.SerialNumber,
|
||||
Cmd.Command,
|
||||
*Params,
|
||||
Cmd.UUID,
|
||||
Sent);
|
||||
if(Sent) {
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
OutstandingUUIDs_.insert(Cmd.UUID);
|
||||
Logger().information(fmt::format("{}: Sent command '{}-{}'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
} else {
|
||||
Logger().information(fmt::format("{}: Could not send command '{}-{}'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().information(fmt::format("{}: Failed command '{}-{}'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
Logger().log(E);
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
} catch (...) {
|
||||
Logger().information(fmt::format("{}: Exception - hard fail - Failed command '{}-{}'", Cmd.SerialNumber, Cmd.Command, Cmd.UUID));
|
||||
StorageService()->SetCommandExecuted(Cmd.UUID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<CommandManager::promise_type_t> CommandManager::PostCommand( const std::string &SerialNumber,
|
||||
const std::string &Method,
|
||||
const Poco::JSON::Object &Params,
|
||||
@@ -187,7 +134,7 @@ namespace OpenWifi {
|
||||
CompleteRPC.set(uCentralProtocol::PARAMS, Params);
|
||||
Poco::JSON::Stringifier::stringify(CompleteRPC, ToSend);
|
||||
Logger().information(
|
||||
fmt::format("({}): Sending command '{}', ID: {}", SerialNumber, Method, Idx.Id));
|
||||
Poco::format("(%s): Sending command '%s', ID: %lu", SerialNumber, Method, Idx.Id));
|
||||
|
||||
Object->submitted = std::chrono::high_resolution_clock::now();
|
||||
Object->uuid = UUID;
|
||||
@@ -196,10 +143,7 @@ namespace OpenWifi {
|
||||
} else {
|
||||
Object->rpc_entry = std::make_shared<CommandManager::promise_type_t>();
|
||||
}
|
||||
if(!oneway_rpc) {
|
||||
OutStandingRequests_[Idx] = Object;
|
||||
OutstandingUUIDs_.insert(UUID);
|
||||
}
|
||||
OutStandingRequests_[Idx] = Object;
|
||||
}
|
||||
|
||||
if(DeviceRegistry()->SendFrame(SerialNumber, ToSend.str())) {
|
||||
@@ -209,39 +153,31 @@ namespace OpenWifi {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/* void CommandManager::onRPCAnswer(bool &b) {
|
||||
if(b) {
|
||||
RPCResponse Resp;
|
||||
auto S = RPCResponseQueue_->Read(Resp);
|
||||
const std::string & SerialNumber = Resp.serialNumber;
|
||||
std::lock_guard M(Mutex_);
|
||||
if(S) {
|
||||
if(!Resp.payload.has(uCentralProtocol::ID)){
|
||||
Logger().error(fmt::format("({}): Invalid RPC response.", SerialNumber));
|
||||
return;
|
||||
}
|
||||
void CommandManager::PostCommandResult(const std::string &SerialNumber, Poco::JSON::Object::Ptr Obj) {
|
||||
|
||||
uint64_t ID = Resp.payload.get(uCentralProtocol::ID);
|
||||
if(ID<2) {
|
||||
Logger().debug(fmt::format("({}): Ignoring RPC response.", SerialNumber));
|
||||
return;
|
||||
}
|
||||
auto Idx = CommandTagIndex{.Id = ID, .SerialNumber = SerialNumber};
|
||||
auto RPC = OutStandingRequests_.find(Idx);
|
||||
if (RPC == OutStandingRequests_.end()) {
|
||||
Logger().warning(fmt::format("({}): Outdated RPC {}", SerialNumber, ID));
|
||||
return;
|
||||
}
|
||||
std::chrono::duration<double, std::milli> rpc_execution_time = std::chrono::high_resolution_clock::now() - RPC->second->submitted;
|
||||
StorageService()->CommandCompleted(RPC->second->uuid, Resp.payload, rpc_execution_time, true);
|
||||
if(RPC->second->rpc_entry) {
|
||||
RPC->second->rpc_entry->set_value(Resp.payload);
|
||||
}
|
||||
OutstandingUUIDs_.erase(RPC->second->uuid);
|
||||
OutStandingRequests_.erase(Idx);
|
||||
Logger().information(fmt::format("({}): Received RPC answer {}", SerialNumber, ID));
|
||||
}
|
||||
if(!Obj->has(uCentralProtocol::ID)){
|
||||
Logger().error(Poco::format("(%s): Invalid RPC response.",SerialNumber));
|
||||
return;
|
||||
}
|
||||
|
||||
uint64_t ID = Obj->get(uCentralProtocol::ID);
|
||||
if(ID<2) {
|
||||
Logger().error(Poco::format("(%s): Ignoring RPC response.",SerialNumber));
|
||||
return;
|
||||
}
|
||||
std::lock_guard G(Mutex_);
|
||||
auto Idx = CommandTagIndex{.Id = ID, .SerialNumber = SerialNumber};
|
||||
auto RPC = OutStandingRequests_.find(Idx);
|
||||
if (RPC == OutStandingRequests_.end()) {
|
||||
Logger().warning(Poco::format("(%s): Outdated RPC %lu", SerialNumber, ID));
|
||||
return;
|
||||
}
|
||||
std::chrono::duration<double, std::milli> rpc_execution_time = std::chrono::high_resolution_clock::now() - RPC->second->submitted;
|
||||
StorageService()->CommandCompleted(RPC->second->uuid, Obj, rpc_execution_time, true);
|
||||
if(RPC->second->rpc_entry) {
|
||||
RPC->second->rpc_entry->set_value(Obj);
|
||||
}
|
||||
Logger().information(Poco::format("(%s): Received RPC answer %lu", SerialNumber, ID));
|
||||
}
|
||||
*/
|
||||
|
||||
} // namespace
|
||||
@@ -19,7 +19,7 @@
|
||||
#include "Poco/Net/HTTPServerResponse.h"
|
||||
#include "Poco/Timer.h"
|
||||
|
||||
#include "RESTObjects/RESTAPI_GWobjects.h"
|
||||
#include "RESTObjects//RESTAPI_GWobjects.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
@@ -43,23 +43,9 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
|
||||
class RPCResponseNotification: public Poco::Notification {
|
||||
public:
|
||||
RPCResponseNotification(const std::string &ser,
|
||||
const Poco::JSON::Object &pl) :
|
||||
SerialNumber_(ser),
|
||||
Payload_(pl)
|
||||
{
|
||||
|
||||
}
|
||||
std::string SerialNumber_;
|
||||
Poco::JSON::Object Payload_;
|
||||
};
|
||||
|
||||
|
||||
class CommandManager : public SubSystemServer, Poco::Runnable {
|
||||
class CommandManager : public SubSystemServer, Poco::Runnable {
|
||||
public:
|
||||
typedef Poco::JSON::Object objtype_t;
|
||||
typedef Poco::JSON::Object::Ptr objtype_t;
|
||||
typedef std::promise<objtype_t> promise_type_t;
|
||||
struct RpcObject {
|
||||
std::string uuid;
|
||||
@@ -67,25 +53,10 @@ namespace OpenWifi {
|
||||
std::shared_ptr<promise_type_t> rpc_entry;
|
||||
};
|
||||
|
||||
struct RPCResponse {
|
||||
std::string serialNumber;
|
||||
Poco::JSON::Object payload;
|
||||
|
||||
explicit RPCResponse(const std::string &ser, const Poco::JSON::Object &pl)
|
||||
:
|
||||
serialNumber(ser),
|
||||
payload(pl) {
|
||||
}
|
||||
};
|
||||
|
||||
int Start() override;
|
||||
void Stop() override;
|
||||
void WakeUp();
|
||||
inline void PostCommandResult(const std::string &SerialNumber, const Poco::JSON::Object &Obj) {
|
||||
std::lock_guard G(Mutex_);
|
||||
// RPCResponseQueue_->Write(RPCResponse{.serialNumber=SerialNumber, .payload = Obj});
|
||||
ResponseQueue_.enqueueNotification(new RPCResponseNotification(SerialNumber,Obj));
|
||||
}
|
||||
void PostCommandResult(const std::string &SerialNumber, Poco::JSON::Object::Ptr Obj);
|
||||
|
||||
std::shared_ptr<promise_type_t> PostCommandOneWayDisk(
|
||||
const std::string &SerialNumber,
|
||||
@@ -149,22 +120,15 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
inline bool Running() const { return Running_; }
|
||||
void onJanitorTimer(Poco::Timer & timer);
|
||||
void onCommandRunnerTimer(Poco::Timer & timer);
|
||||
void onRPCAnswer(bool& b);
|
||||
void onTimer(Poco::Timer & timer);
|
||||
|
||||
private:
|
||||
std::atomic_bool Running_ = false;
|
||||
Poco::Thread ManagerThread;
|
||||
uint64_t Id_=3; // do not start @1. We ignore ID=1 & 0 is illegal..
|
||||
std::map<CommandTagIndex,std::shared_ptr<RpcObject>> OutStandingRequests_;
|
||||
std::set<std::string> OutstandingUUIDs_;
|
||||
Poco::Timer JanitorTimer_;
|
||||
Poco::Timer Timer_;
|
||||
std::unique_ptr<Poco::TimerCallback<CommandManager>> JanitorCallback_;
|
||||
Poco::Timer CommandRunnerTimer_;
|
||||
std::unique_ptr<Poco::TimerCallback<CommandManager>> CommandRunnerCallback_;
|
||||
// std::unique_ptr<FIFO<RPCResponse>> RPCResponseQueue_=std::make_unique<FIFO<RPCResponse>>(100);
|
||||
Poco::NotificationQueue ResponseQueue_;
|
||||
|
||||
std::shared_ptr<promise_type_t> PostCommand(
|
||||
const std::string &SerialNumber,
|
||||
|
||||
@@ -6,10 +6,12 @@
|
||||
// Arilia Wireless Inc.
|
||||
//
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include "Poco/Util/Application.h"
|
||||
#include "Poco/Util/Option.h"
|
||||
#include "Poco/Environment.h"
|
||||
|
||||
#include "CentralConfig.h"
|
||||
#include "CommandManager.h"
|
||||
#include "Daemon.h"
|
||||
#include "DeviceRegistry.h"
|
||||
@@ -82,11 +84,15 @@ namespace OpenWifi {
|
||||
{"wallys_dr40x9","AP"}
|
||||
};
|
||||
|
||||
void Daemon::PostInitialization([[maybe_unused]] Poco::Util::Application &self) {
|
||||
void Daemon::initialize() {
|
||||
AutoProvisioning_ = config().getBool("openwifi.autoprovisioning",false);
|
||||
DeviceTypes_ = DefaultDeviceTypes;
|
||||
}
|
||||
|
||||
void MicroServicePostInitialization() {
|
||||
Daemon()->initialize();
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string Daemon::IdentifyDevice(const std::string & Id ) const {
|
||||
for(const auto &[DeviceType,Type]:DeviceTypes_)
|
||||
{
|
||||
|
||||
15
src/Daemon.h
15
src/Daemon.h
@@ -30,11 +30,11 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
[[maybe_unused]] static const char * vDAEMON_PROPERTIES_FILENAME = "owgw.properties";
|
||||
[[maybe_unused]] static const char * vDAEMON_ROOT_ENV_VAR = "OWGW_ROOT";
|
||||
[[maybe_unused]] static const char * vDAEMON_CONFIG_ENV_VAR = "OWGW_CONFIG";
|
||||
[[maybe_unused]] static const char * vDAEMON_APP_NAME = uSERVICE_GATEWAY.c_str();
|
||||
[[maybe_unused]] static const uint64_t vDAEMON_BUS_TIMER = 10000;
|
||||
static const char * vDAEMON_PROPERTIES_FILENAME = "owgw.properties";
|
||||
static const char * vDAEMON_ROOT_ENV_VAR = "OWGW_ROOT";
|
||||
static const char * vDAEMON_CONFIG_ENV_VAR = "OWGW_CONFIG";
|
||||
static const char * vDAEMON_APP_NAME = uSERVICE_GATEWAY.c_str();
|
||||
static const uint64_t vDAEMON_BUS_TIMER = 10000;
|
||||
|
||||
class Daemon : public MicroService {
|
||||
public:
|
||||
@@ -48,10 +48,10 @@ namespace OpenWifi {
|
||||
|
||||
bool AutoProvisioning() const { return AutoProvisioning_ ; }
|
||||
[[nodiscard]] std::string IdentifyDevice(const std::string & Compatible) const;
|
||||
void initialize();
|
||||
static Daemon *instance();
|
||||
inline DeviceDashboard & GetDashboard() { return DB_; }
|
||||
Poco::Logger & Log() { return Poco::Logger::get(AppName()); }
|
||||
void PostInitialization(Poco::Util::Application &self);
|
||||
private:
|
||||
bool AutoProvisioning_ = false;
|
||||
std::vector<std::pair<std::string,std::string>> DeviceTypes_;
|
||||
@@ -60,8 +60,5 @@ namespace OpenWifi {
|
||||
};
|
||||
|
||||
inline Daemon * Daemon() { return Daemon::instance(); }
|
||||
inline void DaemonPostInitialization(Poco::Util::Application &self) {
|
||||
Daemon()->PostInitialization(self);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ namespace OpenWifi {
|
||||
try {
|
||||
return Device->second->WSConn_->Send(Payload);
|
||||
} catch (...) {
|
||||
Logger().debug(fmt::format("Could not send data to device '{}'", SerialNumber));
|
||||
Logger().debug(Poco::format("Could not send data to device '%s'", SerialNumber));
|
||||
Device->second->Conn_.Address = "";
|
||||
Device->second->WSConn_ = nullptr;
|
||||
Device->second->Conn_.Connected = false;
|
||||
|
||||
@@ -66,7 +66,7 @@ namespace OpenWifi {
|
||||
} else {
|
||||
FullName_ = TmpName + URI_BASE ;
|
||||
}
|
||||
Logger().information(fmt::format("Uploader URI base is '{}'", FullName_));
|
||||
Logger().information(Poco::format("Uploader URI base is '%s'", FullName_));
|
||||
}
|
||||
|
||||
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new FileUpLoaderRequestHandlerFactory(Logger()), Pool_, Sock, Params);
|
||||
@@ -79,7 +79,7 @@ namespace OpenWifi {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void FileUploader::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||
void FileUploader::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
@@ -144,7 +144,7 @@ namespace OpenWifi {
|
||||
|
||||
std::string FinalFileName = FileUploader()->Path() + "/" + UUID_;
|
||||
|
||||
Logger().information(fmt::format("FILE-UPLOADER: uploading trace for {}", FinalFileName));
|
||||
Logger().information(Poco::format("FILE-UPLOADER: uploading trace for %s", FinalFileName));
|
||||
Poco::CountingInputStream InputStream(Stream);
|
||||
std::ofstream OutputStream(FinalFileName, std::ofstream::out);
|
||||
Poco::StreamCopier::copyStream(InputStream, OutputStream);
|
||||
@@ -216,7 +216,7 @@ namespace OpenWifi {
|
||||
}
|
||||
catch( const Poco::Exception & E )
|
||||
{
|
||||
Logger().warning(fmt::format("Error occurred while performing upload. Error='{}'",E.displayText()));
|
||||
Logger().warning(Poco::format("Error occurred while performing upload. Error='%s'",E.displayText()));
|
||||
}
|
||||
catch( ... )
|
||||
{
|
||||
@@ -230,7 +230,7 @@ namespace OpenWifi {
|
||||
|
||||
Poco::Net::HTTPRequestHandler *FileUpLoaderRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest & Request) {
|
||||
|
||||
Logger().debug(fmt::format("REQUEST({}): {} {}", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
Logger().debug(Poco::format("REQUEST(%s): %s %s", Utils::FormatIPv6(Request.clientAddress().toString()), Request.getMethod(), Request.getURI()));
|
||||
|
||||
// The UUID should be after the /v1/upload/ part...
|
||||
auto UUIDLocation = Request.getURI().find_first_of(URI_BASE);
|
||||
@@ -246,7 +246,7 @@ namespace OpenWifi {
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger().warning(fmt::format("Unknown UUID={}",UUID));
|
||||
Logger().warning(Poco::format("Unknown UUID=%s",UUID));
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace OpenWifi {
|
||||
Timer_.stop();
|
||||
}
|
||||
|
||||
void OUIServer::reinitialize([[maybe_unused]] Poco::Util::Application &self) {
|
||||
void OUIServer::reinitialize(Poco::Util::Application &self) {
|
||||
MicroService::instance().LoadConfigurationFile();
|
||||
Logger().information("Reinitializing.");
|
||||
Stop();
|
||||
@@ -42,22 +42,17 @@ namespace OpenWifi {
|
||||
|
||||
bool OUIServer::GetFile(const std::string &FileName) {
|
||||
try {
|
||||
Logger().information(fmt::format("Start: Retrieving OUI file: {}",MicroService::instance().ConfigGetString("oui.download.uri")));
|
||||
Logger().information(Poco::format("Start: Retrieving OUI file: %s",MicroService::instance().ConfigGetString("oui.download.uri")));
|
||||
std::unique_ptr<std::istream> pStr(
|
||||
Poco::URIStreamOpener::defaultOpener().open(MicroService::instance().ConfigGetString("oui.download.uri")));
|
||||
std::ofstream OS;
|
||||
Poco::File F(FileName);
|
||||
if(F.exists()) {
|
||||
auto LastModified = F.getLastModified();
|
||||
auto Delta = OpenWifi::Now() - LastModified.epochTime();
|
||||
if((Delta / (24*60*60)) < 1)
|
||||
return true;
|
||||
if(F.exists())
|
||||
F.remove();
|
||||
}
|
||||
OS.open(FileName);
|
||||
Poco::StreamCopier::copyStream(*pStr, OS);
|
||||
OS.close();
|
||||
Logger().information(fmt::format("Done: Retrieving OUI file: {}",MicroService::instance().ConfigGetString("oui.download.uri")));
|
||||
Logger().information(Poco::format("Done: Retrieving OUI file: %s",MicroService::instance().ConfigGetString("oui.download.uri")));
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
@@ -85,7 +80,7 @@ namespace OpenWifi {
|
||||
auto MAC = Utils::SerialNumberToOUI(Tokens[0]);
|
||||
if (MAC > 0) {
|
||||
std::string Manufacturer;
|
||||
for (size_t i = 2; i < Tokens.count(); i++)
|
||||
for (auto i = 2; i < Tokens.count(); i++)
|
||||
Manufacturer += Tokens[i] + " ";
|
||||
auto M = Poco::trim(Manufacturer);
|
||||
if (!M.empty())
|
||||
@@ -101,7 +96,7 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OUIServer::onTimer([[maybe_unused]] Poco::Timer & timer) {
|
||||
void OUIServer::onTimer(Poco::Timer & timer) {
|
||||
if(Updating_)
|
||||
return;
|
||||
Updating_ = true;
|
||||
@@ -120,7 +115,7 @@ namespace OpenWifi {
|
||||
F1.remove();
|
||||
Poco::File F2(LatestOUIFileName);
|
||||
F2.renameTo(CurrentOUIFileName);
|
||||
Logger().information(fmt::format("New OUI file {} downloaded.",LatestOUIFileName));
|
||||
Logger().information(Poco::format("New OUI file %s downloaded.",LatestOUIFileName));
|
||||
} else if(OUIs_.empty()) {
|
||||
if(ProcessFile(CurrentOUIFileName, TmpOUIs)) {
|
||||
LastUpdate_ = std::time(nullptr);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace OpenWifi {
|
||||
|
||||
private:
|
||||
uint64_t LastUpdate_ = 0 ;
|
||||
// bool ValidFile_=false;
|
||||
bool ValidFile_=false;
|
||||
OUIMap OUIs_;
|
||||
std::atomic_bool Updating_=false;
|
||||
std::atomic_bool Running_=false;
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-06-28.
|
||||
//
|
||||
#include <cctype>
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <iterator>
|
||||
#include <future>
|
||||
#include <numeric>
|
||||
#include <chrono>
|
||||
#include "RESTAPI_RPC.h"
|
||||
|
||||
#include "CommandManager.h"
|
||||
#include "DeviceRegistry.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/uCentral_Protocol.h"
|
||||
|
||||
namespace OpenWifi::RESTAPI_RPC {
|
||||
void SetCommandStatus(GWObjects::CommandDetails &Cmd,
|
||||
[[maybe_unused]] Poco::Net::HTTPServerRequest &Request,
|
||||
[[maybe_unused]] Poco::Net::HTTPServerResponse &Response,
|
||||
RESTAPIHandler *Handler,
|
||||
OpenWifi::Storage::CommandExecutionType Status,
|
||||
[[maybe_unused]] Poco::Logger &Logger) {
|
||||
Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response,
|
||||
RESTAPIHandler *Handler,
|
||||
OpenWifi::Storage::CommandExecutionType Status,
|
||||
Poco::Logger &Logger) {
|
||||
if (StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Status)) {
|
||||
Poco::JSON::Object RetObj;
|
||||
Cmd.to_json(RetObj);
|
||||
@@ -44,88 +47,79 @@ namespace OpenWifi::RESTAPI_RPC {
|
||||
return;
|
||||
}
|
||||
|
||||
Cmd.Executed = OpenWifi::Now();
|
||||
Cmd.Executed = std::time(nullptr);
|
||||
|
||||
bool Sent;
|
||||
std::chrono::time_point<std::chrono::high_resolution_clock> rpc_submitted = std::chrono::high_resolution_clock::now();
|
||||
std::shared_ptr<CommandManager::promise_type_t> rpc_endpoint =
|
||||
CommandManager()->PostCommand(Cmd.SerialNumber, Cmd.Command, Params, Cmd.UUID, Sent);
|
||||
|
||||
Poco::JSON::Object L;
|
||||
|
||||
if (Sent && rpc_endpoint!= nullptr) {
|
||||
std::future<CommandManager::objtype_t> rpc_future(rpc_endpoint->get_future());
|
||||
auto rpc_result = rpc_future.wait_for(WaitTimeInMs);
|
||||
if (rpc_result == std::future_status::ready) {
|
||||
if (rpc_result == std::future_status::ready && rpc_future.valid()) {
|
||||
std::chrono::duration<double, std::milli> rpc_execution_time = std::chrono::high_resolution_clock::now() - rpc_submitted;
|
||||
auto rpc_answer = rpc_future.get();
|
||||
if (rpc_answer.has(uCentralProtocol::RESULT) && rpc_answer.isObject(uCentralProtocol::RESULT)) {
|
||||
auto ResultFields =
|
||||
rpc_answer.get(uCentralProtocol::RESULT).extract<Poco::JSON::Object::Ptr>();
|
||||
if (ResultFields->has(uCentralProtocol::STATUS) && ResultFields->isObject(uCentralProtocol::STATUS)) {
|
||||
auto StatusInnerObj =
|
||||
ResultFields->get(uCentralProtocol::STATUS).extract<Poco::JSON::Object::Ptr>();
|
||||
if (StatusInnerObj->has(uCentralProtocol::ERROR))
|
||||
Cmd.ErrorCode = StatusInnerObj->get(uCentralProtocol::ERROR);
|
||||
if (StatusInnerObj->has(uCentralProtocol::TEXT))
|
||||
Cmd.ErrorText = StatusInnerObj->get(uCentralProtocol::TEXT).toString();
|
||||
std::stringstream ResultText;
|
||||
Poco::JSON::Stringifier::stringify(rpc_answer.get(uCentralProtocol::RESULT),
|
||||
ResultText);
|
||||
Cmd.Results = ResultText.str();
|
||||
Cmd.Status = "completed";
|
||||
Cmd.Completed = std::time(nullptr);
|
||||
Cmd.executionTime = rpc_execution_time.count();
|
||||
if (rpc_answer) {
|
||||
if (rpc_answer->has("result") && rpc_answer->isObject("result")) {
|
||||
auto ResultFields =
|
||||
rpc_answer->get("result").extract<Poco::JSON::Object::Ptr>();
|
||||
if (ResultFields->has("status") && ResultFields->isObject("status")) {
|
||||
auto StatusInnerObj =
|
||||
ResultFields->get("status").extract<Poco::JSON::Object::Ptr>();
|
||||
if (StatusInnerObj->has("error"))
|
||||
Cmd.ErrorCode = StatusInnerObj->get("error");
|
||||
if (StatusInnerObj->has("text"))
|
||||
Cmd.ErrorText = StatusInnerObj->get("text").toString();
|
||||
std::stringstream ResultText;
|
||||
Poco::JSON::Stringifier::stringify(rpc_answer->get("result"),
|
||||
ResultText);
|
||||
Cmd.Results = ResultText.str();
|
||||
Cmd.Status = "completed";
|
||||
Cmd.Completed = time(nullptr);
|
||||
Cmd.executionTime = rpc_execution_time.count();
|
||||
|
||||
if (Cmd.ErrorCode && Cmd.Command == uCentralProtocol::TRACE) {
|
||||
Cmd.WaitingForFile = 0;
|
||||
Cmd.AttachDate = Cmd.AttachSize = 0;
|
||||
Cmd.AttachType = "";
|
||||
}
|
||||
if (Cmd.ErrorCode && Cmd.Command == uCentralProtocol::TRACE) {
|
||||
Cmd.WaitingForFile = 0;
|
||||
Cmd.AttachDate = Cmd.AttachSize = 0;
|
||||
Cmd.AttachType = "";
|
||||
}
|
||||
|
||||
// Add the completed command to the database...
|
||||
StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Storage::COMMAND_COMPLETED);
|
||||
// Add the completed command to the database...
|
||||
StorageService()->AddCommand(Cmd.SerialNumber, Cmd, Storage::COMMAND_COMPLETED);
|
||||
|
||||
if (ObjectToReturn) {
|
||||
Handler->ReturnObject(*ObjectToReturn);
|
||||
if (ObjectToReturn) {
|
||||
Handler->ReturnObject(*ObjectToReturn);
|
||||
} else {
|
||||
Poco::JSON::Object O;
|
||||
Cmd.to_json(O);
|
||||
Handler->ReturnObject(O);
|
||||
}
|
||||
Logger.information(Poco::format("Command(%s): completed in %8.3fms.", Cmd.UUID, Cmd.executionTime));
|
||||
return;
|
||||
} else {
|
||||
Poco::JSON::Object O;
|
||||
Cmd.to_json(O);
|
||||
Handler->ReturnObject(O);
|
||||
SetCommandStatus(Cmd, Request, Response, Handler,
|
||||
Storage::COMMAND_FAILED, Logger);
|
||||
Logger.information(Poco::format(
|
||||
"Invalid response for command '%s'. Missing status.", Cmd.UUID));
|
||||
return;
|
||||
}
|
||||
Logger.information( fmt::format("Command({}): completed in {:.3f}ms.", Cmd.UUID, Cmd.executionTime));
|
||||
return;
|
||||
} else {
|
||||
SetCommandStatus(Cmd, Request, Response, Handler,
|
||||
Storage::COMMAND_FAILED, Logger);
|
||||
Logger.information(fmt::format(
|
||||
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
|
||||
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_FAILED,
|
||||
Logger);
|
||||
Logger.information(Poco::format(
|
||||
"Invalid response for command '%s'. Missing status.", Cmd.UUID));
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_FAILED,
|
||||
Logger);
|
||||
Logger.information(fmt::format(
|
||||
"Invalid response for command '{}'. Missing status.", Cmd.UUID));
|
||||
return;
|
||||
}
|
||||
} else if (rpc_result == std::future_status::timeout) {
|
||||
Logger.information(fmt::format(
|
||||
"Timeout2 for command '{}'.", Cmd.UUID));
|
||||
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_TIMEDOUT,
|
||||
Logger);
|
||||
return;
|
||||
} else {
|
||||
Logger.information(fmt::format(
|
||||
"Pending completion for command '{}'.", Cmd.UUID));
|
||||
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_PENDING, Logger);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
Logger.information(fmt::format(
|
||||
"Pending completion for command '{}'.", Cmd.UUID));
|
||||
SetCommandStatus(Cmd, Request, Response, Handler, Storage::COMMAND_PENDING, Logger);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "Poco/File.h"
|
||||
#include "Poco/JSON/Object.h"
|
||||
|
||||
#include "RESTObjects/RESTAPI_GWobjects.h"
|
||||
#include "RESTObjects//RESTAPI_GWobjects.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include "Poco/JSON/Stringifier.h"
|
||||
#include "RESTAPI_blacklist.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_blacklist::DoDelete() {
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/blacklist/{serialNumber}"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/blacklist/{serialNumber}"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final;
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/blacklist"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/blacklist"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/capabilities"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/capabilities"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -9,15 +9,12 @@
|
||||
#include "RESTAPI_command.h"
|
||||
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_command::DoGet() {
|
||||
auto CommandUUID = GetBinding(RESTAPI::Protocol::COMMANDUUID, "");
|
||||
if(!Utils::ValidUUID(CommandUUID)) {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GWObjects::CommandDetails Command;
|
||||
if (StorageService()->GetCommand(CommandUUID, Command)) {
|
||||
Poco::JSON::Object RetObj;
|
||||
@@ -28,21 +25,18 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
void RESTAPI_command::DoDelete() {
|
||||
auto CommandUUID = GetBinding(RESTAPI::Protocol::COMMANDUUID, "");
|
||||
if(CommandUUID.empty()) {
|
||||
auto UUID = GetBinding(RESTAPI::Protocol::COMMANDUUID, "");
|
||||
|
||||
if(UUID.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::MissingUUID);
|
||||
}
|
||||
|
||||
if(!Utils::ValidUUID(CommandUUID)) {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
GWObjects::CommandDetails C;
|
||||
if(!StorageService()->GetCommand(CommandUUID, C)) {
|
||||
if(!StorageService()->GetCommand(UUID, C)) {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
if (StorageService()->DeleteCommand(CommandUUID)) {
|
||||
if (StorageService()->DeleteCommand(UUID)) {
|
||||
return OK();
|
||||
}
|
||||
return InternalError();
|
||||
|
||||
@@ -21,7 +21,7 @@ class RESTAPI_command : public RESTAPIHandler {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/command/{commandUUID}"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/command/{commandUUID}"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
#include "RESTAPI_commands.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_commands::DoGet() {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/commands"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/commands"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
#include "RESTObjects/RESTAPI_GWobjects.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
#include "framework/ConfigurationValidator.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/default_configuration/{name}"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/default_configuration/{name}"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RESTAPI_default_configurations.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
void RESTAPI_default_configurations::DoGet() {
|
||||
|
||||
@@ -20,7 +20,7 @@ class RESTAPI_default_configurations : public RESTAPIHandler {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal){};
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/default_configurations"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/default_configurations"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenWifi {
|
||||
std::vector<std::string>{
|
||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS}, Server, TransactionId,Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/deviceDashboard"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/deviceDashboard"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -19,8 +19,10 @@
|
||||
#include "StorageService.h"
|
||||
#include "RESTAPI_RPC.h"
|
||||
#include "TelemetryStream.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
#include "framework/uCentral_Protocol.h"
|
||||
#include "framework/KafkaTopics.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/ConfigurationValidator.h"
|
||||
#include "rttys/RTTYS_server.h"
|
||||
#include "WS_Server.h"
|
||||
@@ -129,7 +131,7 @@ void RESTAPI_device_commandHandler::GetCapabilities() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::DeleteCapabilities() {
|
||||
Logger_.information(fmt::format("DELETE-CAPABILITIES: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("DELETE-CAPABILITIES: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
if (StorageService()->DeleteDeviceCapabilities(SerialNumber_)) {
|
||||
return OK();
|
||||
}
|
||||
@@ -170,7 +172,7 @@ void RESTAPI_device_commandHandler::GetStatistics() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::DeleteStatistics() {
|
||||
Logger_.information(fmt::format("DELETE-STATISTICS: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("DELETE-STATISTICS: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
if (StorageService()->DeleteStatisticsData(SerialNumber_, QB_.StartDate, QB_.EndDate)) {
|
||||
return OK();
|
||||
}
|
||||
@@ -178,7 +180,7 @@ void RESTAPI_device_commandHandler::DeleteStatistics() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Ping() {
|
||||
Logger_.information(fmt::format("DELETE-STATISTICS: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("DELETE-STATISTICS: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER)) {
|
||||
auto SNum = Obj->get(RESTAPI::Protocol::SERIALNUMBER).toString();
|
||||
@@ -244,7 +246,7 @@ void RESTAPI_device_commandHandler::GetStatus() {
|
||||
|
||||
void RESTAPI_device_commandHandler::Configure() {
|
||||
// get the configuration from the body of the message
|
||||
Logger_.information(fmt::format("CONFIGURE: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("CONFIGURE: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
Obj->has(RESTAPI::Protocol::UUID) &&
|
||||
@@ -293,7 +295,7 @@ void RESTAPI_device_commandHandler::Configure() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Upgrade() {
|
||||
Logger_.information(fmt::format("UPGRADE: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("UPGRADE: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
|
||||
if (Obj->has(RESTAPI::Protocol::URI) &&
|
||||
@@ -355,7 +357,7 @@ void RESTAPI_device_commandHandler::GetLogs() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::DeleteLogs() {
|
||||
Logger_.information(fmt::format("DELETE-LOGS: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("DELETE-LOGS: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
if (StorageService()->DeleteLogData(SerialNumber_, QB_.StartDate, QB_.EndDate,
|
||||
QB_.LogType)) {
|
||||
return OK();
|
||||
@@ -398,7 +400,7 @@ void RESTAPI_device_commandHandler::GetChecks() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::DeleteChecks() {
|
||||
Logger_.information(fmt::format("DELETE-HEALTHCHECKS: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("DELETE-HEALTHCHECKS: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
if (StorageService()->DeleteHealthCheckData(SerialNumber_, QB_.StartDate, QB_.EndDate)) {
|
||||
return OK();
|
||||
}
|
||||
@@ -406,7 +408,7 @@ void RESTAPI_device_commandHandler::DeleteChecks() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::ExecuteCommand() {
|
||||
Logger_.information(fmt::format("EXECUTE: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("EXECUTE: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::COMMAND) &&
|
||||
Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
@@ -452,7 +454,7 @@ void RESTAPI_device_commandHandler::ExecuteCommand() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Reboot() {
|
||||
Logger_.information(fmt::format("REBOOT: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("REBOOT: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER)) {
|
||||
@@ -461,10 +463,6 @@ void RESTAPI_device_commandHandler::Reboot() {
|
||||
return BadRequest(RESTAPI::Errors::SerialNumberMismatch);
|
||||
}
|
||||
|
||||
if(!DeviceRegistry()->Connected(SerialNumber_)) {
|
||||
return BadRequest(RESTAPI::Errors::DeviceNotConnected);
|
||||
}
|
||||
|
||||
uint64_t When = GetWhen(Obj);
|
||||
GWObjects::CommandDetails Cmd;
|
||||
Cmd.SerialNumber = SerialNumber_;
|
||||
@@ -488,7 +486,7 @@ void RESTAPI_device_commandHandler::Reboot() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Factory() {
|
||||
Logger_.information(fmt::format("FACTORY-RESET: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("FACTORY-RESET: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Poco::JSON::Object::Ptr Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::KEEPREDIRECTOR) &&
|
||||
Obj->has(RESTAPI::Protocol::SERIALNUMBER)) {
|
||||
@@ -526,7 +524,7 @@ void RESTAPI_device_commandHandler::Factory() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::LEDs() {
|
||||
Logger_.information(fmt::format("LEDS: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("LEDS: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
|
||||
if (Obj->has(uCentralProtocol::PATTERN) &&
|
||||
@@ -572,7 +570,7 @@ void RESTAPI_device_commandHandler::LEDs() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Trace() {
|
||||
Logger_.information(fmt::format("TRACE: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("TRACE: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
@@ -584,9 +582,9 @@ void RESTAPI_device_commandHandler::Trace() {
|
||||
return BadRequest(RESTAPI::Errors::SerialNumberMismatch);
|
||||
}
|
||||
|
||||
if(!DeviceRegistry()->Connected(SerialNumber_)) {
|
||||
return BadRequest(RESTAPI::Errors::DeviceNotConnected);
|
||||
}
|
||||
auto Duration = Get(RESTAPI::Protocol::DURATION, Obj, 30);
|
||||
auto When = GetWhen(Obj);
|
||||
auto NumberOfPackets = Get(RESTAPI::Protocol::NUMBEROFPACKETS, Obj, 100);
|
||||
|
||||
auto Network = GetS(RESTAPI::Protocol::NETWORK, Obj);
|
||||
auto Interface = GetS(RESTAPI::Protocol::INTERFACE, Obj);
|
||||
@@ -598,21 +596,16 @@ void RESTAPI_device_commandHandler::Trace() {
|
||||
Cmd.UUID = UUID;
|
||||
Cmd.SubmittedBy = UserInfo_.webtoken.username_;
|
||||
Cmd.Command = uCentralProtocol::TRACE;
|
||||
Cmd.RunAt = 0;
|
||||
Cmd.RunAt = When;
|
||||
Cmd.WaitingForFile = 1;
|
||||
Cmd.AttachType = RESTAPI::Protocol::PCAP_FILE_TYPE;
|
||||
|
||||
Poco::JSON::Object Params;
|
||||
|
||||
if(Obj->has(RESTAPI::Protocol::DURATION))
|
||||
Params.set(uCentralProtocol::DURATION, Get(RESTAPI::Protocol::DURATION, Obj, 30) );
|
||||
else if(Obj->has(RESTAPI::Protocol::NUMBEROFPACKETS))
|
||||
Params.set(uCentralProtocol::PACKETS,Get(RESTAPI::Protocol::NUMBEROFPACKETS, Obj, 100));
|
||||
else
|
||||
Params.set(uCentralProtocol::DURATION, 30);
|
||||
|
||||
Params.set(uCentralProtocol::SERIAL, SerialNumber_);
|
||||
Params.set(uCentralProtocol::WHEN, 0);
|
||||
Params.set(uCentralProtocol::DURATION, Duration);
|
||||
Params.set(uCentralProtocol::WHEN, When);
|
||||
Params.set(uCentralProtocol::PACKETS, NumberOfPackets);
|
||||
Params.set(uCentralProtocol::NETWORK, Network);
|
||||
Params.set(uCentralProtocol::INTERFACE, Interface);
|
||||
Params.set(uCentralProtocol::URI, URI);
|
||||
@@ -628,7 +621,7 @@ void RESTAPI_device_commandHandler::Trace() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::WifiScan() {
|
||||
Logger_.information(fmt::format("WIFISCAN: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("WIFISCAN: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
|
||||
auto SNum = Obj->get(RESTAPI::Protocol::SERIALNUMBER).toString();
|
||||
@@ -636,13 +629,8 @@ void RESTAPI_device_commandHandler::WifiScan() {
|
||||
return BadRequest(RESTAPI::Errors::SerialNumberMismatch);
|
||||
}
|
||||
|
||||
if(!DeviceRegistry()->Connected(SerialNumber_)) {
|
||||
return BadRequest(RESTAPI::Errors::DeviceNotConnected);
|
||||
}
|
||||
|
||||
bool OverrideDFS = GetB(RESTAPI::Protocol::OVERRIDEDFS, Obj, true);
|
||||
bool ActiveScan = GetB(RESTAPI::Protocol::ACTIVESCAN, Obj, false);
|
||||
uint64_t Bandwidth = Get(RESTAPI::Protocol::BANDWIDTH, Obj, (uint64_t) 0);
|
||||
|
||||
auto UUID = MicroService::CreateUUID();
|
||||
GWObjects::CommandDetails Cmd;
|
||||
@@ -657,8 +645,6 @@ void RESTAPI_device_commandHandler::WifiScan() {
|
||||
Params.set(uCentralProtocol::SERIAL, SerialNumber_);
|
||||
Params.set(uCentralProtocol::OVERRIDEDFS, OverrideDFS);
|
||||
Params.set(uCentralProtocol::ACTIVE, ActiveScan);
|
||||
if(Bandwidth!=0)
|
||||
Params.set(uCentralProtocol::BANDWIDTH, Bandwidth);
|
||||
|
||||
std::stringstream ParamStream;
|
||||
Params.stringify(ParamStream);
|
||||
@@ -670,7 +656,7 @@ void RESTAPI_device_commandHandler::WifiScan() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::EventQueue() {
|
||||
Logger_.information(fmt::format("EVENT-QUEUE: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("EVENT-QUEUE: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
Obj->isArray(RESTAPI::Protocol::TYPES)) {
|
||||
@@ -709,7 +695,7 @@ void RESTAPI_device_commandHandler::EventQueue() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::MakeRequest() {
|
||||
Logger_.information(fmt::format("FORCE-REQUEST: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("FORCE-REQUEST: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
Obj->has(uCentralProtocol::MESSAGE)) {
|
||||
@@ -749,15 +735,9 @@ void RESTAPI_device_commandHandler::MakeRequest() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Rtty() {
|
||||
Logger_.information(fmt::format("RTTY: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
|
||||
if(!DeviceRegistry()->Connected(SerialNumber_)) {
|
||||
return BadRequest(RESTAPI::Errors::DeviceNotConnected);
|
||||
}
|
||||
|
||||
Logger_.information(Poco::format("RTTY: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
if (MicroService::instance().ConfigGetBool("rtty.enabled", false)) {
|
||||
GWObjects::Device Device;
|
||||
|
||||
if (StorageService()->GetDevice(SerialNumber_, Device)) {
|
||||
auto CommandUUID = MicroService::CreateUUID();
|
||||
|
||||
@@ -771,7 +751,6 @@ void RESTAPI_device_commandHandler::MakeRequest() {
|
||||
.Started = (uint64_t)time(nullptr),
|
||||
.CommandUUID = CommandUUID,
|
||||
.ViewPort = MicroService::instance().ConfigGetInt("rtty.viewport", 5913),
|
||||
.DevicePassword = ""
|
||||
};
|
||||
|
||||
if(RTTYS_server()->UseInternal()) {
|
||||
@@ -812,7 +791,7 @@ void RESTAPI_device_commandHandler::MakeRequest() {
|
||||
}
|
||||
|
||||
void RESTAPI_device_commandHandler::Telemetry(){
|
||||
Logger_.information(fmt::format("TELEMETRY: user={} serial={}", UserInfo_.userinfo.email,SerialNumber_));
|
||||
Logger_.information(Poco::format("TELEMETRY: user=%s serial=%s", UserInfo_.userinfo.email,SerialNumber_));
|
||||
|
||||
auto Obj = ParseStream();
|
||||
if (Obj->has(RESTAPI::Protocol::SERIALNUMBER) &&
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "framework/MicroService.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
class RESTAPI_device_commandHandler : public RESTAPIHandler {
|
||||
@@ -46,7 +47,7 @@ namespace OpenWifi {
|
||||
void Telemetry();
|
||||
void Ping();
|
||||
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/device/{serialNumber}/{command}"}; };
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/device/{serialNumber}/{command}"}; };
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final;
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
#include "StorageService.h"
|
||||
#include "framework/ConfigurationValidator.h"
|
||||
#include "framework/MicroService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
#include "RESTAPI_device_helper.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
@@ -107,7 +108,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if (!Utils::ValidSerialNumber(SerialNumber)) {
|
||||
Logger_.warning(fmt::format("CREATE-DEVICE({}): Illegal serial number.", SerialNumber));
|
||||
Logger_.warning(Poco::format("CREATE-DEVICE(%s): Illegal serial number.", SerialNumber));
|
||||
return BadRequest( RESTAPI::Errors::InvalidSerialNumber);
|
||||
}
|
||||
|
||||
@@ -178,8 +179,6 @@ namespace OpenWifi {
|
||||
AssignIfPresent(Obj, "venue", Existing.Venue);
|
||||
AssignIfPresent(Obj, "owner", Existing.Owner);
|
||||
AssignIfPresent(Obj, "location", Existing.Location);
|
||||
AssignIfPresent(Obj, "subscriber", Existing.subscriber);
|
||||
AssignIfPresent(Obj, "entity", Existing.entity);
|
||||
|
||||
for(auto &i:NewDevice.Notes) {
|
||||
i.createdBy = UserInfo_.userinfo.email;
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/device/{serialNumber}"}; };
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/device/{serialNumber}"}; };
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final;
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "RESTAPI_devices_handler.h"
|
||||
#include "StorageService.h"
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
#include "framework/MicroService.h"
|
||||
#include "RESTAPI/RESTAPI_device_helper.h"
|
||||
#include "Poco/StringTokenizer.h"
|
||||
@@ -44,7 +44,7 @@ namespace OpenWifi {
|
||||
}
|
||||
} else {
|
||||
Logger_.error(
|
||||
fmt::format("DEVICE({}): device in select cannot be found.", i));
|
||||
Poco::format("DEVICE(%s): device in select cannot be found.", i));
|
||||
}
|
||||
}
|
||||
if (deviceWithStatus)
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal){};
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/devices"}; };
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/devices"}; };
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include "Poco/File.h"
|
||||
#include "StorageService.h"
|
||||
|
||||
#include "framework/ow_constants.h"
|
||||
#include "framework/RESTAPI_errors.h"
|
||||
#include "framework/RESTAPI_protocol.h"
|
||||
#include <fstream>
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace OpenWifi {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/file/{uuid}"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/file/{uuid}"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final;
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -16,7 +16,7 @@ class RESTAPI_iptocountry_handler : public RESTAPIHandler {
|
||||
Server,
|
||||
TransactionId,
|
||||
Internal){};
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/iptocountry"}; };
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/iptocountry"}; };
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenWifi {
|
||||
std::vector<std::string>{
|
||||
Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS}, Server, TransactionId,Internal) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/ouis"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/ouis"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
||||
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const char *Path, RESTAPIHandler::BindingMap &Bindings,
|
||||
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
|
||||
|
||||
Poco::Thread::current()->setName("ExtWebServerThread_" + std::to_string(TransactionId));
|
||||
@@ -47,7 +47,7 @@ namespace OpenWifi {
|
||||
RESTAPI_capabilities_handler, RESTAPI_telemetryWebSocket>(Path,Bindings,L, S, TransactionId);
|
||||
}
|
||||
|
||||
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
||||
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const char *Path, RESTAPIHandler::BindingMap &Bindings,
|
||||
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
|
||||
|
||||
Poco::Thread::current()->setName("IntWebServerThread_" + std::to_string(TransactionId));
|
||||
|
||||
@@ -28,7 +28,7 @@ void RESTAPI_telemetryWebSocket::DoGet() {
|
||||
auto SerialNumber = Utils::SerialNumberToInt(SNum);
|
||||
|
||||
if(!TelemetryStream()->IsValidEndPoint(SerialNumber,UUID)) {
|
||||
Logger_.warning(fmt::format("Illegal telemetry request for S: {}, UUID: {}", SerialNumber, UUID));
|
||||
Logger_.warning(Poco::format("Illegal telemetry request for S: %s, UUID: %s", SerialNumber, UUID));
|
||||
return;
|
||||
}
|
||||
auto WS = Poco::SharedPtr<Poco::Net::WebSocket>( new Poco::Net::WebSocket(*Request, *Response));
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenWifi {
|
||||
std::vector<std::string>{ Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||
Server, TransactionId, Internal, false) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/ws_telemetry"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/ws_telemetry"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -127,7 +127,7 @@ namespace OpenWifi {
|
||||
uint64_t HowMany = 50;
|
||||
if (O->has("howMany"))
|
||||
HowMany = O->get("howMany");
|
||||
Logger_.information(fmt::format("serial_number_search: {}", Prefix));
|
||||
Logger_.information(Poco::format("serial_number_search: %s", Prefix));
|
||||
if (!Prefix.empty() && Prefix.length() < 13) {
|
||||
std::vector<uint64_t> Numbers;
|
||||
SerialNumberCache()->FindNumbers(Prefix, HowMany, Numbers);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace OpenWifi {
|
||||
std::vector<std::string>{ Poco::Net::HTTPRequest::HTTP_GET,
|
||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||
Server, TransactionId, Internal,false) {}
|
||||
static auto PathName() { return std::list<std::string>{"/api/v1/ws"};}
|
||||
static const std::list<const char *> PathName() { return std::list<const char *>{"/api/v1/ws"};}
|
||||
void DoGet() final;
|
||||
void DoDelete() final {};
|
||||
void DoPost() final {};
|
||||
|
||||
@@ -1,360 +0,0 @@
|
||||
//
|
||||
// Created by stephane bourque on 2022-01-10.
|
||||
//
|
||||
|
||||
#include "RESTAPI_AnalyticsObjects.h"
|
||||
#include "RESTAPI_ProvObjects.h"
|
||||
#include "framework/MicroService.h"
|
||||
|
||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||
|
||||
namespace OpenWifi::AnalyticsObjects {
|
||||
|
||||
void Report::reset() {
|
||||
}
|
||||
|
||||
void Report::to_json(Poco::JSON::Object &Obj) const {
|
||||
}
|
||||
|
||||
void VenueInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"id",id);
|
||||
field_to_json(Obj,"name",name);
|
||||
field_to_json(Obj,"description",description);
|
||||
field_to_json(Obj,"retention",retention);
|
||||
field_to_json(Obj,"interval",interval);
|
||||
field_to_json(Obj,"monitorSubVenues",monitorSubVenues);
|
||||
}
|
||||
|
||||
bool VenueInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"name",name);
|
||||
field_from_json(Obj,"description",description);
|
||||
field_from_json(Obj,"retention",retention);
|
||||
field_from_json(Obj,"interval",interval);
|
||||
field_from_json(Obj,"monitorSubVenues",monitorSubVenues);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void BoardInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json(Obj,"venueList",venueList);
|
||||
}
|
||||
|
||||
bool BoardInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json(Obj,"venueList",venueList);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"boardId",boardId);
|
||||
field_to_json(Obj,"type",type);
|
||||
field_to_json(Obj,"serialNumber",serialNumber);
|
||||
field_to_json(Obj,"deviceType",deviceType);
|
||||
field_to_json(Obj,"lastContact",lastContact);
|
||||
field_to_json(Obj,"lastPing",lastPing);
|
||||
field_to_json(Obj,"lastState",lastState);
|
||||
field_to_json(Obj,"lastFirmware",lastFirmware);
|
||||
field_to_json(Obj,"lastFirmwareUpdate",lastFirmwareUpdate);
|
||||
field_to_json(Obj,"lastConnection",lastConnection);
|
||||
field_to_json(Obj,"lastDisconnection",lastDisconnection);
|
||||
field_to_json(Obj,"pings",pings);
|
||||
field_to_json(Obj,"states",states);
|
||||
field_to_json(Obj,"connected",connected);
|
||||
field_to_json(Obj,"connectionIp",connectionIp);
|
||||
field_to_json(Obj,"associations_2g",associations_2g);
|
||||
field_to_json(Obj,"associations_5g",associations_5g);
|
||||
field_to_json(Obj,"associations_6g",associations_6g);
|
||||
field_to_json(Obj,"health",health);
|
||||
field_to_json(Obj,"lastHealth",lastHealth);
|
||||
field_to_json(Obj,"locale",locale);
|
||||
field_to_json(Obj,"uptime",uptime);
|
||||
field_to_json(Obj,"memory",memory);
|
||||
}
|
||||
|
||||
bool DeviceInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"boardId",boardId);
|
||||
field_from_json(Obj,"type",type);
|
||||
field_from_json(Obj,"serialNumber",serialNumber);
|
||||
field_from_json(Obj,"deviceType",deviceType);
|
||||
field_from_json(Obj,"lastContact",lastContact);
|
||||
field_from_json(Obj,"lastPing",lastPing);
|
||||
field_from_json(Obj,"lastState",lastState);
|
||||
field_from_json(Obj,"lastFirmware",lastFirmware);
|
||||
field_from_json(Obj,"lastFirmwareUpdate",lastFirmwareUpdate);
|
||||
field_from_json(Obj,"lastConnection",lastConnection);
|
||||
field_from_json(Obj,"lastDisconnection",lastDisconnection);
|
||||
field_from_json(Obj,"pings",pings);
|
||||
field_from_json(Obj,"states",states);
|
||||
field_from_json(Obj,"connected",connected);
|
||||
field_from_json(Obj,"connectionIp",connectionIp);
|
||||
field_from_json(Obj,"associations_2g",associations_2g);
|
||||
field_from_json(Obj,"associations_5g",associations_5g);
|
||||
field_from_json(Obj,"associations_6g",associations_6g);
|
||||
field_from_json(Obj,"health",health);
|
||||
field_from_json(Obj,"lastHealth",lastHealth);
|
||||
field_from_json(Obj,"locale",locale);
|
||||
field_from_json(Obj,"uptime",uptime);
|
||||
field_from_json(Obj,"memory",memory);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceInfoList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"devices",devices);
|
||||
}
|
||||
|
||||
bool DeviceInfoList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"devices",devices);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UE_rate::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"bitrate",bitrate);
|
||||
field_to_json(Obj,"mcs",mcs);
|
||||
field_to_json(Obj,"nss",nss);
|
||||
field_to_json(Obj,"ht",ht);
|
||||
field_to_json(Obj,"sgi",sgi);
|
||||
field_to_json(Obj,"chwidth",chwidth);
|
||||
}
|
||||
|
||||
bool UE_rate::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"bitrate",bitrate);
|
||||
field_from_json(Obj,"mcs",mcs);
|
||||
field_from_json(Obj,"nss",nss);
|
||||
field_from_json(Obj,"ht",ht);
|
||||
field_from_json(Obj,"sgi",sgi);
|
||||
field_from_json(Obj,"chwidth",chwidth);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UETimePoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"station",station);
|
||||
field_to_json(Obj,"rssi",rssi);
|
||||
field_to_json(Obj,"tx_bytes",tx_bytes);
|
||||
field_to_json(Obj,"rx_bytes",rx_bytes);
|
||||
field_to_json(Obj,"tx_duration",tx_duration);
|
||||
field_to_json(Obj,"rx_packets",rx_packets);
|
||||
field_to_json(Obj,"tx_packets",tx_packets);
|
||||
field_to_json(Obj,"tx_retries",tx_retries);
|
||||
field_to_json(Obj,"tx_failed",tx_failed);
|
||||
field_to_json(Obj,"connected",connected);
|
||||
field_to_json(Obj,"inactive",inactive);
|
||||
field_to_json(Obj,"tx_rate",tx_rate);
|
||||
field_to_json(Obj,"rx_rate",rx_rate);
|
||||
}
|
||||
|
||||
bool UETimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"station",station);
|
||||
field_from_json(Obj,"rssi",rssi);
|
||||
field_from_json(Obj,"tx_bytes",tx_bytes);
|
||||
field_from_json(Obj,"rx_bytes",rx_bytes);
|
||||
field_from_json(Obj,"tx_duration",tx_duration);
|
||||
field_from_json(Obj,"rx_packets",rx_packets);
|
||||
field_from_json(Obj,"tx_packets",tx_packets);
|
||||
field_from_json(Obj,"tx_retries",tx_retries);
|
||||
field_from_json(Obj,"tx_failed",tx_failed);
|
||||
field_from_json(Obj,"connected",connected);
|
||||
field_from_json(Obj,"inactive",inactive);
|
||||
field_from_json(Obj,"tx_rate",tx_rate);
|
||||
field_from_json(Obj,"rx_rate",rx_rate);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void APTimePoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"collisions",collisions);
|
||||
field_to_json(Obj,"multicast",multicast);
|
||||
field_to_json(Obj,"rx_bytes",rx_bytes);
|
||||
field_to_json(Obj,"rx_dropped",rx_dropped);
|
||||
field_to_json(Obj,"rx_errors",rx_errors);
|
||||
field_to_json(Obj,"rx_packets",rx_packets);
|
||||
field_to_json(Obj,"tx_bytes",tx_bytes);
|
||||
field_to_json(Obj,"tx_packets",tx_packets);
|
||||
field_to_json(Obj,"tx_dropped",tx_dropped);
|
||||
field_to_json(Obj,"tx_errors",tx_errors);
|
||||
field_to_json(Obj,"tx_packets",tx_packets);
|
||||
}
|
||||
|
||||
bool APTimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"collisions",collisions);
|
||||
field_from_json(Obj,"multicast",multicast);
|
||||
field_from_json(Obj,"rx_bytes",rx_bytes);
|
||||
field_from_json(Obj,"rx_dropped",rx_dropped);
|
||||
field_from_json(Obj,"rx_errors",rx_errors);
|
||||
field_from_json(Obj,"rx_packets",rx_packets);
|
||||
field_from_json(Obj,"tx_bytes",tx_bytes);
|
||||
field_from_json(Obj,"tx_packets",tx_packets);
|
||||
field_from_json(Obj,"tx_dropped",tx_dropped);
|
||||
field_from_json(Obj,"tx_errors",tx_errors);
|
||||
field_from_json(Obj,"tx_packets",tx_packets);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void TIDstat_entry::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"rx_msdu",rx_msdu);
|
||||
field_to_json(Obj,"tx_msdu",tx_msdu);
|
||||
field_to_json(Obj,"tx_msdu_failed",tx_msdu_failed);
|
||||
field_to_json(Obj,"tx_msdu_retries",tx_msdu_retries);
|
||||
}
|
||||
|
||||
bool TIDstat_entry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"rx_msdu",rx_msdu);
|
||||
field_from_json(Obj,"tx_msdu",tx_msdu);
|
||||
field_from_json(Obj,"tx_msdu_failed",tx_msdu_failed);
|
||||
field_from_json(Obj,"tx_msdu_retries",tx_msdu_retries);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RadioTimePoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"band",band);
|
||||
field_to_json(Obj,"radio_channel",radio_channel);
|
||||
field_to_json(Obj,"active_ms",active_ms);
|
||||
field_to_json(Obj,"busy_ms",busy_ms);
|
||||
field_to_json(Obj,"receive_ms",receive_ms);
|
||||
field_to_json(Obj,"transmit_ms",transmit_ms);
|
||||
field_to_json(Obj,"tx_power",tx_power);
|
||||
field_to_json(Obj,"channel",channel);
|
||||
field_to_json(Obj,"temperature",temperature);
|
||||
field_to_json(Obj,"noise",noise);
|
||||
}
|
||||
|
||||
bool RadioTimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"band",band);
|
||||
field_from_json(Obj,"radio_channel",radio_channel);
|
||||
field_from_json(Obj,"active_ms",active_ms);
|
||||
field_from_json(Obj,"busy_ms",busy_ms);
|
||||
field_from_json(Obj,"receive_ms",receive_ms);
|
||||
field_from_json(Obj,"transmit_ms",transmit_ms);
|
||||
field_from_json(Obj,"tx_power",tx_power);
|
||||
field_from_json(Obj,"channel",channel);
|
||||
field_from_json(Obj,"temperature",temperature);
|
||||
field_from_json(Obj,"noise",noise);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SSIDTimePoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"bssid",bssid);
|
||||
field_to_json(Obj,"mode",mode);
|
||||
field_to_json(Obj,"ssid",ssid);
|
||||
field_to_json(Obj,"band",band);
|
||||
field_to_json(Obj,"associations",associations);
|
||||
}
|
||||
|
||||
bool SSIDTimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"bssid",bssid);
|
||||
field_from_json(Obj,"mode",mode);
|
||||
field_from_json(Obj,"ssid",ssid);
|
||||
field_from_json(Obj,"band",band);
|
||||
field_from_json(Obj,"associations",associations);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceTimePoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"id",id);
|
||||
field_to_json(Obj,"boardId",boardId);
|
||||
field_to_json(Obj,"timestamp",timestamp);
|
||||
field_to_json(Obj,"ap_data",ap_data);
|
||||
field_to_json(Obj,"ssid_data",ssid_data);
|
||||
field_to_json(Obj,"radio_data",radio_data);
|
||||
field_to_json(Obj,"device_info",device_info);
|
||||
}
|
||||
|
||||
bool DeviceTimePoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"boardId",boardId);
|
||||
field_from_json(Obj,"timestamp",timestamp);
|
||||
field_from_json(Obj,"ap_data",ap_data);
|
||||
field_from_json(Obj,"ssid_data",ssid_data);
|
||||
field_from_json(Obj,"radio_data",radio_data);
|
||||
field_from_json(Obj,"device_info",device_info);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceTimePointList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"points",points);
|
||||
}
|
||||
|
||||
bool DeviceTimePointList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"points",points);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceTimePointStats::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"firstPoint",firstPoint);
|
||||
field_to_json(Obj,"lastPoint",lastPoint);
|
||||
field_to_json(Obj,"count",count);
|
||||
}
|
||||
|
||||
bool DeviceTimePointStats::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"firstPoint",firstPoint);
|
||||
field_from_json(Obj,"lastPoint",lastPoint);
|
||||
field_from_json(Obj,"count",count);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,290 +0,0 @@
|
||||
//
|
||||
// Created by stephane bourque on 2022-01-10.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RESTAPI_ProvObjects.h"
|
||||
#include <vector>
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
namespace AnalyticsObjects {
|
||||
|
||||
struct Report {
|
||||
uint64_t snapShot = 0;
|
||||
|
||||
void reset();
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
};
|
||||
|
||||
struct VenueInfo {
|
||||
OpenWifi::Types::UUID_t id;
|
||||
std::string name;
|
||||
std::string description;
|
||||
uint64_t retention = 0;
|
||||
uint64_t interval = 0;
|
||||
bool monitorSubVenues = false;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct BoardInfo {
|
||||
ProvObjects::ObjectInfo info;
|
||||
std::vector<VenueInfo> venueList;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
inline bool operator<(const BoardInfo &bb) const {
|
||||
return info.id < bb.info.id;
|
||||
}
|
||||
|
||||
inline bool operator==(const BoardInfo &bb) const {
|
||||
return info.id == bb.info.id;
|
||||
}
|
||||
};
|
||||
|
||||
struct DeviceInfo {
|
||||
std::string boardId;
|
||||
std::string type;
|
||||
std::string serialNumber;
|
||||
std::string deviceType;
|
||||
uint64_t lastContact = 0 ;
|
||||
uint64_t lastPing = 0;
|
||||
uint64_t lastState = 0;
|
||||
std::string lastFirmware;
|
||||
uint64_t lastFirmwareUpdate = 0;
|
||||
uint64_t lastConnection = 0;
|
||||
uint64_t lastDisconnection = 0;
|
||||
uint64_t pings = 0;
|
||||
uint64_t states = 0;
|
||||
bool connected = false;
|
||||
std::string connectionIp;
|
||||
uint64_t associations_2g = 0;
|
||||
uint64_t associations_5g = 0;
|
||||
uint64_t associations_6g = 0;
|
||||
uint64_t health = 0;
|
||||
uint64_t lastHealth = 0;
|
||||
std::string locale;
|
||||
uint64_t uptime = 0;
|
||||
double memory = 0.0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct DeviceInfoList {
|
||||
std::vector<DeviceInfo> devices;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum wifi_band {
|
||||
band_2g = 0, band_5g = 1, band_6g = 2
|
||||
};
|
||||
|
||||
struct TIDstat_entry {
|
||||
uint64_t rx_msdu = 0,
|
||||
tx_msdu = 0,
|
||||
tx_msdu_failed = 0,
|
||||
tx_msdu_retries = 0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct UE_rate {
|
||||
uint64_t bitrate=0;
|
||||
uint64_t mcs=0;
|
||||
uint64_t nss=0;
|
||||
bool ht=false;
|
||||
bool sgi=false;
|
||||
uint64_t chwidth=0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct UETimePoint {
|
||||
std::string station;
|
||||
int64_t rssi = 0;
|
||||
uint64_t tx_bytes = 0,
|
||||
rx_bytes = 0,
|
||||
tx_duration = 0,
|
||||
rx_packets = 0,
|
||||
tx_packets = 0,
|
||||
tx_retries = 0,
|
||||
tx_failed = 0,
|
||||
connected = 0,
|
||||
inactive = 0;
|
||||
UE_rate tx_rate,
|
||||
rx_rate;
|
||||
std::vector<TIDstat_entry> tidstat;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum SSID_MODES {
|
||||
unknown = 0,
|
||||
ap,
|
||||
mesh,
|
||||
sta,
|
||||
wds_ap,
|
||||
wds_sta,
|
||||
wds_repeater
|
||||
};
|
||||
|
||||
inline SSID_MODES SSID_Mode(const std::string &m) {
|
||||
if (m == "ap")
|
||||
return ap;
|
||||
if (m == "sta")
|
||||
return sta;
|
||||
if (m == "mesh")
|
||||
return mesh;
|
||||
if (m == "wds-ap")
|
||||
return wds_ap;
|
||||
if (m == "wds-sta")
|
||||
return wds_sta;
|
||||
if (m == "wds-repeater")
|
||||
return wds_repeater;
|
||||
return unknown;
|
||||
}
|
||||
|
||||
struct SSIDTimePoint {
|
||||
std::string bssid,
|
||||
mode,
|
||||
ssid;
|
||||
uint64_t band=0;
|
||||
std::vector<UETimePoint> associations;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
|
||||
struct APTimePoint {
|
||||
uint64_t collisions = 0,
|
||||
multicast = 0,
|
||||
rx_bytes = 0,
|
||||
rx_dropped = 0,
|
||||
rx_errors = 0,
|
||||
rx_packets = 0,
|
||||
tx_bytes = 0,
|
||||
tx_dropped = 0,
|
||||
tx_errors = 0,
|
||||
tx_packets = 0;
|
||||
|
||||
double tx_bytes_bw = 0.0 ,
|
||||
rx_bytes_bw = 0.0 ,
|
||||
rx_dropped_pct = 0.0,
|
||||
tx_dropped_pct = 0.0,
|
||||
rx_packets_bw = 0.0,
|
||||
tx_packets_bw = 0.0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct RadioTimePoint {
|
||||
uint64_t band = 0,
|
||||
radio_channel = 0;
|
||||
uint64_t active_ms = 0,
|
||||
busy_ms = 0,
|
||||
receive_ms = 0,
|
||||
transmit_ms = 0,
|
||||
tx_power = 0,
|
||||
channel = 0;
|
||||
int64_t temperature = 0,
|
||||
noise = 0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
|
||||
struct DeviceTimePoint {
|
||||
std::string id;
|
||||
std::string boardId;
|
||||
uint64_t timestamp = 0;
|
||||
APTimePoint ap_data;
|
||||
std::vector<SSIDTimePoint> ssid_data;
|
||||
std::vector<RadioTimePoint> radio_data;
|
||||
AnalyticsObjects::DeviceInfo device_info;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
inline bool operator<(const DeviceTimePoint &rhs) const {
|
||||
if(timestamp < rhs.timestamp)
|
||||
return true;
|
||||
if(timestamp > rhs.timestamp)
|
||||
return false;
|
||||
if(device_info.serialNumber < rhs.device_info.serialNumber)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool operator==(const DeviceTimePoint &rhs) const {
|
||||
return timestamp==rhs.timestamp && device_info.serialNumber==rhs.device_info.serialNumber;
|
||||
}
|
||||
|
||||
inline bool operator>(const DeviceTimePoint &rhs) const {
|
||||
if(timestamp > rhs.timestamp)
|
||||
return true;
|
||||
if(timestamp < rhs.timestamp)
|
||||
return false;
|
||||
if(device_info.serialNumber > rhs.device_info.serialNumber)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
struct DeviceTimePointList {
|
||||
std::vector<DeviceTimePoint> points;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct BandwidthAnalysisEntry {
|
||||
uint64_t timestamp = 0;
|
||||
|
||||
};
|
||||
|
||||
struct BandwidthAnalysis {
|
||||
|
||||
};
|
||||
|
||||
struct AverageValueSigned {
|
||||
int64_t peak=0, avg=0, low=0;
|
||||
};
|
||||
|
||||
struct AverageValueUnsigned {
|
||||
uint64_t peak=0, avg=0, low=0;
|
||||
};
|
||||
|
||||
struct RadioAnalysis {
|
||||
uint64_t timestamp=0;
|
||||
AverageValueSigned noise, temperature;
|
||||
AverageValueUnsigned active_ms,
|
||||
busy_ms,
|
||||
transmit_ms,
|
||||
receive_ms;
|
||||
};
|
||||
|
||||
struct DeviceTimePointStats {
|
||||
uint64_t firstPoint=0;
|
||||
uint64_t lastPoint=0;
|
||||
uint64_t count=0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -236,7 +236,7 @@ namespace OpenWifi::FMSObjects {
|
||||
snapshot = std::time(nullptr);
|
||||
}
|
||||
|
||||
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool DeviceReport::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
|
||||
return true;
|
||||
@@ -245,32 +245,4 @@ namespace OpenWifi::FMSObjects {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeviceInformation::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj, "serialNumber",serialNumber);
|
||||
field_to_json(Obj, "history", history);
|
||||
field_to_json(Obj, "currentFirmware", currentFirmware);
|
||||
field_to_json(Obj, "currentFirmwareDate", currentFirmwareDate);
|
||||
field_to_json(Obj, "latestFirmware", latestFirmware);
|
||||
field_to_json(Obj, "latestFirmwareDate", latestFirmwareDate);
|
||||
field_to_json(Obj, "latestFirmwareAvailable",latestFirmwareAvailable);
|
||||
field_to_json(Obj, "latestFirmwareURI",latestFirmwareURI);
|
||||
}
|
||||
|
||||
bool DeviceInformation::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj, "serialNumber",serialNumber);
|
||||
field_from_json(Obj, "history", history);
|
||||
field_from_json(Obj, "currentFirmware", currentFirmware);
|
||||
field_from_json(Obj, "currentFirmwareDate", currentFirmwareDate);
|
||||
field_from_json(Obj, "latestFirmware", latestFirmware);
|
||||
field_from_json(Obj, "latestFirmwareDate", latestFirmwareDate);
|
||||
field_from_json(Obj, "latestFirmwareAvailable",latestFirmwareAvailable);
|
||||
field_from_json(Obj, "latestFirmwareURI",latestFirmwareURI);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -127,20 +127,6 @@ namespace OpenWifi::FMSObjects {
|
||||
void reset();
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct DeviceInformation {
|
||||
std::string serialNumber;
|
||||
RevisionHistoryEntryList history;
|
||||
std::string currentFirmware;
|
||||
uint64_t currentFirmwareDate=0;
|
||||
std::string latestFirmware;
|
||||
uint64_t latestFirmwareDate=0;
|
||||
bool latestFirmwareAvailable;
|
||||
std::string latestFirmwareURI;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -45,10 +45,6 @@ namespace OpenWifi::GWObjects {
|
||||
field_to_json(Obj,"compatible", Compatible);
|
||||
field_to_json(Obj,"fwUpdatePolicy", FWUpdatePolicy);
|
||||
field_to_json(Obj,"devicePassword", DevicePassword);
|
||||
field_to_json(Obj,"subscriber", subscriber);
|
||||
field_to_json(Obj,"entity", entity);
|
||||
field_to_json(Obj,"modified", modified);
|
||||
field_to_json(Obj,"locale", locale);
|
||||
}
|
||||
|
||||
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
|
||||
@@ -73,7 +69,7 @@ namespace OpenWifi::GWObjects {
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Device::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool Device::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"serialNumber",SerialNumber);
|
||||
field_from_json(Obj,"deviceType",DeviceType);
|
||||
@@ -85,9 +81,6 @@ namespace OpenWifi::GWObjects {
|
||||
field_from_json(Obj,"location",Location);
|
||||
field_from_json(Obj,"venue",Venue);
|
||||
field_from_json(Obj,"compatible",Compatible);
|
||||
field_from_json(Obj,"subscriber", subscriber);
|
||||
field_from_json(Obj,"entity", entity);
|
||||
field_from_json(Obj,"locale", locale);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
}
|
||||
@@ -156,7 +149,7 @@ namespace OpenWifi::GWObjects {
|
||||
field_to_json(Obj,"executionTime", executionTime);
|
||||
}
|
||||
|
||||
bool DefaultConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool DefaultConfiguration::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"name",Name);
|
||||
field_from_json(Obj,"configuration",Configuration);
|
||||
@@ -175,7 +168,7 @@ namespace OpenWifi::GWObjects {
|
||||
field_to_json(Obj,"created", created);
|
||||
}
|
||||
|
||||
bool BlackListedDevice::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool BlackListedDevice::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"serialNumber",serialNumber);
|
||||
field_from_json(Obj,"author",author);
|
||||
@@ -202,7 +195,6 @@ namespace OpenWifi::GWObjects {
|
||||
field_to_json(Obj,"websocketPackets", websocketPackets);
|
||||
field_to_json(Obj,"kafkaClients", kafkaClients);
|
||||
field_to_json(Obj,"kafkaPackets", kafkaPackets);
|
||||
field_to_json(Obj,"locale", locale);
|
||||
|
||||
switch(VerifiedCertificate) {
|
||||
case NO_CERTIFICATE:
|
||||
|
||||
@@ -37,7 +37,6 @@ namespace OpenWifi::GWObjects {
|
||||
uint64_t webSocketClients=0;
|
||||
uint64_t kafkaPackets=0;
|
||||
uint64_t websocketPackets=0;
|
||||
std::string locale;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
};
|
||||
|
||||
@@ -60,14 +59,9 @@ namespace OpenWifi::GWObjects {
|
||||
uint64_t LastFWUpdate = 0 ;
|
||||
std::string Venue;
|
||||
std::string DevicePassword;
|
||||
std::string subscriber;
|
||||
std::string entity;
|
||||
uint64_t modified=0;
|
||||
std::string locale;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
void to_json_with_status(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
void Print() const;
|
||||
};
|
||||
|
||||
@@ -124,7 +118,7 @@ namespace OpenWifi::GWObjects {
|
||||
uint64_t Created;
|
||||
uint64_t LastModified;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct CommandDetails {
|
||||
@@ -156,7 +150,7 @@ namespace OpenWifi::GWObjects {
|
||||
std::string author;
|
||||
uint64_t created;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct RttySessionDetails {
|
||||
|
||||
@@ -93,11 +93,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"devices",devices);
|
||||
field_to_json( Obj,"rrm",rrm);
|
||||
field_to_json( Obj,"sourceIP",sourceIP);
|
||||
field_to_json( Obj,"variables", variables);
|
||||
field_to_json( Obj,"managementPolicies", managementPolicies);
|
||||
field_to_json( Obj,"managementRoles", managementRoles);
|
||||
field_to_json( Obj,"maps", maps);
|
||||
field_to_json( Obj,"configurations", configurations);
|
||||
}
|
||||
|
||||
bool Entity::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -113,11 +108,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"devices",devices);
|
||||
field_from_json( Obj,"rrm",rrm);
|
||||
field_from_json( Obj,"sourceIP",sourceIP);
|
||||
field_from_json( Obj,"variables", variables);
|
||||
field_from_json( Obj,"managementPolicies", managementPolicies);
|
||||
field_from_json( Obj,"managementRoles", managementRoles);
|
||||
field_from_json( Obj,"maps", maps);
|
||||
field_from_json( Obj,"configurations", configurations);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
@@ -152,16 +142,10 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"design",design);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||
field_to_json( Obj,"contacts",contacts);
|
||||
field_to_json( Obj,"contact",contact);
|
||||
field_to_json( Obj,"location",location);
|
||||
field_to_json( Obj,"rrm",rrm);
|
||||
field_to_json( Obj,"sourceIP",sourceIP);
|
||||
field_to_json( Obj,"variables", variables);
|
||||
field_to_json( Obj,"managementPolicies", managementPolicies);
|
||||
field_to_json( Obj,"managementRoles", managementRoles);
|
||||
field_to_json( Obj,"maps", maps);
|
||||
field_to_json( Obj,"configurations", configurations);
|
||||
field_to_json( Obj,"boards", boards);
|
||||
}
|
||||
|
||||
bool Venue::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -176,16 +160,10 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"design",design);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_from_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||
field_from_json( Obj,"contacts",contacts);
|
||||
field_from_json( Obj,"contact",contact);
|
||||
field_from_json( Obj,"location",location);
|
||||
field_from_json( Obj,"rrm",rrm);
|
||||
field_from_json( Obj,"sourceIP",sourceIP);
|
||||
field_from_json( Obj,"variables", variables);
|
||||
field_from_json( Obj,"managementPolicies", managementPolicies);
|
||||
field_from_json( Obj,"managementRoles", managementRoles);
|
||||
field_from_json( Obj,"maps", maps);
|
||||
field_from_json( Obj,"configurations", configurations);
|
||||
field_from_json( Obj,"boards", boards);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
@@ -193,93 +171,6 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void Operator::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_to_json( Obj,"managementRoles",managementRoles);
|
||||
field_to_json( Obj,"rrm",rrm);
|
||||
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||
field_to_json( Obj,"variables",variables);
|
||||
field_to_json( Obj,"defaultOperator",defaultOperator);
|
||||
field_to_json( Obj,"sourceIP",sourceIP);
|
||||
field_to_json( Obj,"registrationId",registrationId);
|
||||
}
|
||||
|
||||
bool Operator::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_from_json( Obj,"managementRoles",managementRoles);
|
||||
field_from_json( Obj,"rrm",rrm);
|
||||
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||
field_from_json( Obj,"variables",variables);
|
||||
field_from_json( Obj,"defaultOperator",defaultOperator);
|
||||
field_from_json( Obj,"sourceIP",sourceIP);
|
||||
field_from_json( Obj,"registrationId",registrationId);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"operators",operators);
|
||||
}
|
||||
|
||||
bool OperatorList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"operators",operators);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServiceClass::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"operatorId",operatorId);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_to_json( Obj,"cost",cost);
|
||||
field_to_json( Obj,"currency",currency);
|
||||
field_to_json( Obj,"period",period);
|
||||
field_to_json( Obj,"billingCode",billingCode);
|
||||
field_to_json( Obj,"variables",variables);
|
||||
field_to_json( Obj,"defaultService",defaultService);
|
||||
}
|
||||
|
||||
bool ServiceClass::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"operatorId",operatorId);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_from_json( Obj,"cost",cost);
|
||||
field_from_json( Obj,"currency",currency);
|
||||
field_from_json( Obj,"period",period);
|
||||
field_from_json( Obj,"billingCode",billingCode);
|
||||
field_from_json( Obj,"variables",variables);
|
||||
field_from_json( Obj,"defaultService",defaultService);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void ServiceClassList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"serviceClasses",serviceClasses);
|
||||
}
|
||||
|
||||
bool ServiceClassList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"serviceClasses",serviceClasses);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void UserInfoDigest::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"id",id);
|
||||
field_to_json( Obj,"entity",loginId);
|
||||
@@ -302,7 +193,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_to_json( Obj,"users",users);
|
||||
field_to_json( Obj,"entity",entity);
|
||||
field_to_json( Obj,"venue",venue);
|
||||
}
|
||||
|
||||
bool ManagementRole::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -311,7 +201,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_from_json( Obj,"users",users);
|
||||
field_from_json( Obj,"entity",entity);
|
||||
field_from_json( Obj,"venue",venue);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
@@ -360,92 +249,6 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorLocation::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"type",type);
|
||||
field_to_json( Obj,"buildingName",buildingName);
|
||||
field_to_json( Obj,"addressLines",addressLines);
|
||||
field_to_json( Obj,"city",city);
|
||||
field_to_json( Obj,"state",state);
|
||||
field_to_json( Obj,"postal",postal);
|
||||
field_to_json( Obj,"country",country);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"geoCode",geoCode);
|
||||
field_to_json( Obj,"operatorId",operatorId);
|
||||
field_to_json( Obj,"subscriberDeviceId",subscriberDeviceId);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
}
|
||||
|
||||
bool OperatorLocation::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"buildingName",buildingName);
|
||||
field_from_json( Obj,"addressLines",addressLines);
|
||||
field_from_json( Obj,"city",city);
|
||||
field_from_json( Obj,"state",state);
|
||||
field_from_json( Obj,"postal",postal);
|
||||
field_from_json( Obj,"country",country);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"geoCode",geoCode);
|
||||
field_from_json( Obj,"operatorId",operatorId);
|
||||
field_from_json( Obj,"subscriberDeviceId",subscriberDeviceId);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubLocation::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"type",type);
|
||||
field_to_json( Obj,"buildingName",buildingName);
|
||||
field_to_json( Obj,"addressLines",addressLines);
|
||||
field_to_json( Obj,"city",city);
|
||||
field_to_json( Obj,"state",state);
|
||||
field_to_json( Obj,"postal",postal);
|
||||
field_to_json( Obj,"country",country);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"geoCode",geoCode);
|
||||
}
|
||||
|
||||
bool SubLocation::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"buildingName",buildingName);
|
||||
field_from_json( Obj,"addressLines",addressLines);
|
||||
field_from_json( Obj,"city",city);
|
||||
field_from_json( Obj,"state",state);
|
||||
field_from_json( Obj,"postal",postal);
|
||||
field_from_json( Obj,"country",country);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"geoCode",geoCode);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorLocationList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "locations", locations);
|
||||
}
|
||||
|
||||
bool OperatorLocationList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj, "locations", locations);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Contact::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"type", to_string(type));
|
||||
@@ -492,118 +295,21 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorContact::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"type", type);
|
||||
field_to_json( Obj,"title",title);
|
||||
field_to_json( Obj,"salutation",salutation);
|
||||
field_to_json( Obj,"firstname",firstname);
|
||||
field_to_json( Obj,"lastname",lastname);
|
||||
field_to_json( Obj,"initials",initials);
|
||||
field_to_json( Obj,"visual",visual);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_to_json( Obj,"accessPIN",accessPIN);
|
||||
field_to_json( Obj,"operatorId",operatorId);
|
||||
field_to_json( Obj,"subscriberDeviceId",subscriberDeviceId);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
}
|
||||
|
||||
bool OperatorContact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"title",title);
|
||||
field_from_json( Obj,"salutation",salutation);
|
||||
field_from_json( Obj,"firstname",firstname);
|
||||
field_from_json( Obj,"lastname",lastname);
|
||||
field_from_json( Obj,"initials",initials);
|
||||
field_from_json( Obj,"visual",visual);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_from_json( Obj,"accessPIN",accessPIN);
|
||||
field_from_json( Obj,"operatorId",operatorId);
|
||||
field_from_json( Obj,"subscriberDeviceId",subscriberDeviceId);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubContact::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"type", type);
|
||||
field_to_json( Obj,"title",title);
|
||||
field_to_json( Obj,"salutation",salutation);
|
||||
field_to_json( Obj,"firstname",firstname);
|
||||
field_to_json( Obj,"lastname",lastname);
|
||||
field_to_json( Obj,"initials",initials);
|
||||
field_to_json( Obj,"visual",visual);
|
||||
field_to_json( Obj,"mobiles",mobiles);
|
||||
field_to_json( Obj,"phones",phones);
|
||||
field_to_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_to_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_to_json( Obj,"accessPIN",accessPIN);
|
||||
}
|
||||
|
||||
bool SubContact::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"title",title);
|
||||
field_from_json( Obj,"salutation",salutation);
|
||||
field_from_json( Obj,"firstname",firstname);
|
||||
field_from_json( Obj,"lastname",lastname);
|
||||
field_from_json( Obj,"initials",initials);
|
||||
field_from_json( Obj,"visual",visual);
|
||||
field_from_json( Obj,"mobiles",mobiles);
|
||||
field_from_json( Obj,"phones",phones);
|
||||
field_from_json( Obj,"primaryEmail",primaryEmail);
|
||||
field_from_json( Obj,"secondaryEmail",secondaryEmail);
|
||||
field_from_json( Obj,"accessPIN",accessPIN);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void OperatorContactList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "contacts", contacts);
|
||||
}
|
||||
|
||||
bool OperatorContactList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj, "contacts", contacts);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InventoryTag::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj, "serialNumber", serialNumber);
|
||||
field_to_json( Obj, "venue", venue);
|
||||
field_to_json( Obj, "entity", entity);
|
||||
field_to_json( Obj, "subscriber", subscriber);
|
||||
field_to_json( Obj, "deviceType", deviceType);
|
||||
field_to_json( Obj, "qrCode", qrCode);
|
||||
field_to_json( Obj, "geoCode", geoCode);
|
||||
field_to_json( Obj, "location", location);
|
||||
field_to_json( Obj, "contact", contact);
|
||||
field_to_json( Obj, "deviceConfiguration",deviceConfiguration);
|
||||
field_to_json( Obj, "rrm",rrm);
|
||||
field_to_json( Obj, "managementPolicy",managementPolicy);
|
||||
field_to_json( Obj, "state",state);
|
||||
field_to_json( Obj, "devClass",devClass);
|
||||
field_to_json( Obj, "locale",locale);
|
||||
field_to_json( Obj, "realMacAddress",realMacAddress);
|
||||
field_to_json(Obj, "serialNumber", serialNumber);
|
||||
field_to_json(Obj, "venue", venue);
|
||||
field_to_json(Obj, "entity", entity);
|
||||
field_to_json(Obj, "subscriber", subscriber);
|
||||
field_to_json(Obj, "deviceType", deviceType);
|
||||
field_to_json(Obj, "qrCode", qrCode);
|
||||
field_to_json(Obj, "geoCode", geoCode);
|
||||
field_to_json(Obj, "location", location);
|
||||
field_to_json(Obj, "contact", contact);
|
||||
field_to_json( Obj,"deviceConfiguration",deviceConfiguration);
|
||||
field_to_json( Obj,"rrm",rrm);
|
||||
field_to_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_to_json( Obj,"state",state);
|
||||
}
|
||||
|
||||
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -614,7 +320,7 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"entity",entity);
|
||||
field_from_json( Obj,"subscriber",subscriber);
|
||||
field_from_json( Obj,"deviceType",deviceType);
|
||||
field_from_json( Obj,"qrCode", qrCode);
|
||||
field_from_json(Obj, "qrCode", qrCode);
|
||||
field_from_json( Obj,"geoCode",geoCode);
|
||||
field_from_json( Obj,"location",location);
|
||||
field_from_json( Obj,"contact",contact);
|
||||
@@ -622,9 +328,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"rrm",rrm);
|
||||
field_from_json( Obj,"managementPolicy",managementPolicy);
|
||||
field_from_json( Obj,"state",state);
|
||||
field_from_json( Obj,"devClass",devClass);
|
||||
field_from_json( Obj,"locale",locale);
|
||||
field_from_json( Obj,"realMacAddress",realMacAddress);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
@@ -632,26 +335,6 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void InventoryConfigApplyResult::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "appliedConfiguration", appliedConfiguration);
|
||||
field_to_json( Obj, "warnings", warnings);
|
||||
field_to_json( Obj, "errors", errors);
|
||||
field_to_json( Obj, "errorCode", errorCode);
|
||||
}
|
||||
|
||||
bool InventoryConfigApplyResult::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj, "appliedConfiguration", appliedConfiguration);
|
||||
field_from_json( Obj, "warnings", warnings);
|
||||
field_from_json( Obj, "errors", errors);
|
||||
field_from_json( Obj, "errorCode", errorCode);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InventoryTagList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"taglist",taglist);
|
||||
}
|
||||
@@ -659,7 +342,7 @@ namespace OpenWifi::ProvObjects {
|
||||
bool InventoryTagList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"taglist",taglist);
|
||||
return true;
|
||||
return false;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
@@ -696,10 +379,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_to_json( Obj,"rrm",rrm);
|
||||
field_to_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||
field_to_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||
field_to_json( Obj,"subscriberOnly",subscriberOnly);
|
||||
field_to_json( Obj,"entity", entity);
|
||||
field_to_json( Obj,"venue", venue);
|
||||
field_to_json( Obj,"subscriber", subscriber);
|
||||
}
|
||||
|
||||
bool DeviceConfiguration::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -713,10 +392,6 @@ namespace OpenWifi::ProvObjects {
|
||||
field_from_json( Obj,"rrm",rrm);
|
||||
field_from_json( Obj,"firmwareUpgrade",firmwareUpgrade);
|
||||
field_from_json( Obj,"firmwareRCOnly",firmwareRCOnly);
|
||||
field_from_json( Obj,"subscriberOnly",subscriberOnly);
|
||||
field_from_json( Obj,"entity", entity);
|
||||
field_from_json( Obj,"venue", venue);
|
||||
field_from_json( Obj,"subscriber", subscriber);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
@@ -795,16 +470,46 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, ACLACCESS A) {
|
||||
switch(A) {
|
||||
case READ: Obj.set(FieldName,"read"); break;
|
||||
case MODIFY: Obj.set(FieldName,"modify"); break;
|
||||
case CREATE: Obj.set(FieldName,"create"); break;
|
||||
case DELETE: Obj.set(FieldName,"delete"); break;
|
||||
case NONE:
|
||||
default:
|
||||
Obj.set(FieldName,"none");
|
||||
}
|
||||
}
|
||||
|
||||
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, ACLACCESS &A) {
|
||||
if(Obj->has(FieldName)) {
|
||||
auto V = Obj->getValue<std::string>(FieldName);
|
||||
if(V=="read")
|
||||
A = READ;
|
||||
else if(V=="modify")
|
||||
A = MODIFY;
|
||||
else if(V=="create")
|
||||
A = CREATE;
|
||||
else if(V=="delete")
|
||||
A = DELETE;
|
||||
else if(V=="none")
|
||||
A = NONE;
|
||||
else
|
||||
throw Poco::Exception("invalid JSON");
|
||||
}
|
||||
}
|
||||
|
||||
void ObjectACL::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj, "users", users);
|
||||
field_to_json(Obj, "roles", roles);
|
||||
RESTAPI_utils::field_to_json(Obj, "users", users);
|
||||
RESTAPI_utils::field_to_json(Obj, "roles", roles);
|
||||
field_to_json(Obj, "access", access);
|
||||
}
|
||||
|
||||
bool ObjectACL::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj, "users", users);
|
||||
field_from_json(Obj, "roles", roles);
|
||||
RESTAPI_utils::field_from_json(Obj, "users", users);
|
||||
RESTAPI_utils::field_from_json(Obj, "roles", roles);
|
||||
field_from_json(Obj, "access", access);
|
||||
return true;
|
||||
} catch(...) {
|
||||
@@ -814,12 +519,12 @@ namespace OpenWifi::ProvObjects {
|
||||
}
|
||||
|
||||
void ObjectACLList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj, "list", list);
|
||||
RESTAPI_utils::field_to_json(Obj, "list", list);
|
||||
}
|
||||
|
||||
bool ObjectACLList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj, "list", list);
|
||||
RESTAPI_utils::field_from_json(Obj, "list", list);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
@@ -827,15 +532,44 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string to_string(VISIBILITY A) {
|
||||
switch(A) {
|
||||
case PUBLIC: return "public";
|
||||
case SELECT: return "select";
|
||||
case PRIVATE:
|
||||
default:
|
||||
return "private";
|
||||
}
|
||||
}
|
||||
|
||||
void field_to_json(Poco::JSON::Object &Obj, const char * FieldName, VISIBILITY A) {
|
||||
Obj.set(FieldName,to_string(A));
|
||||
}
|
||||
|
||||
VISIBILITY visibility_from_string(const std::string &V) {
|
||||
if(V=="public")
|
||||
return PUBLIC;
|
||||
else if(V=="select")
|
||||
return SELECT;
|
||||
else if(V=="private")
|
||||
return PRIVATE;
|
||||
throw Poco::Exception("invalid json");
|
||||
}
|
||||
|
||||
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char * FieldName, VISIBILITY &A) {
|
||||
if(Obj->has(FieldName)) {
|
||||
auto V = Obj->getValue<std::string>(FieldName);
|
||||
A = visibility_from_string(V);
|
||||
}
|
||||
}
|
||||
|
||||
void Map::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"data",data);
|
||||
field_to_json( Obj,"entity",entity);
|
||||
field_to_json( Obj,"creator",creator);
|
||||
RESTAPI_utils::field_to_json( Obj,"data",data);
|
||||
RESTAPI_utils::field_to_json( Obj,"entity",entity);
|
||||
RESTAPI_utils::field_to_json( Obj,"creator",creator);
|
||||
field_to_json( Obj,"visibility",visibility);
|
||||
field_to_json( Obj,"access",access);
|
||||
field_to_json( Obj,"managementPolicy", managementPolicy);
|
||||
field_to_json( Obj,"venue", venue);
|
||||
RESTAPI_utils::field_to_json( Obj,"access",access);
|
||||
}
|
||||
|
||||
bool Map::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -844,24 +578,8 @@ namespace OpenWifi::ProvObjects {
|
||||
RESTAPI_utils::field_from_json( Obj,"data",data);
|
||||
RESTAPI_utils::field_from_json( Obj,"entity",entity);
|
||||
RESTAPI_utils::field_from_json( Obj,"creator",creator);
|
||||
RESTAPI_utils::field_from_json( Obj,"visibility",visibility);
|
||||
field_from_json( Obj,"visibility",visibility);
|
||||
RESTAPI_utils::field_from_json( Obj,"access",access);
|
||||
RESTAPI_utils::field_from_json( Obj,"managementPolicy", managementPolicy);
|
||||
RESTAPI_utils::field_from_json( Obj,"venue", venue);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SerialNumberList::to_json(Poco::JSON::Object &Obj) const {
|
||||
RESTAPI_utils::field_to_json( Obj,"serialNumbers",serialNumbers);
|
||||
}
|
||||
|
||||
bool SerialNumberList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
RESTAPI_utils::field_from_json( Obj,"serialNumbers",serialNumbers);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
@@ -883,199 +601,6 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void SignupEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"email", email);
|
||||
field_to_json( Obj,"userId", userId);
|
||||
field_to_json( Obj,"macAddress", macAddress);
|
||||
field_to_json( Obj,"serialNumber", serialNumber);
|
||||
field_to_json( Obj,"submitted", submitted);
|
||||
field_to_json( Obj,"completed", completed);
|
||||
field_to_json( Obj,"status", status);
|
||||
field_to_json( Obj,"error", error);
|
||||
field_to_json( Obj,"statusCode", statusCode);
|
||||
field_to_json( Obj,"deviceID", deviceID);
|
||||
field_to_json( Obj,"registrationId",registrationId);
|
||||
}
|
||||
|
||||
bool SignupEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"email", email);
|
||||
field_from_json( Obj,"userId", userId);
|
||||
field_from_json( Obj,"macAddress", macAddress);
|
||||
field_from_json( Obj,"serialNumber", serialNumber);
|
||||
field_from_json( Obj,"submitted", submitted);
|
||||
field_from_json( Obj,"completed", completed);
|
||||
field_from_json( Obj,"status", status);
|
||||
field_from_json( Obj,"error", error);
|
||||
field_from_json( Obj,"statusCode", statusCode);
|
||||
field_from_json( Obj,"deviceID", deviceID);
|
||||
field_from_json( Obj,"registrationId",registrationId);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Variable::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"type", type);
|
||||
field_to_json( Obj,"weight", weight);
|
||||
field_to_json( Obj,"prefix", prefix);
|
||||
field_to_json( Obj,"value", value);
|
||||
}
|
||||
|
||||
bool Variable::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"type", type);
|
||||
field_from_json( Obj,"weight", weight);
|
||||
field_from_json( Obj,"prefix", prefix);
|
||||
field_from_json( Obj,"value", value);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VariableList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"variables", variables);
|
||||
}
|
||||
|
||||
bool VariableList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"variables", variables);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VariableBlock::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"variables", variables);
|
||||
field_to_json( Obj,"entity", entity);
|
||||
field_to_json( Obj,"venue", venue);
|
||||
field_to_json( Obj,"subscriber", subscriber);
|
||||
field_to_json( Obj,"inventory", inventory);
|
||||
field_to_json( Obj,"configurations", configurations);
|
||||
field_to_json( Obj,"managementPolicy", managementPolicy);
|
||||
}
|
||||
|
||||
bool VariableBlock::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"variables", variables);
|
||||
field_from_json( Obj,"entity", entity);
|
||||
field_from_json( Obj,"venue", venue);
|
||||
field_from_json( Obj,"subscriber", subscriber);
|
||||
field_from_json( Obj,"inventory", inventory);
|
||||
field_from_json( Obj,"configurations", configurations);
|
||||
field_from_json( Obj,"managementPolicy", managementPolicy);
|
||||
return true;
|
||||
} catch(...) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VariableBlockList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"variableBlocks", variableBlocks);
|
||||
}
|
||||
|
||||
bool VariableBlockList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"variableBlocks", variableBlocks);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubscriberDevice::to_json(Poco::JSON::Object &Obj) const {
|
||||
info.to_json(Obj);
|
||||
field_to_json( Obj,"serialNumber", serialNumber);
|
||||
field_to_json( Obj,"deviceType", deviceType);
|
||||
field_to_json( Obj,"operatorId", operatorId);
|
||||
field_to_json( Obj,"subscriberId", subscriberId);
|
||||
field_to_json( Obj,"location", location);
|
||||
field_to_json( Obj,"contact", contact);
|
||||
field_to_json( Obj,"managementPolicy", managementPolicy);
|
||||
field_to_json( Obj,"serviceClass", serviceClass);
|
||||
field_to_json( Obj,"qrCode", qrCode);
|
||||
field_to_json( Obj,"geoCode", geoCode);
|
||||
field_to_json( Obj,"rrm", rrm);
|
||||
field_to_json( Obj,"state", state);
|
||||
field_to_json( Obj,"locale", locale);
|
||||
field_to_json( Obj,"billingCode", billingCode);
|
||||
field_to_json( Obj,"configuration", configuration);
|
||||
field_to_json( Obj,"suspended", suspended);
|
||||
field_to_json( Obj,"realMacAddress", realMacAddress);
|
||||
}
|
||||
|
||||
bool SubscriberDevice::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
info.from_json(Obj);
|
||||
field_from_json( Obj,"serialNumber", serialNumber);
|
||||
field_from_json( Obj,"deviceType", deviceType);
|
||||
field_from_json( Obj,"operatorId", operatorId);
|
||||
field_from_json( Obj,"subscriberId", subscriberId);
|
||||
field_from_json( Obj,"location", location);
|
||||
field_from_json( Obj,"contact", contact);
|
||||
field_from_json( Obj,"managementPolicy", managementPolicy);
|
||||
field_from_json( Obj,"serviceClass", serviceClass);
|
||||
field_from_json( Obj,"qrCode", qrCode);
|
||||
field_from_json( Obj,"geoCode", geoCode);
|
||||
field_from_json( Obj,"rrm", rrm);
|
||||
field_from_json( Obj,"state", state);
|
||||
field_from_json( Obj,"locale", locale);
|
||||
field_from_json( Obj,"billingCode", billingCode);
|
||||
field_from_json( Obj,"configuration", configuration);
|
||||
field_from_json( Obj,"suspended", suspended);
|
||||
field_from_json( Obj,"realMacAddress", realMacAddress);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void SubscriberDeviceList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"subscriberDevices", subscriberDevices);
|
||||
}
|
||||
|
||||
bool SubscriberDeviceList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj,"subscriberDevices", subscriberDevices);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void VenueDeviceList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"id",id);
|
||||
field_to_json(Obj,"name",name);
|
||||
field_to_json(Obj,"description",description);
|
||||
field_to_json(Obj,"devices",devices);
|
||||
}
|
||||
|
||||
bool VenueDeviceList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"name",name);
|
||||
field_from_json(Obj,"description",description);
|
||||
field_from_json(Obj,"devices",devices);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||
uint64_t Now = std::time(nullptr);
|
||||
if(O->has("name"))
|
||||
@@ -1098,7 +623,7 @@ namespace OpenWifi::ProvObjects {
|
||||
}
|
||||
|
||||
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||
uint64_t Now = OpenWifi::Now();
|
||||
uint64_t Now = std::time(nullptr);
|
||||
if(O->has("name"))
|
||||
I.name = O->get("name").toString();
|
||||
|
||||
@@ -1120,54 +645,5 @@ namespace OpenWifi::ProvObjects {
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||
I.modified = I.created = OpenWifi::Now();
|
||||
I.id = MicroService::CreateUUID();
|
||||
return true;
|
||||
}
|
||||
|
||||
void WebSocketNotificationContent::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"title",title);
|
||||
field_to_json(Obj,"type",type);
|
||||
field_to_json(Obj,"success",success);
|
||||
field_to_json(Obj,"errors",errors);
|
||||
field_to_json(Obj,"warnings",warnings);
|
||||
field_to_json(Obj,"timeStamp",timeStamp);
|
||||
field_to_json(Obj,"details",details);
|
||||
}
|
||||
|
||||
bool WebSocketNotificationContent::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"title",title);
|
||||
field_from_json(Obj,"type",type);
|
||||
field_from_json(Obj,"success",success);
|
||||
field_from_json(Obj,"errors",errors);
|
||||
field_from_json(Obj,"warnings",warnings);
|
||||
field_from_json(Obj,"timeStamp",timeStamp);
|
||||
field_from_json(Obj,"details",details);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WebSocketNotification::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"notification_id",notification_id);
|
||||
field_to_json(Obj,"content",content);
|
||||
}
|
||||
|
||||
bool WebSocketNotification::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"notification_id",notification_id);
|
||||
field_from_json(Obj,"content",content);
|
||||
return true;
|
||||
} catch(...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,13 +33,6 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SerialNumberList {
|
||||
Types::UUIDvec_t serialNumbers;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct ManagementPolicyEntry {
|
||||
Types::UUIDvec_t users;
|
||||
Types::UUIDvec_t resources;
|
||||
@@ -55,7 +48,6 @@ namespace OpenWifi::ProvObjects {
|
||||
std::vector<ManagementPolicyEntry> entries;
|
||||
Types::StringVec inUse;
|
||||
Types::UUID_t entity;
|
||||
Types::UUID_t venue;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -74,11 +66,6 @@ namespace OpenWifi::ProvObjects {
|
||||
Types::UUIDvec_t devices;
|
||||
std::string rrm;
|
||||
Types::StringVec sourceIP;
|
||||
Types::UUIDvec_t variables;
|
||||
Types::UUIDvec_t managementPolicies;
|
||||
Types::UUIDvec_t managementRoles;
|
||||
Types::UUIDvec_t maps;
|
||||
Types::UUIDvec_t configurations;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -105,16 +92,10 @@ namespace OpenWifi::ProvObjects {
|
||||
DiGraph topology;
|
||||
std::string design;
|
||||
Types::UUIDvec_t deviceConfiguration;
|
||||
Types::UUIDvec_t contacts;
|
||||
std::string contact;
|
||||
std::string location;
|
||||
std::string rrm;
|
||||
Types::StringVec sourceIP;
|
||||
Types::UUIDvec_t variables;
|
||||
Types::UUIDvec_t configurations;
|
||||
Types::UUIDvec_t maps;
|
||||
Types::UUIDvec_t managementPolicies;
|
||||
Types::UUIDvec_t managementRoles;
|
||||
Types::UUIDvec_t boards;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -136,7 +117,6 @@ namespace OpenWifi::ProvObjects {
|
||||
Types::UUIDvec_t users;
|
||||
Types::StringVec inUse;
|
||||
Types::UUID_t entity;
|
||||
Types::UUID_t venue;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -200,51 +180,6 @@ namespace OpenWifi::ProvObjects {
|
||||
};
|
||||
typedef std::vector<Location> LocationVec;
|
||||
|
||||
struct OperatorLocation {
|
||||
ObjectInfo info;
|
||||
std::string type;
|
||||
std::string buildingName;
|
||||
Types::StringVec addressLines;
|
||||
std::string city;
|
||||
std::string state;
|
||||
std::string postal;
|
||||
std::string country;
|
||||
Types::StringVec phones;
|
||||
Types::StringVec mobiles;
|
||||
std::string geoCode;
|
||||
Types::UUID_t operatorId;
|
||||
Types::UUID_t subscriberDeviceId;
|
||||
Types::UUID_t managementPolicy;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<Location> LocationVec;
|
||||
|
||||
struct SubLocation {
|
||||
std::string type;
|
||||
std::string buildingName;
|
||||
Types::StringVec addressLines;
|
||||
std::string city;
|
||||
std::string state;
|
||||
std::string postal;
|
||||
std::string country;
|
||||
Types::StringVec phones;
|
||||
Types::StringVec mobiles;
|
||||
std::string geoCode;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct OperatorLocationList {
|
||||
std::vector<OperatorLocation> locations;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
|
||||
enum ContactType {
|
||||
CT_SUBSCRIBER, CT_USER, CT_INSTALLER, CT_CSR, CT_MANAGER,
|
||||
CT_BUSINESSOWNER, CT_TECHNICIAN, CT_CORPORATE, CT_UNKNOWN
|
||||
@@ -308,55 +243,6 @@ namespace OpenWifi::ProvObjects {
|
||||
};
|
||||
typedef std::vector<Contact> ContactVec;
|
||||
|
||||
struct OperatorContact {
|
||||
ObjectInfo info;
|
||||
std::string type;
|
||||
std::string title;
|
||||
std::string salutation;
|
||||
std::string firstname;
|
||||
std::string lastname;
|
||||
std::string initials;
|
||||
std::string visual;
|
||||
Types::StringVec mobiles;
|
||||
Types::StringVec phones;
|
||||
std::string primaryEmail;
|
||||
std::string secondaryEmail;
|
||||
std::string accessPIN;
|
||||
Types::UUID_t operatorId;
|
||||
Types::UUID_t subscriberDeviceId;
|
||||
Types::UUID_t managementPolicy;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SubContact {
|
||||
std::string type;
|
||||
std::string title;
|
||||
std::string salutation;
|
||||
std::string firstname;
|
||||
std::string lastname;
|
||||
std::string initials;
|
||||
std::string visual;
|
||||
Types::StringVec mobiles;
|
||||
Types::StringVec phones;
|
||||
std::string primaryEmail;
|
||||
std::string secondaryEmail;
|
||||
std::string accessPIN;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct OperatorContactList {
|
||||
std::vector<OperatorContact> contacts;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
typedef std::vector<OperatorContact> OperatorContactVec;
|
||||
|
||||
struct DeviceConfigurationElement {
|
||||
std::string name;
|
||||
std::string description;
|
||||
@@ -369,26 +255,21 @@ namespace OpenWifi::ProvObjects {
|
||||
typedef std::vector<DeviceConfigurationElement> DeviceConfigurationElementVec;
|
||||
|
||||
struct DeviceConfiguration {
|
||||
ObjectInfo info;
|
||||
ObjectInfo info;
|
||||
Types::UUID_t managementPolicy;
|
||||
Types::StringVec deviceTypes;
|
||||
DeviceConfigurationElementVec configuration;
|
||||
Types::StringVec inUse;
|
||||
Types::UUIDvec_t variables;
|
||||
Types::StringPairVec variables;
|
||||
std::string rrm;
|
||||
std::string firmwareUpgrade;
|
||||
bool firmwareRCOnly=false;
|
||||
bool subscriberOnly=false;
|
||||
std::string venue;
|
||||
std::string entity;
|
||||
std::string subscriber;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<DeviceConfiguration> DeviceConfigurationVec;
|
||||
|
||||
|
||||
struct InventoryTag {
|
||||
ObjectInfo info;
|
||||
std::string serialNumber;
|
||||
@@ -404,9 +285,6 @@ namespace OpenWifi::ProvObjects {
|
||||
std::string rrm;
|
||||
Types::UUID_t managementPolicy;
|
||||
std::string state;
|
||||
std::string devClass;
|
||||
std::string locale;
|
||||
std::string realMacAddress;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -421,15 +299,6 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct InventoryConfigApplyResult {
|
||||
std::string appliedConfiguration;
|
||||
Types::StringVec errors;
|
||||
Types::StringVec warnings;
|
||||
uint64_t errorCode;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Report {
|
||||
uint64_t snapShot=0;
|
||||
@@ -464,20 +333,20 @@ namespace OpenWifi::ProvObjects {
|
||||
};
|
||||
|
||||
struct UuidList {
|
||||
Types::UUIDvec_t list;
|
||||
std::vector<std::string> list;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum ACLACCESS {
|
||||
NONE = 0, READ=1, MODIFY=2, CREATE=3, DELETE=4
|
||||
NONE, READ, MODIFY, CREATE, DELETE
|
||||
};
|
||||
|
||||
struct ObjectACL {
|
||||
UuidList users;
|
||||
UuidList roles;
|
||||
uint64_t access = (uint64_t) NONE;
|
||||
ACLACCESS access = NONE;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -490,15 +359,20 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum VISIBILITY {
|
||||
PUBLIC, PRIVATE, SELECT
|
||||
};
|
||||
|
||||
std::string to_string(VISIBILITY A);
|
||||
VISIBILITY visibility_from_string(const std::string &V);
|
||||
|
||||
struct Map {
|
||||
ObjectInfo info;
|
||||
std::string data;
|
||||
std::string entity;
|
||||
std::string creator;
|
||||
std::string visibility{"private"};
|
||||
VISIBILITY visibility = PRIVATE;
|
||||
ObjectACLList access;
|
||||
Types::UUID_t managementPolicy;
|
||||
std::string venue;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -511,181 +385,6 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum SignupStatusCodes {
|
||||
SignupCreated = 0 ,
|
||||
SignupWaitingForEmail,
|
||||
SignupWaitingForDevice,
|
||||
SignupSuccess,
|
||||
SignupFailure,
|
||||
SignupCanceled,
|
||||
SignupTimedOut
|
||||
};
|
||||
|
||||
struct SignupEntry {
|
||||
ObjectInfo info;
|
||||
std::string email;
|
||||
std::string userId;
|
||||
std::string macAddress;
|
||||
std::string serialNumber;
|
||||
uint64_t submitted = 0 ;
|
||||
uint64_t completed = 0 ;
|
||||
std::string status;
|
||||
uint64_t error=0;
|
||||
uint64_t statusCode=0;
|
||||
std::string deviceID;
|
||||
std::string registrationId;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Variable {
|
||||
std::string type;
|
||||
uint64_t weight=0;
|
||||
std::string prefix;
|
||||
std::string value;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct VariableList {
|
||||
std::vector<Variable> variables;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct VariableBlock {
|
||||
ObjectInfo info;
|
||||
std::vector<Variable> variables;
|
||||
std::string entity;
|
||||
std::string venue;
|
||||
std::string subscriber;
|
||||
std::string inventory;
|
||||
Types::UUIDvec_t configurations;
|
||||
Types::UUID_t managementPolicy;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct VariableBlockList {
|
||||
std::vector<VariableBlock> variableBlocks;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Operator {
|
||||
ObjectInfo info;
|
||||
Types::UUID_t managementPolicy;
|
||||
Types::UUIDvec_t managementRoles;
|
||||
std::string rrm;
|
||||
std::string firmwareUpgrade;
|
||||
bool firmwareRCOnly=true;
|
||||
std::vector<Variable> variables;
|
||||
bool defaultOperator=false;
|
||||
Types::StringVec sourceIP;
|
||||
std::string registrationId;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct OperatorList {
|
||||
std::vector<Operator> operators;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct VenueDeviceList {
|
||||
std::string id;
|
||||
std::string name;
|
||||
std::string description;
|
||||
Types::UUIDvec_t devices;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct ServiceClass {
|
||||
ObjectInfo info;
|
||||
Types::UUID_t operatorId;
|
||||
Types::UUID_t managementPolicy;
|
||||
double cost=0.0;
|
||||
std::string currency;
|
||||
std::string period;
|
||||
std::string billingCode;
|
||||
std::vector<Variable> variables;
|
||||
bool defaultService=false;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct ServiceClassList {
|
||||
std::vector<ServiceClass> serviceClasses;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SubscriberDevice {
|
||||
ObjectInfo info;
|
||||
std::string serialNumber;
|
||||
std::string deviceType;
|
||||
Types::UUID_t operatorId;
|
||||
Types::UUID_t subscriberId;
|
||||
SubLocation location;
|
||||
SubContact contact;
|
||||
Types::UUID_t managementPolicy;
|
||||
Types::UUID_t serviceClass;
|
||||
std::string qrCode;
|
||||
std::string geoCode;
|
||||
std::string rrm;
|
||||
std::string state;
|
||||
std::string locale;
|
||||
std::string billingCode;
|
||||
DeviceConfigurationElementVec configuration;
|
||||
bool suspended=false;
|
||||
std::string realMacAddress;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SubscriberDeviceList {
|
||||
std::vector<SubscriberDevice> subscriberDevices;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct WebSocketNotificationContent {
|
||||
std::string title,
|
||||
type,
|
||||
details;
|
||||
std::vector<std::string> success,
|
||||
errors,
|
||||
warnings;
|
||||
uint64_t timeStamp=std::time(nullptr);
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct WebSocketNotification {
|
||||
inline static uint64_t xid=1;
|
||||
uint64_t notification_id=++xid;
|
||||
WebSocketNotificationContent content;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||
};
|
||||
|
||||
@@ -95,7 +95,6 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "PortalLogin", PortalLogin_);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: AclTemplate" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +130,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "userMustChangePassword",userMustChangePassword);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: WebToken" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -142,14 +141,14 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"primary", primary);
|
||||
}
|
||||
|
||||
bool MobilePhoneNumber::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool MobilePhoneNumber::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"number",number);
|
||||
field_from_json(Obj,"verified",verified);
|
||||
field_from_json(Obj,"primary",primary);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: MobilePhoneNumber" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -159,13 +158,13 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"method", method);
|
||||
}
|
||||
|
||||
bool MfaAuthInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool MfaAuthInfo::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"enabled",enabled);
|
||||
field_from_json(Obj,"method",method);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: MfaAuthInfo" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -176,14 +175,14 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj, "authenticatorSecret", authenticatorSecret);
|
||||
}
|
||||
|
||||
bool UserLoginLoginExtensions::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool UserLoginLoginExtensions::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj, "mobiles",mobiles);
|
||||
field_from_json(Obj, "mfa",mfa);
|
||||
field_from_json(Obj,"mobiles",mobiles);
|
||||
field_from_json(Obj,"mfa",mfa);
|
||||
field_from_json(Obj, "authenticatorSecret", authenticatorSecret);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: UserLoginLoginExtensions" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -195,7 +194,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj, "method", method);
|
||||
}
|
||||
|
||||
bool MFAChallengeRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool MFAChallengeRequest::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"uuid",uuid);
|
||||
field_from_json(Obj,"question",question);
|
||||
@@ -203,7 +202,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"method",method);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: MFAChallengeRequest" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -211,15 +210,16 @@ namespace OpenWifi::SecurityObjects {
|
||||
void MFAChallengeResponse::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj, "uuid", uuid);
|
||||
field_to_json(Obj, "answer", answer);
|
||||
|
||||
}
|
||||
|
||||
bool MFAChallengeResponse::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool MFAChallengeResponse::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"uuid",uuid);
|
||||
field_from_json(Obj,"answer",answer);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: MFAChallengeResponse" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -257,7 +257,6 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"oauthType",oauthType);
|
||||
field_to_json(Obj,"oauthUserInfo",oauthUserInfo);
|
||||
field_to_json(Obj,"modified",modified);
|
||||
field_to_json(Obj,"signingUp",signingUp);
|
||||
};
|
||||
|
||||
bool UserInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -293,28 +292,13 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"oauthType",oauthType);
|
||||
field_from_json(Obj,"oauthUserInfo",oauthUserInfo);
|
||||
field_from_json(Obj,"modified",modified);
|
||||
field_from_json(Obj,"signingUp",signingUp);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
std::cout << "Cannot parse: UserInfo" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
void UserInfoList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"users",users);
|
||||
}
|
||||
|
||||
bool UserInfoList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"users",users);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: InternalServiceInfo" << std::endl;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InternalServiceInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj,"privateURI",privateURI);
|
||||
field_to_json(Obj,"publicURI",publicURI);
|
||||
@@ -328,7 +312,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"token",token);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: InternalServiceInfo" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -346,7 +330,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "services", services);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: InternalSystemServices" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -368,7 +352,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "authenticationType", authenticationType);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: SystemEndpoint" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
};
|
||||
@@ -382,7 +366,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "endpoints", endpoints);
|
||||
return true;
|
||||
} catch (...) {
|
||||
std::cout << "Cannot parse: SystemEndpointList" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -401,7 +385,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj, "userInfo", userinfo);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: UserInfoAndPolicy" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -412,14 +396,14 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"note", note);
|
||||
}
|
||||
|
||||
bool NoteInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool NoteInfo::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"created",created);
|
||||
field_from_json(Obj,"created",created);
|
||||
field_from_json(Obj,"createdBy",createdBy);
|
||||
field_from_json(Obj,"note", note);
|
||||
field_from_json(Obj,"note",note);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: NoteInfo" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -436,7 +420,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
}
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: MergeNotes" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -454,13 +438,13 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json<ResourceAccessType>(Obj,"access", access, ResourceAccessTypeToString);
|
||||
}
|
||||
|
||||
bool ProfileAction::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool ProfileAction::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"resource",resource);
|
||||
field_from_json<ResourceAccessType>(Obj,"access",access,ResourceAccessTypeFromString );
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: ProfileAction" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -474,7 +458,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"notes", notes);
|
||||
}
|
||||
|
||||
bool SecurityProfile::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool SecurityProfile::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"name",name);
|
||||
@@ -484,7 +468,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"notes",notes);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: SecurityProfile" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -493,12 +477,12 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj, "profiles", profiles);
|
||||
}
|
||||
|
||||
bool SecurityProfileList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool SecurityProfileList::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"profiles",profiles);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: SecurityProfileList" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -519,7 +503,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"userAction",userAction);
|
||||
}
|
||||
|
||||
bool ActionLink::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool ActionLink::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"action",action);
|
||||
@@ -536,7 +520,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"userAction",userAction);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: ActionLink" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -547,14 +531,14 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"data",data);
|
||||
}
|
||||
|
||||
bool Preferences::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool Preferences::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"modified",modified);
|
||||
field_from_json(Obj,"data",data);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: Preferences" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -566,7 +550,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"email",email);
|
||||
}
|
||||
|
||||
bool SubMfaConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool SubMfaConfig::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"id",id);
|
||||
field_from_json(Obj,"type",type);
|
||||
@@ -574,7 +558,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"email",email);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: SubMfaConfig" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -590,7 +574,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_to_json(Obj,"revocationDate",revocationDate);
|
||||
}
|
||||
|
||||
bool Token::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
bool Token::from_json(Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj,"token",token);
|
||||
field_from_json(Obj,"refreshToken",refreshToken);
|
||||
@@ -602,7 +586,7 @@ namespace OpenWifi::SecurityObjects {
|
||||
field_from_json(Obj,"revocationDate",revocationDate);
|
||||
return true;
|
||||
} catch(...) {
|
||||
std::cout << "Cannot parse: Token" << std::endl;
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -54,12 +54,11 @@ namespace OpenWifi {
|
||||
std::string UserTypeToString(USER_ROLE U);
|
||||
|
||||
struct NoteInfo {
|
||||
uint64_t created=0; // = std::time(nullptr);
|
||||
uint64_t created = std::time(nullptr);
|
||||
std::string createdBy;
|
||||
std::string note;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<NoteInfo> NoteInfoVec;
|
||||
|
||||
@@ -69,7 +68,7 @@ namespace OpenWifi {
|
||||
bool primary = false;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct MfaAuthInfo {
|
||||
@@ -77,7 +76,7 @@ namespace OpenWifi {
|
||||
std::string method;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct UserLoginLoginExtensions {
|
||||
@@ -86,7 +85,7 @@ namespace OpenWifi {
|
||||
std::string authenticatorSecret;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct MFAChallengeRequest {
|
||||
@@ -96,7 +95,7 @@ namespace OpenWifi {
|
||||
uint64_t created = std::time(nullptr);
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct MFAChallengeResponse {
|
||||
@@ -104,7 +103,7 @@ namespace OpenWifi {
|
||||
std::string answer;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct UserInfo {
|
||||
@@ -139,20 +138,12 @@ namespace OpenWifi {
|
||||
std::string oauthType;
|
||||
std::string oauthUserInfo;
|
||||
uint64_t modified;
|
||||
std::string signingUp;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<UserInfo> UserInfoVec;
|
||||
|
||||
struct UserInfoList {
|
||||
std::vector<UserInfo> users;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
// bool append_from_json(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||
bool MergeNotes(Poco::JSON::Object::Ptr Obj, const UserInfo &UInfo, NoteInfoVec & Notes);
|
||||
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes);
|
||||
@@ -216,7 +207,7 @@ namespace OpenWifi {
|
||||
std::string resource;
|
||||
ResourceAccessType access;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<ProfileAction> ProfileActionVec;
|
||||
|
||||
@@ -228,22 +219,21 @@ namespace OpenWifi {
|
||||
std::string role;
|
||||
NoteInfoVec notes;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
typedef std::vector<SecurityProfile> SecurityProfileVec;
|
||||
|
||||
struct SecurityProfileList {
|
||||
SecurityProfileVec profiles;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
enum LinkActions {
|
||||
FORGOT_PASSWORD=1,
|
||||
VERIFY_EMAIL,
|
||||
SUB_FORGOT_PASSWORD,
|
||||
SUB_VERIFY_EMAIL,
|
||||
SUB_SIGNUP
|
||||
SUB_VERIFY_EMAIL
|
||||
};
|
||||
|
||||
struct ActionLink {
|
||||
@@ -262,7 +252,7 @@ namespace OpenWifi {
|
||||
bool userAction=true;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Preferences {
|
||||
@@ -270,7 +260,7 @@ namespace OpenWifi {
|
||||
uint64_t modified;
|
||||
Types::StringPairVec data;
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct SubMfaConfig {
|
||||
@@ -280,7 +270,7 @@ namespace OpenWifi {
|
||||
std::string email;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Token {
|
||||
@@ -294,7 +284,7 @@ namespace OpenWifi {
|
||||
uint64_t revocationDate=0;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
bool from_json(Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Avatar {
|
||||
@@ -302,8 +292,7 @@ namespace OpenWifi {
|
||||
std::string type;
|
||||
uint64_t created=0;
|
||||
std::string name;
|
||||
// Poco::Data::LOB<char> avatar;
|
||||
Poco::Data::BLOB avatar;
|
||||
Poco::Data::LOB<char> avatar;
|
||||
};
|
||||
|
||||
struct LoginRecordInfo {
|
||||
|
||||
@@ -433,8 +433,6 @@ namespace OpenWifi::SubObjects {
|
||||
field_to_json(Obj, "rates", rates);
|
||||
field_to_json(Obj, "he", he);
|
||||
field_to_json(Obj, "rawInfo", rawInfo);
|
||||
field_to_json(Obj, "allowDFS", allowDFS);
|
||||
field_to_json(Obj, "mimo", mimo);
|
||||
}
|
||||
|
||||
bool RadioInformation::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
@@ -454,8 +452,6 @@ namespace OpenWifi::SubObjects {
|
||||
field_from_json(Obj, "rates", rates);
|
||||
field_from_json(Obj, "he", he);
|
||||
field_from_json(Obj, "rawInfo", rawInfo);
|
||||
field_from_json(Obj, "allowDFS", allowDFS);
|
||||
field_from_json(Obj, "mimo", mimo);
|
||||
return true;
|
||||
} catch (...) {
|
||||
}
|
||||
@@ -465,7 +461,6 @@ namespace OpenWifi::SubObjects {
|
||||
void AccessPoint::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json(Obj, "id", id);
|
||||
field_to_json(Obj, "macAddress", macAddress);
|
||||
field_to_json(Obj, "serialNumber", serialNumber);
|
||||
field_to_json(Obj, "name", name);
|
||||
field_to_json(Obj, "deviceType", deviceType);
|
||||
field_to_json(Obj, "subscriberDevices", subscriberDevices);
|
||||
@@ -478,19 +473,12 @@ namespace OpenWifi::SubObjects {
|
||||
field_to_json(Obj, "radios", radios);
|
||||
field_to_json(Obj, "automaticUpgrade", automaticUpgrade);
|
||||
field_to_json(Obj, "configurationUUID", configurationUUID);
|
||||
field_to_json(Obj, "currentFirmware", currentFirmware);
|
||||
field_to_json(Obj, "currentFirmwareDate", currentFirmwareDate);
|
||||
field_to_json(Obj, "latestFirmware", latestFirmware);
|
||||
field_to_json(Obj, "latestFirmwareDate", latestFirmwareDate);
|
||||
field_to_json(Obj, "newFirmwareAvailable", newFirmwareAvailable);
|
||||
field_to_json(Obj, "latestFirmwareURI", latestFirmwareURI);
|
||||
}
|
||||
|
||||
bool AccessPoint::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json(Obj, "id", id);
|
||||
field_from_json(Obj, "macAddress", macAddress);
|
||||
field_from_json(Obj, "serialNumber", serialNumber);
|
||||
field_from_json(Obj, "name", name);
|
||||
field_from_json(Obj, "deviceType", deviceType);
|
||||
field_from_json(Obj, "subscriberDevices", subscriberDevices);
|
||||
@@ -503,12 +491,6 @@ namespace OpenWifi::SubObjects {
|
||||
field_from_json(Obj, "radios", radios);
|
||||
field_from_json(Obj, "automaticUpgrade", automaticUpgrade);
|
||||
field_from_json(Obj, "configurationUUID", configurationUUID);
|
||||
field_from_json(Obj, "currentFirmware", currentFirmware);
|
||||
field_from_json(Obj, "currentFirmwareDate", currentFirmwareDate);
|
||||
field_from_json(Obj, "latestFirmware", latestFirmware);
|
||||
field_from_json(Obj, "latestFirmwareDate", latestFirmwareDate);
|
||||
field_from_json(Obj, "newFirmwareAvailable", newFirmwareAvailable);
|
||||
field_from_json(Obj, "latestFirmwareURI", latestFirmwareURI);
|
||||
return true;
|
||||
} catch (...) {
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace OpenWifi::SubObjects {
|
||||
int subnetMaskV6=0;
|
||||
std::string startIPV6;
|
||||
std::string endIPV6;
|
||||
std::string leaseTime;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
@@ -239,8 +238,6 @@ namespace OpenWifi::SubObjects {
|
||||
uint64_t maximumClients = 64;
|
||||
RadioRates rates;
|
||||
RadioHE he;
|
||||
bool allowDFS=false;
|
||||
std::string mimo;
|
||||
std::vector<std::string> rawInfo;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
@@ -250,7 +247,6 @@ namespace OpenWifi::SubObjects {
|
||||
struct AccessPoint {
|
||||
std::string id;
|
||||
std::string macAddress;
|
||||
std::string serialNumber;
|
||||
std::string name;
|
||||
std::string deviceType;
|
||||
SubscriberDeviceList subscriberDevices;
|
||||
@@ -263,12 +259,6 @@ namespace OpenWifi::SubObjects {
|
||||
std::vector<RadioInformation> radios;
|
||||
bool automaticUpgrade = true;
|
||||
std::string configurationUUID;
|
||||
std::string currentFirmware;
|
||||
uint64_t currentFirmwareDate;
|
||||
std::string latestFirmware;
|
||||
uint64_t latestFirmwareDate;
|
||||
bool newFirmwareAvailable;
|
||||
std::string latestFirmwareURI;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
|
||||
@@ -10,27 +10,27 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
void Archiver::onTimer([[maybe_unused]] Poco::Timer &timer){
|
||||
auto now = OpenWifi::Now();
|
||||
void Archiver::onTimer(Poco::Timer &timer){
|
||||
auto Now = std::time(nullptr);
|
||||
for(const auto &i:DBs_) {
|
||||
if (!Poco::icompare(i.DBName, "healthchecks")) {
|
||||
Logger().information("Archiving HealthChecks...");
|
||||
StorageService()->RemoveHealthChecksRecordsOlderThan(
|
||||
now - (i.HowManyDays * 24 * 60 * 60));
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "statistics")) {
|
||||
Logger().information("Archiving Statistics...");
|
||||
StorageService()->RemoveStatisticsRecordsOlderThan(
|
||||
now - (i.HowManyDays * 24 * 60 * 60));
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "devicelogs")) {
|
||||
Logger().information("Archiving Device Logs...");
|
||||
StorageService()->RemoveDeviceLogsRecordsOlderThan(
|
||||
now - (i.HowManyDays * 24 * 60 * 60));
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else if (!Poco::icompare(i.DBName, "commandlist")) {
|
||||
Logger().information("Archiving Command History...");
|
||||
StorageService()->RemoveCommandListRecordsOlderThan(
|
||||
now - (i.HowManyDays * 24 * 60 * 60));
|
||||
Now - (i.HowManyDays * 24 * 60 * 60));
|
||||
} else {
|
||||
Logger().information(fmt::format("Cannot archive DB '{}'", i.DBName));
|
||||
Logger().information(Poco::format("Cannot archive DB '%s'", i.DBName));
|
||||
}
|
||||
}
|
||||
AppServiceRegistry().Set("lastStorageArchiverRun", (uint64_t) Now);
|
||||
@@ -90,7 +90,7 @@ namespace OpenWifi {
|
||||
|
||||
int NextRun = CalculateDelta(RunAtHour_,RunAtMin_);
|
||||
|
||||
Logger().information(fmt::format("Next run in {} seconds.",NextRun));
|
||||
Logger().information(Poco::format("Next run in %d seconds.",NextRun));
|
||||
|
||||
Timer_.setStartInterval( NextRun * 1000);
|
||||
Timer_.setPeriodicInterval(24 * 60 * 60 * 1000); // 1 hours
|
||||
|
||||
@@ -90,9 +90,14 @@ namespace OpenWifi {
|
||||
bool DeleteDevice(std::string &SerialNumber);
|
||||
bool UpdateDevice(GWObjects::Device &);
|
||||
bool DeviceExists(std::string & SerialNumber);
|
||||
bool SetOwner(std::string & SerialNumber, std::string & OwnerUUID);
|
||||
bool SetLocation(std::string & SerialNumber, std::string & LocationUUID);
|
||||
bool SetVenue(std::string & SerialNumber, std::string & OwnerUUID);
|
||||
bool SetConnectInfo(std::string &SerialNumber, std::string &Firmware);
|
||||
bool GetDeviceCount(uint64_t & Count);
|
||||
bool GetDeviceSerialNumbers(uint64_t From, uint64_t HowMany, std::vector<std::string> & SerialNumbers);
|
||||
bool SetDeviceCompatibility(std::string & SerialNumber, std::string & Compatible);
|
||||
bool GetDevicesWithoutFirmware(std::string &DeviceType, std::string &Version, std::vector<std::string> & SerialNumbers);
|
||||
bool GetDeviceFWUpdatePolicy(std::string & SerialNumber, std::string & Policy);
|
||||
bool SetDevicePassword(std::string & SerialNumber, std::string & Password);
|
||||
bool UpdateSerialNumberCache();
|
||||
@@ -128,7 +133,7 @@ namespace OpenWifi {
|
||||
bool DeleteCommand( std::string &UUID );
|
||||
bool GetReadyToExecuteCommands( uint64_t Offset, uint64_t HowMany, std::vector<GWObjects::CommandDetails> & Commands );
|
||||
bool CommandExecuted(std::string & UUID);
|
||||
bool CommandCompleted(std::string & UUID, const Poco::JSON::Object & ReturnVars, const std::chrono::duration<double, std::milli> & execution_time, bool FullCommand);
|
||||
bool CommandCompleted(std::string & UUID, const Poco::JSON::Object::Ptr & ReturnVars, const std::chrono::duration<double, std::milli> & execution_time, bool FullCommand);
|
||||
bool AttachFileToCommand(std::string & UUID);
|
||||
bool CancelWaitFile( std::string & UUID, std::string & ErrorText );
|
||||
bool GetAttachedFile(std::string & UUID, const std::string & SerialNumber, const std::string & FileName, std::string &Type);
|
||||
|
||||
@@ -19,11 +19,7 @@ namespace OpenWifi {
|
||||
Poco::SharedPtr<Poco::Net::WebSocket> WSock,
|
||||
Poco::Net::SocketReactor& Reactor,
|
||||
Poco::Logger &Logger):
|
||||
UUID_(std::move(UUID)),
|
||||
SerialNumber_(SerialNumber),
|
||||
Reactor_(Reactor),
|
||||
Logger_(Logger),
|
||||
WS_(std::move(WSock)) {
|
||||
UUID_(std::move(UUID)), SerialNumber_(SerialNumber), WS_(std::move(WSock)),Reactor_(Reactor), Logger_(Logger) {
|
||||
std::cout << "Telemetry client creation" << std::endl;
|
||||
try {
|
||||
std::thread T([this]() { this->CompleteStartup(); });
|
||||
@@ -60,7 +56,7 @@ namespace OpenWifi {
|
||||
*WS_, Poco::NObserver<TelemetryClient, Poco::Net::ErrorNotification>(
|
||||
*this, &TelemetryClient::OnSocketError));
|
||||
Registered_ = true;
|
||||
Logger().information(fmt::format("CONNECTION({}): completed.", CId_));
|
||||
Logger().information(Poco::format("CONNECTION(%s): completed.", CId_));
|
||||
return;
|
||||
}
|
||||
} catch (const Poco::Net::SSLException &E) {
|
||||
@@ -96,12 +92,12 @@ namespace OpenWifi {
|
||||
|
||||
bool TelemetryClient::Send(const std::string &Payload) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
size_t BytesSent = WS_->sendFrame(Payload.c_str(),(int)Payload.size());
|
||||
auto BytesSent = WS_->sendFrame(Payload.c_str(),(int)Payload.size());
|
||||
return BytesSent == Payload.size();
|
||||
}
|
||||
|
||||
void TelemetryClient::SendTelemetryShutdown() {
|
||||
Logger().information(fmt::format("TELEMETRY-SHUTDOWN({}): Closing.",CId_));
|
||||
Logger().information(Poco::format("TELEMETRY-SHUTDOWN(%s): Closing.",CId_));
|
||||
auto Device = DeviceRegistry()->GetDeviceConnection(SerialNumber_);
|
||||
if(Device) {
|
||||
if(Device->WSConn_)
|
||||
@@ -111,19 +107,19 @@ namespace OpenWifi {
|
||||
delete this;
|
||||
}
|
||||
|
||||
void TelemetryClient::OnSocketShutdown([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf) {
|
||||
void TelemetryClient::OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger().information(fmt::format("SOCKET-SHUTDOWN({}): Orderly shutdown.", CId_));
|
||||
Logger().information(Poco::format("SOCKET-SHUTDOWN(%s): Orderly shutdown.", CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
|
||||
void TelemetryClient::OnSocketError([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf) {
|
||||
void TelemetryClient::OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
Logger().information(fmt::format("SOCKET-ERROR({}): Closing.",CId_));
|
||||
Logger().information(Poco::format("SOCKET-ERROR(%s): Closing.",CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
|
||||
void TelemetryClient::OnSocketReadable([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ReadableNotification>& pNf) {
|
||||
void TelemetryClient::OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification>& pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
try
|
||||
{
|
||||
@@ -136,11 +132,11 @@ namespace OpenWifi {
|
||||
}
|
||||
catch (const std::exception & E) {
|
||||
std::string W = E.what();
|
||||
Logger().information(fmt::format("std::exception caught: {}. Connection terminated with {}",W,CId_));
|
||||
Logger().information(Poco::format("std::exception caught: %s. Connection terminated with %s",W,CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
catch ( ... ) {
|
||||
Logger().information(fmt::format("Unknown exception for {}. Connection terminated.",CId_));
|
||||
Logger().information(Poco::format("Unknown exception for %s. Connection terminated.",CId_));
|
||||
SendTelemetryShutdown();
|
||||
}
|
||||
}
|
||||
@@ -157,16 +153,16 @@ namespace OpenWifi {
|
||||
Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||
|
||||
if (IncomingSize == 0 && flags == 0 && Op == 0) {
|
||||
Logger().information(fmt::format("DISCONNECT({}): device has disconnected.", CId_));
|
||||
Logger().information(Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
MustDisconnect = true;
|
||||
} else {
|
||||
if (Op == Poco::Net::WebSocket::FRAME_OP_PING) {
|
||||
Logger().debug(fmt::format("WS-PING({}): received. PONG sent back.", CId_));
|
||||
Logger().debug(Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
WS_->sendFrame("", 0,
|
||||
(int)Poco::Net::WebSocket::FRAME_OP_PONG |
|
||||
(int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
} else if (Op == Poco::Net::WebSocket::FRAME_OP_CLOSE) {
|
||||
Logger().information(fmt::format("DISCONNECT({}): device wants to disconnect.", CId_));
|
||||
Logger().information(Poco::format("DISCONNECT(%s): device wants to disconnect.", CId_));
|
||||
MustDisconnect = true ;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@
|
||||
#include "Daemon.h"
|
||||
#include "TelemetryStream.h"
|
||||
#include "CentralConfig.h"
|
||||
#include "FindCountry.h"
|
||||
|
||||
|
||||
namespace OpenWifi {
|
||||
void WSConnection::LogException(const Poco::Exception &E) {
|
||||
Logger().information(fmt::format("EXCEPTION({}): {}", CId_, E.displayText()));
|
||||
Logger().information(Poco::format("EXCEPTION(%s): %s", CId_, E.displayText()));
|
||||
}
|
||||
|
||||
void WSConnection::CompleteStartup() {
|
||||
@@ -41,9 +41,9 @@ namespace OpenWifi {
|
||||
PeerAddress_ = SS->peerAddress().host();
|
||||
CId_ = Utils::FormatIPv6(SS->peerAddress().toString());
|
||||
if (!SS->secure()) {
|
||||
Logger().error(fmt::format("{}: Connection is NOT secure.", CId_));
|
||||
Logger().error(Poco::format("%s: Connection is NOT secure.", CId_));
|
||||
} else {
|
||||
Logger().debug(fmt::format("{}: Connection is secure.", CId_));
|
||||
Logger().debug(Poco::format("%s: Connection is secure.", CId_));
|
||||
}
|
||||
|
||||
if (SS->havePeerCertificate()) {
|
||||
@@ -55,20 +55,20 @@ namespace OpenWifi {
|
||||
if (WebSocketServer()->ValidateCertificate(CId_, PeerCert)) {
|
||||
CN_ = Poco::trim(Poco::toLower(PeerCert.commonName()));
|
||||
CertValidation_ = GWObjects::MISMATCH_SERIAL;
|
||||
Logger().debug(fmt::format("{}: Valid certificate: CN={}", CId_, CN_));
|
||||
Logger().debug(Poco::format("%s: Valid certificate: CN=%s", CId_, CN_));
|
||||
} else {
|
||||
Logger().debug(fmt::format("{}: Certificate is not valid", CId_));
|
||||
Logger().debug(Poco::format("%s: Certificate is not valid", CId_));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
LogException(E);
|
||||
}
|
||||
} else {
|
||||
Logger().error(fmt::format("{}: No certificates available..", CId_));
|
||||
Logger().error(Poco::format("%s: No certificates available..", CId_));
|
||||
}
|
||||
|
||||
if (WebSocketServer::IsSim(CN_) && !WebSocketServer()->IsSimEnabled()) {
|
||||
Logger().debug(fmt::format(
|
||||
"CONNECTION({}): Sim Device {} is not allowed. Disconnecting.", CId_, CN_));
|
||||
Logger().debug(Poco::format(
|
||||
"CONNECTION(%s): Sim Device %s is not allowed. Disconnecting.", CId_, CN_));
|
||||
delete this;
|
||||
return;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ namespace OpenWifi {
|
||||
SerialNumberInt_ = Utils::SerialNumberToInt(SerialNumber_);
|
||||
|
||||
if (!CN_.empty() && StorageService()->IsBlackListed(SerialNumber_)) {
|
||||
Logger().debug(fmt::format("CONNECTION({}): Device {} is black listed. Disconnecting.",
|
||||
Logger().debug(Poco::format("CONNECTION(%s): Device %s is black listed. Disconnecting.",
|
||||
CId_, CN_));
|
||||
return delete this;
|
||||
}
|
||||
@@ -86,8 +86,8 @@ namespace OpenWifi {
|
||||
Poco::Net::HTTPServerResponseImpl Response(Session);
|
||||
Poco::Net::HTTPServerRequestImpl Request(Response, Session, Params);
|
||||
|
||||
auto now = OpenWifi::Now();
|
||||
Response.setDate(now);
|
||||
auto Now = std::time(nullptr);
|
||||
Response.setDate(Now);
|
||||
Response.setVersion(Request.getVersion());
|
||||
Response.setKeepAlive(Params->getKeepAlive() && Request.getKeepAlive() &&
|
||||
Session.canKeepAlive());
|
||||
@@ -108,49 +108,47 @@ namespace OpenWifi {
|
||||
Reactor_.addEventHandler(*WS_, Poco::NObserver<WSConnection, Poco::Net::ErrorNotification>(
|
||||
*this, &WSConnection::OnSocketError));
|
||||
Registered_ = true;
|
||||
Logger().information(fmt::format("CONNECTION({}): completed.", CId_));
|
||||
Logger().information(Poco::format("CONNECTION(%s): completed.", CId_));
|
||||
return;
|
||||
} catch (const Poco::Net::CertificateValidationException &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception Certificate Validation failed during connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception Certificate Validation failed during connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Net::WebSocketException &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception WebSocket error during connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception WebSocket error during connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Net::ConnectionAbortedException &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception Connection was aborted during connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception Connection was aborted during connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Net::ConnectionResetException &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception Connection was reset during connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception Connection was reset during connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Net::InvalidCertificateException &E) {
|
||||
Logger().error(fmt::format(
|
||||
"CONNECTION({}): Poco::Exception Invalid certificate. Device will have to retry.",
|
||||
Logger().error(Poco::format(
|
||||
"CONNECTION(%s): Poco::Exception Invalid certificate. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Net::SSLException &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception SSL Exception during connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception SSL Exception during connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Poco::Exception caught during device connection. Device will have to retry.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Poco::Exception caught during device connection. Device will have to retry.",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
} catch (...) {
|
||||
Logger().error(fmt::format("CONNECTION({}): Exception caught during device connection. Device will have to retry. Unsecure connect denied.",
|
||||
Logger().error(Poco::format("CONNECTION(%s): Exception caught during device connection. Device will have to retry. Unsecure connect denied.",
|
||||
CId_));
|
||||
}
|
||||
return delete this;
|
||||
}
|
||||
|
||||
WSConnection::WSConnection(Poco::Net::StreamSocket &socket, [[maybe_unused]] Poco::Net::SocketReactor &reactor)
|
||||
: Logger_(WebSocketServer()->Logger()) ,
|
||||
Socket_(socket),
|
||||
Reactor_(WebSocketServer()->GetNextReactor())
|
||||
{
|
||||
WSConnection::WSConnection(Poco::Net::StreamSocket &socket, Poco::Net::SocketReactor &reactor)
|
||||
: Socket_(socket), Reactor_(WebSocketServer()->GetNextReactor()),
|
||||
Logger_(WebSocketServer()->Logger()) {
|
||||
std::thread T([=]() { CompleteStartup(); });
|
||||
T.detach();
|
||||
// CompleteStartup();
|
||||
@@ -247,7 +245,7 @@ namespace OpenWifi {
|
||||
std::ostringstream O;
|
||||
Poco::JSON::Stringifier::stringify(Params, O);
|
||||
Cmd.Details = O.str();
|
||||
poco_information(Logger(),fmt::format("CFG-UPGRADE({}): Current ID: {}, newer configuration {}.",
|
||||
poco_information(Logger(),Poco::format("CFG-UPGRADE(%s): Current ID: %Lu, newer configuration %Lu.",
|
||||
CId_, UUID, D.UUID));
|
||||
bool Sent;
|
||||
|
||||
@@ -260,54 +258,40 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool WSConnection::ExtractBase64CompressedData(const std::string &CompressedData,
|
||||
std::string &UnCompressedData, uint64_t compress_sz ) {
|
||||
std::string &UnCompressedData) {
|
||||
std::istringstream ifs(CompressedData);
|
||||
Poco::Base64Decoder b64in(ifs);
|
||||
std::ostringstream ofs;
|
||||
Poco::StreamCopier::copyStream(b64in, ofs);
|
||||
|
||||
int factor = 20;
|
||||
unsigned long MaxSize = compress_sz ? (unsigned long) (compress_sz + 5000) : (unsigned long) (ofs.str().size() * factor);
|
||||
while(true) {
|
||||
std::vector<uint8_t> UncompressedBuffer(MaxSize);
|
||||
unsigned long FinalSize = MaxSize;
|
||||
auto status = uncompress((uint8_t *)&UncompressedBuffer[0], &FinalSize,
|
||||
(uint8_t *)ofs.str().c_str(), ofs.str().size());
|
||||
if(status==Z_OK) {
|
||||
UncompressedBuffer[FinalSize] = 0;
|
||||
UnCompressedData = (char *)&UncompressedBuffer[0];
|
||||
return true;
|
||||
}
|
||||
if(status==Z_BUF_ERROR) {
|
||||
if(factor<300) {
|
||||
factor+=10;
|
||||
MaxSize = ofs.str().size() * factor;
|
||||
continue;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
unsigned long MaxSize = ofs.str().size() * 10;
|
||||
std::vector<uint8_t> UncompressedBuffer(MaxSize);
|
||||
unsigned long FinalSize = MaxSize;
|
||||
if (uncompress((uint8_t *)&UncompressedBuffer[0], &FinalSize, (uint8_t *)ofs.str().c_str(),
|
||||
ofs.str().size()) == Z_OK) {
|
||||
UncompressedBuffer[FinalSize] = 0;
|
||||
UnCompressedData = (char *)&UncompressedBuffer[0];
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void WSConnection::ProcessJSONRPCResult(Poco::JSON::Object::Ptr Doc) {
|
||||
CommandManager()->PostCommandResult(SerialNumber_, *Doc);
|
||||
void WSConnection::ProcessJSONRPCResult(Poco::JSON::Object::Ptr &Doc) {
|
||||
CommandManager()->PostCommandResult(SerialNumber_, Doc);
|
||||
}
|
||||
|
||||
void WSConnection::ProcessJSONRPCEvent(Poco::JSON::Object::Ptr &Doc) {
|
||||
|
||||
auto Method = Doc->get(uCentralProtocol::METHOD).toString();
|
||||
auto EventType = uCentralProtocol::Events::EventFromString(Method);
|
||||
if (EventType == uCentralProtocol::Events::ET_UNKNOWN) {
|
||||
poco_warning(Logger(),fmt::format("ILLEGAL-PROTOCOL({}): Unknown message type '{}'", CId_, Method));
|
||||
auto EventType = uCentralProtocol::EventFromString(Method);
|
||||
if (EventType == uCentralProtocol::ET_UNKNOWN) {
|
||||
poco_warning(Logger(),Poco::format("ILLEGAL-PROTOCOL(%s): Unknown message type '%s'", CId_, Method));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!Doc->isObject(uCentralProtocol::PARAMS)) {
|
||||
poco_warning(Logger(),fmt::format("MISSING-PARAMS({}): params must be an object.", CId_));
|
||||
poco_warning(Logger(),Poco::format("MISSING-PARAMS(%s): params must be an object.", CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -317,25 +301,20 @@ namespace OpenWifi {
|
||||
if (ParamsObj->has(uCentralProtocol::COMPRESS_64)) {
|
||||
std::string UncompressedData;
|
||||
try {
|
||||
auto CompressedData = ParamsObj->get(uCentralProtocol::COMPRESS_64).toString();
|
||||
uint64_t compress_sz = 0 ;
|
||||
if(ParamsObj->has("compress_sz")) {
|
||||
compress_sz = ParamsObj->get("compress_sz");
|
||||
}
|
||||
|
||||
if (ExtractBase64CompressedData(CompressedData, UncompressedData, compress_sz)) {
|
||||
poco_trace(Logger(),fmt::format("EVENT({}): Found compressed payload expanded to '{}'.",
|
||||
if (ExtractBase64CompressedData(
|
||||
ParamsObj->get(uCentralProtocol::COMPRESS_64).toString(), UncompressedData)) {
|
||||
poco_trace(Logger(),Poco::format("EVENT(%s): Found compressed payload expanded to '%s'.",
|
||||
CId_, UncompressedData));
|
||||
Poco::JSON::Parser Parser;
|
||||
ParamsObj = Parser.parse(UncompressedData).extract<Poco::JSON::Object::Ptr>();
|
||||
} else {
|
||||
poco_warning(Logger(),fmt::format("INVALID-COMPRESSED-DATA({}): Compressed cannot be uncompressed - content must be corrupt..: size={}",
|
||||
CId_, CompressedData.size()));
|
||||
poco_warning(Logger(),Poco::format("INVALID-COMPRESSED-DATA(%s): Compressed cannot be uncompressed - content must be corrupt..",
|
||||
CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
poco_warning(Logger(),fmt::format("INVALID-COMPRESSED-JSON-DATA({}): Compressed cannot be parsed - JSON must be corrupt..",
|
||||
poco_warning(Logger(),Poco::format("INVALID-COMPRESSED-JSON-DATA(%s): Compressed cannot be parsed - JSON must be corrupt..",
|
||||
CId_));
|
||||
Logger().log(E);
|
||||
return;
|
||||
@@ -343,15 +322,15 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if (!ParamsObj->has(uCentralProtocol::SERIAL)) {
|
||||
poco_warning(Logger(),fmt::format("MISSING-PARAMS({}): Serial number is missing in message.", CId_));
|
||||
poco_warning(Logger(),Poco::format("MISSING-PARAMS(%s): Serial number is missing in message.", CId_));
|
||||
return;
|
||||
}
|
||||
|
||||
auto Serial = Poco::trim(Poco::toLower(ParamsObj->get(uCentralProtocol::SERIAL).toString()));
|
||||
if (!Utils::ValidSerialNumber(Serial)) {
|
||||
Poco::Exception E(
|
||||
fmt::format(
|
||||
"ILLEGAL-DEVICE-NAME({}): device name is illegal and not allowed to connect.",
|
||||
Poco::format(
|
||||
"ILLEGAL-DEVICE-NAME(%s): device name is illegal and not allowed to connect.",
|
||||
Serial),
|
||||
EACCES);
|
||||
E.rethrow();
|
||||
@@ -359,7 +338,7 @@ namespace OpenWifi {
|
||||
|
||||
if (StorageService()->IsBlackListed(Serial)) {
|
||||
Poco::Exception E(
|
||||
fmt::format("BLACKLIST({}): device is blacklisted and not allowed to connect.",
|
||||
Poco::format("BLACKLIST(%s): device is blacklisted and not allowed to connect.",
|
||||
Serial),
|
||||
EACCES);
|
||||
E.rethrow();
|
||||
@@ -369,7 +348,7 @@ namespace OpenWifi {
|
||||
Conn_->Conn_.LastContact = std::time(nullptr);
|
||||
|
||||
switch (EventType) {
|
||||
case uCentralProtocol::Events::ET_CONNECT: {
|
||||
case uCentralProtocol::ET_CONNECT: {
|
||||
if (ParamsObj->has(uCentralProtocol::UUID) &&
|
||||
ParamsObj->has(uCentralProtocol::FIRMWARE) &&
|
||||
ParamsObj->has(uCentralProtocol::CAPABILITIES)) {
|
||||
@@ -390,72 +369,51 @@ namespace OpenWifi {
|
||||
if ((!CN_.empty() && Utils::SerialNumberMatch(CN_, SerialNumber_)) ||
|
||||
WebSocketServer()->IsSimSerialNumber(CN_)) {
|
||||
CertValidation_ = GWObjects::VERIFIED;
|
||||
poco_information(Logger(), fmt::format("CONNECT({}): Fully validated and authenticated device..", CId_));
|
||||
poco_information(Logger(),Poco::format("CONNECT(%s): Fully validated and authenticated device..", CId_));
|
||||
} else {
|
||||
if (CN_.empty())
|
||||
poco_information(Logger(), fmt::format("CONNECT({}): Not authenticated or validated.", CId_));
|
||||
poco_information(Logger(),Poco::format("CONNECT(%s): Not authenticated or validated.", CId_));
|
||||
else
|
||||
poco_information(Logger(), fmt::format(
|
||||
"CONNECT({}): Authenticated but not validated. Serial='{}' CN='{}'", CId_,
|
||||
poco_information(Logger(),Poco::format(
|
||||
"CONNECT(%s): Authenticated but not validated. Serial='%s' CN='%s'", CId_,
|
||||
Serial, CN_));
|
||||
}
|
||||
Conn_->Conn_.VerifiedCertificate = CertValidation_;
|
||||
auto IP = PeerAddress_.toString();
|
||||
if(IP.substr(0,7)=="::ffff:") {
|
||||
IP = IP.substr(7);
|
||||
}
|
||||
Conn_->Conn_.locale = FindCountryFromIP()->Get(IP);
|
||||
GWObjects::Device DeviceInfo;
|
||||
auto DeviceExists = StorageService()->GetDevice(SerialNumber_,DeviceInfo);
|
||||
// std::cout << "Connecting: " << SerialNumber_ << std::endl;
|
||||
|
||||
auto DeviceExists = SerialNumberCache()->NumberExists(SerialNumberInt_);
|
||||
if (Daemon()->AutoProvisioning() && !DeviceExists) {
|
||||
StorageService()->CreateDefaultDevice(SerialNumber_, Capabilities, Firmware,
|
||||
Compatible_, PeerAddress_);
|
||||
Conn_->Conn_.Compatible = Compatible_;
|
||||
} else if (DeviceExists) {
|
||||
StorageService()->UpdateDeviceCapabilities(SerialNumber_, Capabilities,
|
||||
Compatible_);
|
||||
bool Updated = false;
|
||||
if(!Firmware.empty() && Firmware!=DeviceInfo.Firmware) {
|
||||
DeviceInfo.Firmware = Firmware;
|
||||
Updated = true;
|
||||
}
|
||||
if(DeviceInfo.locale != Conn_->Conn_.locale) {
|
||||
DeviceInfo.locale = Conn_->Conn_.locale;
|
||||
Updated = true;
|
||||
}
|
||||
if(Compatible_ != DeviceInfo.DeviceType) {
|
||||
DeviceInfo.DeviceType = Compatible_;
|
||||
Updated = true;
|
||||
}
|
||||
if(Updated) {
|
||||
StorageService()->UpdateDevice(DeviceInfo);
|
||||
Conn_->Conn_.Compatible = Compatible_;
|
||||
if (!Firmware.empty()) {
|
||||
StorageService()->SetConnectInfo(SerialNumber_, Firmware);
|
||||
}
|
||||
LookForUpgrade(UUID);
|
||||
}
|
||||
|
||||
Conn_->Conn_.Compatible = Compatible_;
|
||||
|
||||
if (KafkaManager()->Enabled()) {
|
||||
Poco::JSON::Stringifier Stringify;
|
||||
ParamsObj->set(uCentralProtocol::CONNECTIONIP, CId_);
|
||||
ParamsObj->set("locale", Conn_->Conn_.locale );
|
||||
ParamsObj->set(uCentralProtocol::TIMESTAMP, std::time(nullptr));
|
||||
std::ostringstream OS;
|
||||
Stringify.condense(ParamsObj, OS);
|
||||
KafkaManager()->PostMessage(KafkaTopics::CONNECTION, SerialNumber_, OS.str());
|
||||
}
|
||||
Connected_ = true;
|
||||
} else {
|
||||
poco_warning(Logger(),fmt::format("INVALID-PROTOCOL({}): Missing one of uuid, firmware, or capabilities", CId_));
|
||||
poco_warning(Logger(),Poco::format("INVALID-PROTOCOL(%s): Missing one of uuid, firmware, or capabilities", CId_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_STATE: {
|
||||
case uCentralProtocol::ET_STATE: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -468,13 +426,11 @@ namespace OpenWifi {
|
||||
if (ParamsObj->has(uCentralProtocol::REQUEST_UUID))
|
||||
request_uuid = ParamsObj->get(uCentralProtocol::REQUEST_UUID).toString();
|
||||
|
||||
if (request_uuid.empty()) {
|
||||
poco_trace(Logger(), fmt::format("STATE({}): UUID={} Updating.", CId_, UUID));
|
||||
} else {
|
||||
poco_trace(Logger(), fmt::format("STATE({}): UUID={} Updating for CMD={}.",
|
||||
CId_, UUID, request_uuid));
|
||||
}
|
||||
|
||||
if (request_uuid.empty())
|
||||
poco_trace(Logger(),Poco::format("STATE(%s): UUID=%Lu Updating.", CId_, UUID));
|
||||
else
|
||||
poco_trace(Logger(),Poco::format("STATE(%s): UUID=%Lu Updating for CMD=%s.", CId_, UUID,
|
||||
request_uuid));
|
||||
Conn_->Conn_.UUID = UUID;
|
||||
Conn_->LastStats = StateStr;
|
||||
|
||||
@@ -497,14 +453,14 @@ namespace OpenWifi {
|
||||
KafkaManager()->PostMessage(KafkaTopics::STATE, SerialNumber_, OS.str());
|
||||
}
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("STATE({}): Invalid request. Missing serial, uuid, or state", CId_));
|
||||
poco_warning(Logger(),Poco::format("STATE(%s): Invalid request. Missing serial, uuid, or state", CId_));
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_HEALTHCHECK: {
|
||||
case uCentralProtocol::ET_HEALTHCHECK: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -520,14 +476,11 @@ namespace OpenWifi {
|
||||
if (ParamsObj->has(uCentralProtocol::REQUEST_UUID))
|
||||
request_uuid = ParamsObj->get(uCentralProtocol::REQUEST_UUID).toString();
|
||||
|
||||
if (request_uuid.empty()) {
|
||||
poco_trace(Logger(),
|
||||
fmt::format("HEALTHCHECK({}): UUID={} Updating.", CId_, UUID));
|
||||
} else {
|
||||
poco_trace(Logger(),
|
||||
fmt::format("HEALTHCHECK({}): UUID={} Updating for CMD={}.", CId_,
|
||||
UUID, request_uuid));
|
||||
}
|
||||
if (request_uuid.empty())
|
||||
poco_trace(Logger(),Poco::format("HEALTHCHECK(%s): UUID=%Lu Updating.", CId_, UUID));
|
||||
else
|
||||
poco_trace(Logger(),Poco::format("HEALTHCHECK(%s): UUID=%Lu Updating for CMD=%s.", CId_,
|
||||
UUID, request_uuid));
|
||||
|
||||
Conn_->Conn_.UUID = UUID;
|
||||
LookForUpgrade(UUID);
|
||||
@@ -555,20 +508,20 @@ namespace OpenWifi {
|
||||
KafkaManager()->PostMessage(KafkaTopics::HEALTHCHECK, SerialNumber_, OS.str());
|
||||
}
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("HEALTHCHECK({}): Missing parameter", CId_));
|
||||
poco_warning(Logger(),Poco::format("HEALTHCHECK(%s): Missing parameter", CId_));
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_LOG: {
|
||||
case uCentralProtocol::ET_LOG: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
if (ParamsObj->has(uCentralProtocol::LOG) && ParamsObj->has(uCentralProtocol::SEVERITY)) {
|
||||
poco_trace(Logger(), fmt::format("LOG({}): new entry.", CId_));
|
||||
poco_trace(Logger(),Poco::format("LOG(%s): new entry.", CId_));
|
||||
auto Log = ParamsObj->get(uCentralProtocol::LOG).toString();
|
||||
auto Severity = ParamsObj->get(uCentralProtocol::SEVERITY);
|
||||
std::string DataStr = uCentralProtocol::EMPTY_JSON_DOC;
|
||||
@@ -587,14 +540,14 @@ namespace OpenWifi {
|
||||
.UUID = Conn_->Conn_.UUID};
|
||||
StorageService()->AddLog(DeviceLog);
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("LOG({}): Missing parameters.", CId_));
|
||||
poco_warning(Logger(),Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_CRASHLOG: {
|
||||
case uCentralProtocol::ET_CRASHLOG: {
|
||||
if (ParamsObj->has(uCentralProtocol::UUID) && ParamsObj->has(uCentralProtocol::LOGLINES)) {
|
||||
poco_trace(Logger(), fmt::format("CRASH-LOG({}): new entry.", CId_));
|
||||
poco_trace(Logger(),Poco::format("CRASH-LOG(%s): new entry.", CId_));
|
||||
auto LogLines = ParamsObj->get(uCentralProtocol::LOGLINES);
|
||||
std::string LogText;
|
||||
if (LogLines.isArray()) {
|
||||
@@ -613,38 +566,38 @@ namespace OpenWifi {
|
||||
StorageService()->AddLog(DeviceLog);
|
||||
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("LOG({}): Missing parameters.", CId_));
|
||||
poco_warning(Logger(), Poco::format("LOG(%s): Missing parameters.", CId_));
|
||||
return;
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_PING: {
|
||||
case uCentralProtocol::ET_PING: {
|
||||
if (ParamsObj->has(uCentralProtocol::UUID)) {
|
||||
[[maybe_unused]] uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
poco_trace(Logger(), fmt::format("PING({}): Current config is {}", CId_, UUID));
|
||||
uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
poco_trace(Logger(),Poco::format("PING(%s): Current config is %Lu", CId_, UUID));
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("PING({}): Missing parameter.", CId_));
|
||||
poco_warning(Logger(),Poco::format("PING(%s): Missing parameter.", CId_));
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_CFGPENDING: {
|
||||
case uCentralProtocol::ET_CFGPENDING: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
if (ParamsObj->has(uCentralProtocol::UUID) && ParamsObj->has(uCentralProtocol::ACTIVE)) {
|
||||
|
||||
[[maybe_unused]] uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
[[maybe_unused]] uint64_t Active = ParamsObj->get(uCentralProtocol::ACTIVE);
|
||||
poco_trace(Logger(), fmt::format("CFG-PENDING({}): Active: {} Target: {}", CId_, Active, UUID));
|
||||
uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
|
||||
uint64_t Active = ParamsObj->get(uCentralProtocol::ACTIVE);
|
||||
poco_trace(Logger(),Poco::format("CFG-PENDING(%s): Active: %Lu Target: %Lu", CId_, Active, UUID));
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("CFG-PENDING({}): Missing some parameters", CId_));
|
||||
poco_warning(Logger(),Poco::format("CFG-PENDING(%s): Missing some parameters", CId_));
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_RECOVERY: {
|
||||
case uCentralProtocol::ET_RECOVERY: {
|
||||
if (ParamsObj->has(uCentralProtocol::SERIAL) &&
|
||||
ParamsObj->has(uCentralProtocol::FIRMWARE) && ParamsObj->has(uCentralProtocol::UUID) &&
|
||||
ParamsObj->has(uCentralProtocol::REBOOT) &&
|
||||
@@ -686,21 +639,21 @@ namespace OpenWifi {
|
||||
bool Sent;
|
||||
CommandManager()->PostCommand(SerialNumber_, Cmd.Command, Params, Cmd.UUID, Sent);
|
||||
StorageService()->AddCommand(SerialNumber_, Cmd, Storage::COMMAND_EXECUTED);
|
||||
poco_information(Logger(), fmt::format("RECOVERY({}): Recovery mode received, need for a reboot.", CId_));
|
||||
poco_information(Logger(),Poco::format("RECOVERY(%s): Recovery mode received, need for a reboot.", CId_));
|
||||
} else {
|
||||
poco_information(Logger(), fmt::format(
|
||||
"RECOVERY({}): Recovery mode received, no need for a reboot.", CId_));
|
||||
poco_information(Logger(),Poco::format(
|
||||
"RECOVERY(%s): Recovery mode received, no need for a reboot.", CId_));
|
||||
}
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format("RECOVERY({}): Recovery missing one of serialnumber, firmware, uuid, loglines, reboot",
|
||||
poco_warning(Logger(),Poco::format("RECOVERY(%s): Recovery missing one of serialnumber, firmware, uuid, loglines, reboot",
|
||||
CId_));
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_DEVICEUPDATE: {
|
||||
case uCentralProtocol::ET_DEVICEUPDATE: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -708,14 +661,14 @@ namespace OpenWifi {
|
||||
auto Password = ParamsObj->get("currentPassword").toString();
|
||||
|
||||
StorageService()->SetDevicePassword(Serial, Password);
|
||||
poco_trace(Logger(), fmt::format("DEVICEUPDATE({}): Device is updating its login password.", Serial));
|
||||
poco_trace(Logger(),Poco::format("DEVICEUPDATE(%s): Device is updating its login password.", Serial));
|
||||
}
|
||||
} break;
|
||||
|
||||
case uCentralProtocol::Events::ET_TELEMETRY: {
|
||||
case uCentralProtocol::ET_TELEMETRY: {
|
||||
if (!Connected_) {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"INVALID-PROTOCOL({}): Device '{}' is not following protocol", CId_, CN_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"INVALID-PROTOCOL(%s): Device '%s' is not following protocol", CId_, CN_));
|
||||
Errors_++;
|
||||
return;
|
||||
}
|
||||
@@ -748,8 +701,8 @@ namespace OpenWifi {
|
||||
|
||||
// this will never be called but some compilers will complain if we do not have a case for
|
||||
// every single values of an enum
|
||||
case uCentralProtocol::Events::ET_UNKNOWN: {
|
||||
poco_warning(Logger(), fmt::format("ILLEGAL-EVENT({}): Event '{}' unknown. CN={}", CId_, Method, CN_));
|
||||
case uCentralProtocol::ET_UNKNOWN: {
|
||||
poco_warning(Logger(),Poco::format("ILLEGAL-EVENT(%s): Event '%s' unknown. CN=%s", CId_, Method, CN_));
|
||||
Errors_++;
|
||||
}
|
||||
}
|
||||
@@ -757,7 +710,7 @@ namespace OpenWifi {
|
||||
|
||||
bool WSConnection::StartTelemetry() {
|
||||
std::cout << "Start telemetry for " << SerialNumber_ << std::endl;
|
||||
poco_information(Logger(), fmt::format("TELEMETRY({}): Starting.", CId_));
|
||||
poco_information(Logger(),Poco::format("TELEMETRY(%s): Starting.", CId_));
|
||||
Poco::JSON::Object StartMessage;
|
||||
StartMessage.set("jsonrpc", "2.0");
|
||||
StartMessage.set("method", "telemetry");
|
||||
@@ -780,7 +733,7 @@ namespace OpenWifi {
|
||||
|
||||
bool WSConnection::StopTelemetry() {
|
||||
std::cout << "Stop telemetry for " << SerialNumber_ << std::endl;
|
||||
poco_information(Logger(), fmt::format("TELEMETRY({}): Stopping.", CId_));
|
||||
poco_information(Logger(),Poco::format("TELEMETRY(%s): Stopping.", CId_));
|
||||
Poco::JSON::Object StopMessage;
|
||||
StopMessage.set("jsonrpc", "2.0");
|
||||
StopMessage.set("method", "telemetry");
|
||||
@@ -856,19 +809,19 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
|
||||
void WSConnection::OnSocketShutdown([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
|
||||
void WSConnection::OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
poco_trace(Logger(), fmt::format("SOCKET-SHUTDOWN({}): Closing.", CId_));
|
||||
poco_trace(Logger(),Poco::format("SOCKET-SHUTDOWN(%s): Closing.", CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
void WSConnection::OnSocketError([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf) {
|
||||
void WSConnection::OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification> &pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
poco_trace(Logger(), fmt::format("SOCKET-ERROR({}): Closing.", CId_));
|
||||
poco_trace(Logger(),Poco::format("SOCKET-ERROR(%s): Closing.", CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
void WSConnection::OnSocketReadable([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
|
||||
void WSConnection::OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
try {
|
||||
ProcessIncomingFrame();
|
||||
@@ -877,10 +830,10 @@ namespace OpenWifi {
|
||||
delete this;
|
||||
} catch (const std::exception &E) {
|
||||
std::string W = E.what();
|
||||
poco_information(Logger(), fmt::format("std::exception caught: {}. Connection terminated with {}", W, CId_));
|
||||
poco_information(Logger(),Poco::format("std::exception caught: %s. Connection terminated with %s", W, CId_));
|
||||
delete this;
|
||||
} catch (...) {
|
||||
poco_information(Logger(), fmt::format("Unknown exception for {}. Connection terminated.", CId_));
|
||||
poco_information(Logger(),Poco::format("Unknown exception for %s. Connection terminated.", CId_));
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
@@ -902,21 +855,13 @@ namespace OpenWifi {
|
||||
int Op, flags;
|
||||
int IncomingSize;
|
||||
IncomingSize = WS_->receiveFrame(IncomingFrame, flags);
|
||||
|
||||
Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||
|
||||
if (IncomingSize == 0 && flags == 0 && Op == 0) {
|
||||
poco_information(Logger(), fmt::format("DISCONNECT({}): device has disconnected.", CId_));
|
||||
poco_information(Logger(),Poco::format("DISCONNECT(%s): device has disconnected.", CId_));
|
||||
return delete this;
|
||||
} else {
|
||||
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
|
||||
// auto flag_fin = (flags & Poco::Net::WebSocket::FRAME_FLAG_FIN) == Poco::Net::WebSocket::FRAME_FLAG_FIN;
|
||||
// auto flag_cont = (Op == Poco::Net::WebSocket::FRAME_OP_CONT) ;
|
||||
//std::cout << "SerialNumber: " << SerialNumber_ << " Size: " << std::dec
|
||||
// << IncomingMessageStr.size() << " fin=" << flag_fin << " cont=" << flag_cont << std::endl;
|
||||
|
||||
if (Conn_ != nullptr) {
|
||||
Conn_->Conn_.RX += IncomingSize;
|
||||
Conn_->Conn_.MessageCount++;
|
||||
@@ -924,7 +869,7 @@ namespace OpenWifi {
|
||||
|
||||
switch (Op) {
|
||||
case Poco::Net::WebSocket::FRAME_OP_PING: {
|
||||
poco_trace(Logger(), fmt::format("WS-PING({}): received. PONG sent back.", CId_));
|
||||
poco_trace(Logger(),Poco::format("WS-PING(%s): received. PONG sent back.", CId_));
|
||||
WS_->sendFrame("", 0,
|
||||
(int)Poco::Net::WebSocket::FRAME_OP_PONG |
|
||||
(int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
@@ -939,8 +884,6 @@ namespace OpenWifi {
|
||||
PingDetails.set(uCentralProtocol::SERIALNUMBER, SerialNumber_);
|
||||
PingDetails.set(uCentralProtocol::COMPATIBLE, Compatible_);
|
||||
PingDetails.set(uCentralProtocol::CONNECTIONIP, CId_);
|
||||
PingDetails.set(uCentralProtocol::TIMESTAMP, std::time(nullptr));
|
||||
PingDetails.set("locale", Conn_->Conn_.locale );
|
||||
PingObject.set(uCentralProtocol::PING, PingDetails);
|
||||
Poco::JSON::Stringifier Stringify;
|
||||
std::ostringstream OS;
|
||||
@@ -951,13 +894,15 @@ namespace OpenWifi {
|
||||
} break;
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_PONG: {
|
||||
poco_trace(Logger(), fmt::format("PONG({}): received and ignored.", CId_));
|
||||
poco_trace(Logger(),Poco::format("PONG(%s): received and ignored.", CId_));
|
||||
return;
|
||||
} break;
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
|
||||
poco_trace(Logger(), fmt::format("FRAME({}): Frame received (length={}, flags={}). Msg={}", CId_,
|
||||
IncomingSize, flags, IncomingMessageStr));
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_trace(Logger(),
|
||||
Poco::format("FRAME(%s): Frame received (length=%d, flags=0x%x). Msg=%s", CId_,
|
||||
IncomingSize, unsigned(flags), IncomingMessageStr));
|
||||
|
||||
Poco::JSON::Parser parser;
|
||||
auto ParsedMessage = parser.parse(IncomingMessageStr);
|
||||
@@ -969,16 +914,16 @@ namespace OpenWifi {
|
||||
ProcessJSONRPCEvent(IncomingJSON);
|
||||
} else if (IncomingJSON->has(uCentralProtocol::RESULT) &&
|
||||
IncomingJSON->has(uCentralProtocol::ID)) {
|
||||
poco_trace(Logger(), fmt::format("RPC-RESULT({}): payload: {}", CId_, IncomingMessageStr));
|
||||
poco_trace(Logger(),Poco::format("RPC-RESULT(%s): payload: %s", CId_, IncomingMessageStr));
|
||||
ProcessJSONRPCResult(IncomingJSON);
|
||||
} else {
|
||||
poco_warning(Logger(),
|
||||
fmt::format("INVALID-PAYLOAD({}): Payload is not JSON-RPC 2.0: {}",
|
||||
Poco::format("INVALID-PAYLOAD(%s): Payload is not JSON-RPC 2.0: %s",
|
||||
CId_, IncomingMessageStr));
|
||||
}
|
||||
} else {
|
||||
poco_warning(Logger(), fmt::format(
|
||||
"FRAME({}): illegal transaction header, missing 'jsonrpc'", CId_));
|
||||
poco_warning(Logger(),Poco::format(
|
||||
"FRAME(%s): illegal transaction header, missing 'jsonrpc'", CId_));
|
||||
Errors_++;
|
||||
}
|
||||
return;
|
||||
@@ -986,61 +931,61 @@ namespace OpenWifi {
|
||||
|
||||
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
|
||||
poco_information(Logger(),
|
||||
fmt::format("CLOSE({}): Device is closing its connection.", CId_));
|
||||
Poco::format("CLOSE(%s): Device is closing its connection.", CId_));
|
||||
return delete this;
|
||||
} break;
|
||||
|
||||
default: {
|
||||
poco_warning(Logger(), fmt::format("UNKNOWN({}): unknownWS Frame operation: {}", CId_,
|
||||
poco_warning(Logger(),Poco::format("UNKNOWN(%s): unknownWS Frame operation: %s", CId_,
|
||||
std::to_string(Op)));
|
||||
} break;
|
||||
}
|
||||
}
|
||||
} catch (const Poco::Net::ConnectionResetException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a ConnectionResetException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a ConnectionResetException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::JSON::JSONException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a JSONException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a JSONException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
} catch (const Poco::Net::WebSocketException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a JSONException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a JSONException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
Logger().warning( fmt::format("{}({}): Caught a websocket exception: {}. Message: {}",
|
||||
Logger().warning(Poco::format("%s(%s): Caught a websocket exception: %s. Message: %s",
|
||||
std::string(__func__), CId_, E.displayText(),
|
||||
IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::Net::SSLConnectionUnexpectedlyClosedException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a SSLConnectionUnexpectedlyClosedException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a SSLConnectionUnexpectedlyClosedException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::Net::SSLException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a SSLException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a SSLException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::Net::NetException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a NetException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a NetException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::IOException &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a IOException: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a IOException: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const Poco::Exception &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a Exception: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a Exception: %s, Message: %s",
|
||||
CId_, E.displayText(), IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (const std::exception &E) {
|
||||
std::string IncomingMessageStr = asString(IncomingFrame);
|
||||
poco_warning(Logger(), fmt::format("EXCEPTION({}): Caught a std::exception: {}, Message: {}",
|
||||
poco_warning(Logger(),Poco::format("EXCEPTION(%s): Caught a std::exception: %s, Message: %s",
|
||||
CId_, std::string{E.what()}, IncomingMessageStr));
|
||||
return delete this;
|
||||
} catch (...) {
|
||||
@@ -1050,14 +995,14 @@ namespace OpenWifi {
|
||||
if (Errors_ < 10)
|
||||
return;
|
||||
|
||||
poco_warning(Logger(), fmt::format("DISCONNECTING({}): Too many errors", CId_));
|
||||
poco_warning(Logger(),Poco::format("DISCONNECTING(%s): Too many errors", CId_));
|
||||
delete this;
|
||||
}
|
||||
|
||||
bool WSConnection::Send(const std::string &Payload) {
|
||||
std::lock_guard Guard(Mutex_);
|
||||
|
||||
size_t BytesSent = WS_->sendFrame(Payload.c_str(), (int)Payload.size());
|
||||
auto BytesSent = WS_->sendFrame(Payload.c_str(), (int)Payload.size());
|
||||
if (Conn_)
|
||||
Conn_->Conn_.TX += BytesSent;
|
||||
return BytesSent == Payload.size();
|
||||
|
||||
@@ -18,20 +18,20 @@
|
||||
namespace OpenWifi {
|
||||
|
||||
class WSConnection {
|
||||
static constexpr int BufSize = 128000;
|
||||
static constexpr int BufSize = 64000;
|
||||
public:
|
||||
WSConnection(Poco::Net::StreamSocket& Socket, Poco::Net::SocketReactor& Reactor);
|
||||
~WSConnection();
|
||||
|
||||
void ProcessJSONRPCEvent(Poco::JSON::Object::Ptr & Doc);
|
||||
void ProcessJSONRPCResult(Poco::JSON::Object::Ptr Doc);
|
||||
void ProcessJSONRPCResult(Poco::JSON::Object::Ptr & Doc);
|
||||
void ProcessIncomingFrame();
|
||||
bool Send(const std::string &Payload);
|
||||
void OnSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification>& pNf);
|
||||
void OnSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf);
|
||||
void OnSocketError(const Poco::AutoPtr<Poco::Net::ErrorNotification>& pNf);
|
||||
bool LookForUpgrade(uint64_t UUID);
|
||||
static bool ExtractBase64CompressedData(const std::string & CompressedData, std::string & UnCompressedData, uint64_t compress_sz);
|
||||
static bool ExtractBase64CompressedData(const std::string & CompressedData, std::string & UnCompressedData);
|
||||
void LogException(const Poco::Exception &E);
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
bool SetWebSocketTelemetryReporting(uint64_t interval, uint64_t TelemetryWebSocketTimer);
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace OpenWifi {
|
||||
: NumberOfThreads_(NumberOfThreads) {}
|
||||
|
||||
void Start(const std::string & ThreadNamePrefix) {
|
||||
for (uint64_t i = 0; i < NumberOfThreads_; ++i) {
|
||||
for (auto i = 0; i < NumberOfThreads_; ++i) {
|
||||
auto NewReactor = std::make_unique<Poco::Net::SocketReactor>();
|
||||
auto NewThread = std::make_unique<Poco::Thread>();
|
||||
NewThread->start(*NewReactor);
|
||||
@@ -40,8 +40,8 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
private:
|
||||
uint64_t NumberOfThreads_;
|
||||
uint64_t NextReactor_ = 0;
|
||||
unsigned int NumberOfThreads_;
|
||||
unsigned int NextReactor_ = 0;
|
||||
std::vector<std::unique_ptr<Poco::Net::SocketReactor>> Reactors_;
|
||||
std::vector<std::unique_ptr<Poco::Thread>> Threads_;
|
||||
};
|
||||
|
||||
@@ -17,9 +17,9 @@ namespace OpenWifi {
|
||||
|
||||
bool WebSocketServer::ValidateCertificate(const std::string & ConnectionId, const Poco::Crypto::X509Certificate & Certificate) {
|
||||
if(IsCertOk()) {
|
||||
Logger().debug(fmt::format("CERTIFICATE({}): issuer='{}' cn='{}'", ConnectionId, Certificate.issuerName(),Certificate.commonName()));
|
||||
Logger().debug(Poco::format("CERTIFICATE(%s): issuer='%s' cn='%s'", ConnectionId, Certificate.issuerName(),Certificate.commonName()));
|
||||
if(!Certificate.issuedBy(*IssuerCert_)) {
|
||||
Logger().debug(fmt::format("CERTIFICATE({}): issuer mismatch. Local='{}' Incoming='{}'", ConnectionId, IssuerCert_->issuerName(), Certificate.issuerName()));
|
||||
Logger().debug(Poco::format("CERTIFICATE(%s): issuer mismatch. Local='%s' Incoming='%s'", ConnectionId, IssuerCert_->issuerName(), Certificate.issuerName()));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -30,10 +30,8 @@ namespace OpenWifi {
|
||||
int WebSocketServer::Start() {
|
||||
ReactorPool_.Start("DeviceReactorPool_");
|
||||
for(const auto & Svr : ConfigServersList_ ) {
|
||||
Logger().notice( fmt::format("Starting: {}:{} Keyfile:{} CertFile: {}",
|
||||
Svr.Address(),
|
||||
Svr.Port(),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
Logger().notice(Poco::format("Starting: %s:%s Keyfile:%s CertFile: %s", Svr.Address(), std::to_string(Svr.Port()),
|
||||
Svr.KeyFile(),Svr.CertFile()));
|
||||
|
||||
Svr.LogCert(Logger());
|
||||
if(!Svr.RootCA().empty())
|
||||
@@ -43,7 +41,7 @@ namespace OpenWifi {
|
||||
|
||||
if(!IsCertOk()) {
|
||||
IssuerCert_ = std::make_unique<Poco::Crypto::X509Certificate>(Svr.IssuerCertFile());
|
||||
Logger().information( fmt::format("Certificate Issuer Name:{}",IssuerCert_->issuerName()));
|
||||
Logger().information(Poco::format("Certificate Issuer Name:%s",IssuerCert_->issuerName()));
|
||||
}
|
||||
auto NewSocketAcceptor = std::make_unique<Poco::Net::ParallelSocketAcceptor<WSConnection, Poco::Net::SocketReactor>>(Sock, Reactor_, Poco::Environment::processorCount()*2);
|
||||
Acceptors_.push_back(std::move(NewSocketAcceptor));
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,8 +14,9 @@ namespace OpenWifi {
|
||||
class ConfigurationValidator : public SubSystemServer {
|
||||
public:
|
||||
|
||||
static auto instance() {
|
||||
static auto instance_ = new ConfigurationValidator;
|
||||
static ConfigurationValidator *instance() {
|
||||
if(instance_== nullptr)
|
||||
instance_ = new ConfigurationValidator;
|
||||
return instance_;
|
||||
}
|
||||
|
||||
@@ -26,17 +27,18 @@ namespace OpenWifi {
|
||||
void reinitialize(Poco::Util::Application &self) override;
|
||||
|
||||
private:
|
||||
static ConfigurationValidator * instance_;
|
||||
bool Initialized_=false;
|
||||
bool Working_=false;
|
||||
void Init();
|
||||
nlohmann::json RootSchema_;
|
||||
std::unique_ptr<json_validator> Validator_=std::make_unique<json_validator>(nullptr, my_format_checker);
|
||||
|
||||
ConfigurationValidator():
|
||||
SubSystemServer("configvalidator", "CFG-VALIDATOR", "config.validator") {
|
||||
}
|
||||
};
|
||||
|
||||
inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
|
||||
inline ConfigurationValidator * ConfigurationValidator() { return ConfigurationValidator::instance(); }
|
||||
inline bool ValidateUCentralConfiguration(const std::string &C, std::string &Error) { return ConfigurationValidator::instance()->Validate(C, Error); }
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ namespace OpenWifi::KafkaTopics {
|
||||
static const std::string SERVICE_EVENTS{"service_events"};
|
||||
static const std::string DEVICE_EVENT_QUEUE{"device_event_queue"};
|
||||
static const std::string DEVICE_TELEMETRY{"device_telemetry"};
|
||||
static const std::string PROVISIONING_CHANGE{"provisioning_change"};
|
||||
|
||||
namespace ServiceEvents {
|
||||
static const std::string EVENT_JOIN{"join"};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
68
src/framework/RESTAPI_errors.h
Normal file
68
src/framework/RESTAPI_errors.h
Normal file
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// Created by stephane bourque on 2021-09-12.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OpenWifi::RESTAPI::Errors {
|
||||
static const std::string MissingUUID{"Missing UUID."};
|
||||
static const std::string MissingSerialNumber{"Missing Serial Number."};
|
||||
static const std::string InternalError{"Internal error. Please try later."};
|
||||
static const std::string InvalidJSONDocument{"Invalid JSON document."};
|
||||
static const std::string UnsupportedHTTPMethod{"Unsupported HTTP Method"};
|
||||
static const std::string StillInUse{"Element still in use."};
|
||||
static const std::string CouldNotBeDeleted{"Element could not be deleted."};
|
||||
static const std::string NameMustBeSet{"The name property must be set."};
|
||||
static const std::string ConfigBlockInvalid{"Configuration block type invalid."};
|
||||
static const std::string UnknownId{"Unknown UUID."};
|
||||
static const std::string InvalidDeviceTypes{"Unknown or invalid device type(s)."};
|
||||
static const std::string RecordNotCreated{"Record could not be created."};
|
||||
static const std::string RecordNotUpdated{"Record could not be updated."};
|
||||
static const std::string UnknownManagementPolicyUUID{"Unknown management policy UUID."};
|
||||
static const std::string CannotDeleteRoot{"Root Entity cannot be removed, only modified."};
|
||||
static const std::string MustCreateRootFirst{"Root entity must be created first."};
|
||||
static const std::string ParentUUIDMustExist{"Parent UUID must exist."};
|
||||
static const std::string ConfigurationMustExist{"Configuration must exist."};
|
||||
static const std::string MissingOrInvalidParameters{"Invalid or missing parameters."};
|
||||
static const std::string UnknownSerialNumber{"Unknown Serial Number."};
|
||||
static const std::string InvalidSerialNumber{"Invalid Serial Number."};
|
||||
static const std::string SerialNumberExists{"Serial Number already exists."};
|
||||
static const std::string ValidNonRootUUID{"Must be a non-root, and valid UUID."};
|
||||
static const std::string VenueMustExist{"Venue does not exist."};
|
||||
static const std::string NotBoth{"You cannot specify both Entity and Venue"};
|
||||
static const std::string EntityMustExist{"Entity must exist."};
|
||||
static const std::string ParentOrEntityMustBeSet{"Parent or Entity must be set."};
|
||||
static const std::string ContactMustExist{"Contact must exist."};
|
||||
static const std::string LocationMustExist{"Location must exist."};
|
||||
static const std::string OnlyWSSupported{"This endpoint only supports WebSocket."};
|
||||
static const std::string SerialNumberMismatch{"Serial Number mismatch."};
|
||||
static const std::string InvalidCommand{"Invalid command."};
|
||||
static const std::string NoRecordsDeleted{"No records deleted."};
|
||||
static const std::string DeviceNotConnected{"Device is not currently connected."};
|
||||
static const std::string CannotCreateWS{"Telemetry system could not create WS endpoint. Please try again."};
|
||||
static const std::string BothDeviceTypeRevision{"Both deviceType and revision must be set."};
|
||||
static const std::string IdOrSerialEmpty{"SerialNumber and Id must not be empty."};
|
||||
static const std::string MissingUserID{"Missing user ID."};
|
||||
static const std::string IdMustBe0{"To create a user, you must set the ID to 0"};
|
||||
static const std::string InvalidUserRole{"Invalid userRole."};
|
||||
static const std::string InvalidEmailAddress{"Invalid email address."};
|
||||
static const std::string PasswordRejected{"Password was rejected. This maybe an old password."};
|
||||
static const std::string InvalidIPRanges{"Invalid IP range specifications."};
|
||||
static const std::string InvalidLOrderBy{"Invalid orderBy specification."};
|
||||
static const std::string NeedMobileNumber{"You must provide at least one validated phone number."};
|
||||
static const std::string BadMFAMethod{"MFA only supports sms or email."};
|
||||
static const std::string InvalidCredentials{"Invalid credentials (username/password)."};
|
||||
static const std::string InvalidPassword{"Password does not conform to basic password rules."};
|
||||
static const std::string UserPendingVerification{"User access denied pending email verification."};
|
||||
static const std::string PasswordMustBeChanged{"Password must be changed."};
|
||||
static const std::string UnrecognizedRequest{"Ill-formed request. Please consult documentation."};
|
||||
static const std::string MissingAuthenticationInformation{"Missing authentication information."};
|
||||
static const std::string InsufficientAccessRights{"Insufficient access rights to complete the operation."};
|
||||
static const std::string ExpiredToken{"Token has expired, user must login."};
|
||||
static const std::string SubscriberMustExist{"Subscriber must exist."};
|
||||
static const std::string AuthenticatorVerificationIncomplete{"Authenticator validation is not complete."};
|
||||
static const std::string SMSCouldNotBeSentRetry{"SMS could not be sent to validate device, try later or change the phone number."};
|
||||
static const std::string SMSCouldNotValidate{"Code and number could not be validated"};
|
||||
static const std::string InvalidDeviceClass{"Invalid device class. Must be: any, venue, entity, or subscriber"};
|
||||
}
|
||||
|
||||
139
src/framework/RESTAPI_protocol.h
Normal file
139
src/framework/RESTAPI_protocol.h
Normal file
@@ -0,0 +1,139 @@
|
||||
//
|
||||
// License type: BSD 3-Clause License
|
||||
// License copy: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
||||
//
|
||||
// Created by Stephane Bourque on 2021-03-04.
|
||||
// Arilia Wireless Inc.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace OpenWifi::RESTAPI::Protocol {
|
||||
static const char * CAPABILITIES = "capabilities";
|
||||
static const char * LOGS = "logs";
|
||||
static const char * HEALTHCHECKS = "healthchecks";
|
||||
static const char * STATISTICS = "statistics";
|
||||
static const char * STATUS = "status";
|
||||
static const char * SERIALNUMBER = "serialNumber";
|
||||
static const char * PERFORM = "perform";
|
||||
static const char * CONFIGURE = "configure";
|
||||
static const char * UPGRADE = "upgrade";
|
||||
static const char * REBOOT = "reboot";
|
||||
static const char * FACTORY = "factory";
|
||||
static const char * LEDS = "leds";
|
||||
static const char * TRACE = "trace";
|
||||
static const char * REQUEST = "request";
|
||||
static const char * WIFISCAN = "wifiscan";
|
||||
static const char * EVENTQUEUE = "eventqueue";
|
||||
static const char * RTTY = "rtty";
|
||||
static const char * COMMAND = "command";
|
||||
static const char * STARTDATE = "startDate";
|
||||
static const char * ENDDATE = "endDate";
|
||||
static const char * OFFSET = "offset";
|
||||
static const char * LIMIT = "limit";
|
||||
static const char * LIFETIME = "lifetime";
|
||||
static const char * UUID = "UUID";
|
||||
static const char * DATA = "data";
|
||||
static const char * CONFIGURATION = "configuration";
|
||||
static const char * WHEN = "when";
|
||||
static const char * URI = "uri";
|
||||
static const char * LOGTYPE = "logType";
|
||||
static const char * VALUES = "values";
|
||||
static const char * TYPES = "types";
|
||||
static const char * PAYLOAD = "payload";
|
||||
static const char * KEEPREDIRECTOR = "keepRedirector";
|
||||
static const char * NETWORK = "network";
|
||||
static const char * INTERFACE = "interface";
|
||||
static const char * BANDS = "bands";
|
||||
static const char * CHANNELS = "channels";
|
||||
static const char * VERBOSE = "verbose";
|
||||
static const char * MESSAGE = "message";
|
||||
static const char * STATE = "state";
|
||||
static const char * HEALTHCHECK = "healthcheck";
|
||||
static const char * PCAP_FILE_TYPE = "pcap";
|
||||
static const char * DURATION = "duration";
|
||||
static const char * NUMBEROFPACKETS = "numberOfPackets";
|
||||
static const char * FILTER = "filter";
|
||||
static const char * SELECT = "select";
|
||||
static const char * SERIALONLY = "serialOnly";
|
||||
static const char * COUNTONLY = "countOnly";
|
||||
static const char * DEVICEWITHSTATUS = "deviceWithStatus";
|
||||
static const char * DEVICESWITHSTATUS = "devicesWithStatus";
|
||||
static const char * DEVICES = "devices";
|
||||
static const char * COUNT = "count";
|
||||
static const char * SERIALNUMBERS = "serialNumbers";
|
||||
static const char * CONFIGURATIONS = "configurations";
|
||||
static const char * NAME = "name";
|
||||
static const char * COMMANDS = "commands";
|
||||
static const char * COMMANDUUID = "commandUUID";
|
||||
static const char * FIRMWARES = "firmwares";
|
||||
static const char * TOPIC = "topic";
|
||||
static const char * HOST = "host";
|
||||
static const char * OS = "os";
|
||||
static const char * HOSTNAME = "hostname";
|
||||
static const char * PROCESSORS = "processors";
|
||||
static const char * REASON = "reason";
|
||||
static const char * RELOAD = "reload";
|
||||
static const char * SUBSYSTEMS = "subsystems";
|
||||
static const char * FILEUUID = "uuid";
|
||||
static const char * USERID = "userId";
|
||||
static const char * PASSWORD = "password";
|
||||
static const char * TOKEN = "token";
|
||||
static const char * SETLOGLEVEL = "setloglevel";
|
||||
static const char * GETLOGLEVELS = "getloglevels";
|
||||
static const char * GETSUBSYSTEMNAMES = "getsubsystemnames";
|
||||
static const char * GETLOGLEVELNAMES = "getloglevelnames";
|
||||
static const char * STATS = "stats";
|
||||
static const char * PING = "ping";
|
||||
static const char * PARAMETERS = "parameters";
|
||||
static const char * VALUE = "value";
|
||||
static const char * LASTONLY = "lastOnly";
|
||||
static const char * NEWEST = "newest";
|
||||
static const char * ACTIVESCAN = "activeScan";
|
||||
static const char * OVERRIDEDFS = "override_dfs";
|
||||
static const char * LIST = "list";
|
||||
static const char * TAG = "tag";
|
||||
static const char * TAGLIST = "tagList";
|
||||
static const char * DESCRIPTION = "description";
|
||||
static const char * NOTES = "notes";
|
||||
static const char * DEVICETYPE = "deviceType";
|
||||
static const char * REVISION = "revision";
|
||||
static const char * AGES = "ages";
|
||||
static const char * REVISIONS = "revisions";
|
||||
static const char * DEVICETYPES = "deviceTypes";
|
||||
static const char * LATESTONLY = "latestOnly";
|
||||
static const char * IDONLY = "idOnly";
|
||||
static const char * REVISIONSET = "revisionSet";
|
||||
static const char * DEVICESET = "deviceSet";
|
||||
static const char * HISTORY = "history";
|
||||
static const char * ID = "id";
|
||||
static const char * VERSION = "version";
|
||||
static const char * TIMES = "times";
|
||||
static const char * UPTIME = "uptime";
|
||||
static const char * START = "start";
|
||||
|
||||
static const char * NEWPASSWORD = "newPassword";
|
||||
static const char * USERS = "users";
|
||||
static const char * WITHEXTENDEDINFO = "withExtendedInfo";
|
||||
|
||||
static const char * ERRORTEXT = "errorText";
|
||||
static const char * ERRORCODE = "errorCode";
|
||||
static const char * AVATARID = "avatarId";
|
||||
static const char * UNNAMED = "(unnamed)";
|
||||
static const char * UNSPECIFIED = "(unspecified)";
|
||||
static const char * CONTENTDISPOSITION = "Content-Disposition";
|
||||
static const char * CONTENTTYPE = "Content-Type";
|
||||
|
||||
static const char * REQUIREMENTS = "requirements";
|
||||
static const char * PASSWORDPATTERN = "passwordPattern";
|
||||
static const char * ACCESSPOLICY = "accessPolicy";
|
||||
static const char * PASSWORDPOLICY = "passwordPolicy";
|
||||
static const char * FORGOTPASSWORD = "forgotPassword";
|
||||
static const char * RESENDMFACODE = "resendMFACode";
|
||||
static const char * COMPLETEMFACHALLENGE = "completeMFAChallenge";
|
||||
static const char * ME = "me";
|
||||
static const char * TELEMETRY = "telemetry";
|
||||
static const char * INTERVAL = "interval";
|
||||
static const char * UI = "UI";
|
||||
|
||||
}
|
||||
@@ -51,14 +51,13 @@ namespace OpenWifi {
|
||||
Pool_->shutdown();
|
||||
}
|
||||
|
||||
DBType Type() const { return dbType_; };
|
||||
private:
|
||||
inline int Setup_SQLite();
|
||||
inline int Setup_MySQL();
|
||||
inline int Setup_PostgreSQL();
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Poco::Data::SessionPool> Pool_;
|
||||
Poco::SharedPtr<Poco::Data::SessionPool> Pool_;
|
||||
Poco::Data::SQLite::Connector SQLiteConn_;
|
||||
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
||||
Poco::Data::MySQL::Connector MySQLConn_;
|
||||
@@ -74,22 +73,18 @@ namespace OpenWifi {
|
||||
Logger().notice("SQLite StorageClass enabled.");
|
||||
dbType_ = sqlite;
|
||||
auto DBName = MicroService::instance().DataDir() + "/" + MicroService::instance().ConfigGetString("storage.type.sqlite.db");
|
||||
int NumSessions = (int) MicroService::instance().ConfigGetInt("storage.type.sqlite.maxsessions", 64);
|
||||
int IdleTime = (int) MicroService::instance().ConfigGetInt("storage.type.sqlite.idletime", 60);
|
||||
|
||||
Poco::Data::SQLite::Connector::registerConnector();
|
||||
// Pool_ = std::make_unique<Poco::Data::SessionPool>(new Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
||||
// (int)NumSessions, (int)IdleTime));
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
||||
(int)NumSessions, (int)IdleTime);
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.sqlite.maxsessions", 64);
|
||||
auto IdleTime = MicroService::instance().ConfigGetInt("storage.type.sqlite.idletime", 60);
|
||||
SQLiteConn_.registerConnector();
|
||||
Pool_ = Poco::SharedPtr<Poco::Data::SessionPool>(new Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 4, NumSessions, IdleTime));
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline int StorageClass::Setup_MySQL() {
|
||||
Logger().notice("MySQL StorageClass enabled.");
|
||||
dbType_ = mysql;
|
||||
int NumSessions = (int) MicroService::instance().ConfigGetInt("storage.type.mysql.maxsessions", 64);
|
||||
int IdleTime = (int) MicroService::instance().ConfigGetInt("storage.type.mysql.idletime", 60);
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.mysql.maxsessions", 64);
|
||||
auto IdleTime = MicroService::instance().ConfigGetInt("storage.type.mysql.idletime", 60);
|
||||
auto Host = MicroService::instance().ConfigGetString("storage.type.mysql.host");
|
||||
auto Username = MicroService::instance().ConfigGetString("storage.type.mysql.username");
|
||||
auto Password = MicroService::instance().ConfigGetString("storage.type.mysql.password");
|
||||
@@ -104,8 +99,8 @@ namespace OpenWifi {
|
||||
";port=" + Port +
|
||||
";compress=true;auto-reconnect=true";
|
||||
|
||||
Poco::Data::MySQL::Connector::registerConnector();
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8, NumSessions, IdleTime);
|
||||
MySQLConn_.registerConnector();
|
||||
Pool_ = Poco::SharedPtr<Poco::Data::SessionPool>(new Poco::Data::SessionPool(MySQLConn_.name(), ConnectionStr, 4, NumSessions, IdleTime));
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -113,8 +108,8 @@ namespace OpenWifi {
|
||||
inline int StorageClass::Setup_PostgreSQL() {
|
||||
Logger().notice("PostgreSQL StorageClass enabled.");
|
||||
dbType_ = pgsql;
|
||||
int NumSessions = (int) MicroService::instance().ConfigGetInt("storage.type.postgresql.maxsessions", 64);
|
||||
int IdleTime = (int) MicroService::instance().ConfigGetInt("storage.type.postgresql.idletime", 60);
|
||||
auto NumSessions = MicroService::instance().ConfigGetInt("storage.type.postgresql.maxsessions", 64);
|
||||
auto IdleTime = MicroService::instance().ConfigGetInt("storage.type.postgresql.idletime", 60);
|
||||
auto Host = MicroService::instance().ConfigGetString("storage.type.postgresql.host");
|
||||
auto Username = MicroService::instance().ConfigGetString("storage.type.postgresql.username");
|
||||
auto Password = MicroService::instance().ConfigGetString("storage.type.postgresql.password");
|
||||
@@ -130,8 +125,8 @@ namespace OpenWifi {
|
||||
" port=" + Port +
|
||||
" connect_timeout=" + ConnectionTimeout;
|
||||
|
||||
Poco::Data::PostgreSQL::Connector::registerConnector();
|
||||
Pool_ = std::make_unique<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8, NumSessions, IdleTime);
|
||||
PostgresConn_.registerConnector();
|
||||
Pool_ = Poco::SharedPtr<Poco::Data::SessionPool>(new Poco::Data::SessionPool(PostgresConn_.name(), ConnectionStr, 4, NumSessions, IdleTime));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,8 +33,7 @@ namespace ORM {
|
||||
FT_TEXT,
|
||||
FT_VARCHAR,
|
||||
FT_BLOB,
|
||||
FT_BOOLEAN,
|
||||
FT_REAL
|
||||
FT_BOOLEAN
|
||||
};
|
||||
|
||||
enum Indextype {
|
||||
@@ -82,14 +81,14 @@ namespace ORM {
|
||||
typedef std::vector<Field> FieldVec;
|
||||
|
||||
struct IndexEntry {
|
||||
std::string FieldName;
|
||||
Indextype Type;
|
||||
std::string FieldName;
|
||||
Indextype Type;
|
||||
};
|
||||
typedef std::vector<IndexEntry> IndexEntryVec;
|
||||
|
||||
struct Index {
|
||||
std::string Name;
|
||||
IndexEntryVec Entries;
|
||||
IndexEntryVec Entries;
|
||||
};
|
||||
typedef std::vector<Index> IndexVec;
|
||||
|
||||
@@ -109,13 +108,11 @@ namespace ORM {
|
||||
return "LONGBLOB";
|
||||
else if(Type==OpenWifi::DBType::pgsql)
|
||||
return "BYTEA";
|
||||
else
|
||||
else if(Type==OpenWifi::DBType::sqlite)
|
||||
return "BLOB";
|
||||
case FT_REAL:
|
||||
return "REAL";
|
||||
default:
|
||||
assert(false);
|
||||
|
||||
default:
|
||||
assert(false);
|
||||
return "";
|
||||
}
|
||||
assert(false);
|
||||
return "";
|
||||
@@ -124,13 +121,12 @@ namespace ORM {
|
||||
inline std::string Escape(const std::string &S) {
|
||||
std::string R;
|
||||
|
||||
for(const auto &i:S) {
|
||||
if (i == '\'')
|
||||
for(const auto &i:S)
|
||||
if(i=='\'')
|
||||
R += "''";
|
||||
else
|
||||
R += i;
|
||||
}
|
||||
return R;
|
||||
return R;
|
||||
}
|
||||
|
||||
enum SqlComparison { EQ = 0, NEQ, LT, LTE, GT, GTE };
|
||||
@@ -155,25 +151,13 @@ namespace ORM {
|
||||
return S;
|
||||
}
|
||||
|
||||
inline std::string to_string(const Poco::Data::BLOB &blob) {
|
||||
auto Content = blob.content();
|
||||
std::string result;
|
||||
result.reserve(Content.size());
|
||||
for(const auto &c:Content) {
|
||||
result += (char) c;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
inline std::string to_string(const char * S) {
|
||||
return S;
|
||||
}
|
||||
|
||||
template <typename RecordType> class DBCache {
|
||||
public:
|
||||
DBCache(unsigned Size, unsigned Timeout) :
|
||||
Size_(Size),
|
||||
Timeout_(Timeout)
|
||||
DBCache(unsigned Size, unsigned Timeout)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -182,8 +166,7 @@ namespace ORM {
|
||||
virtual void UpdateCache(const RecordType &R)=0;
|
||||
virtual void Delete(const std::string &FieldName, const std::string &Value)=0;
|
||||
private:
|
||||
size_t Size_=0;
|
||||
uint64_t Timeout_=0;
|
||||
|
||||
};
|
||||
|
||||
template <typename RecordTuple, typename RecordType> class DB {
|
||||
@@ -199,8 +182,8 @@ namespace ORM {
|
||||
Poco::Logger &L,
|
||||
const char *Prefix,
|
||||
DBCache<RecordType> * Cache=nullptr):
|
||||
TableName_(TableName),
|
||||
Type_(dbtype),
|
||||
TableName_(TableName),
|
||||
Pool_(Pool),
|
||||
Logger_(L),
|
||||
Prefix_(Prefix),
|
||||
@@ -307,7 +290,7 @@ namespace ORM {
|
||||
return std::string("(")+P1 + BOPS[BOP] + P2 +")";
|
||||
}
|
||||
|
||||
std::string OP( [[maybe_unused]] bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) {
|
||||
std::string OP( bool Paran, const std::string &P1, SqlBinaryOp BOP , const std::string &P2) {
|
||||
return P1 + BOPS[BOP] + P2 +")";
|
||||
}
|
||||
|
||||
@@ -432,7 +415,7 @@ namespace ORM {
|
||||
Poco::Data::Statement Select(Session);
|
||||
RecordTuple RT;
|
||||
|
||||
std::string St = "select " + SelectFields_ + " from " + TableName_ + " where " + FieldName + "=?" + " limit 1";
|
||||
std::string St = "select " + SelectFields_ + " from " + TableName_ + " where " + FieldName + "=?" ;
|
||||
|
||||
auto tValue{Value};
|
||||
|
||||
@@ -441,12 +424,13 @@ namespace ORM {
|
||||
Poco::Data::Keywords::use(tValue);
|
||||
Select.execute();
|
||||
|
||||
if(Select.execute()==1) {
|
||||
if(Select.rowsExtracted()==1) {
|
||||
Convert(RT,R);
|
||||
if(Cache_)
|
||||
Cache_->UpdateCache(R);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
}
|
||||
@@ -483,11 +467,9 @@ namespace ORM {
|
||||
return false;
|
||||
}
|
||||
|
||||
typedef std::vector<RecordTuple> RecordList;
|
||||
typedef std::vector<RecordType> RecordVec;
|
||||
typedef RecordType RecordName;
|
||||
typedef std::vector<RecordTuple> RecordList;
|
||||
|
||||
bool GetRecords( uint64_t Offset, uint64_t HowMany, RecordVec & Records, const std::string & Where = "", const std::string & OrderBy = "") {
|
||||
bool GetRecords( uint64_t Offset, uint64_t HowMany, std::vector<RecordType> & Records, const std::string & Where = "", const std::string & OrderBy = "") {
|
||||
try {
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
Poco::Data::Statement Select(Session);
|
||||
@@ -542,21 +524,6 @@ namespace ORM {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RunStatement(const std::string &St) {
|
||||
try {
|
||||
Poco::Data::Session Session = Pool_.get();
|
||||
Poco::Data::Statement Command(Session);
|
||||
|
||||
Command << St ;
|
||||
Command.execute();
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger_.log(E);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
template <typename T> bool ReplaceRecord(field_name_t FieldName, const T & Value, RecordType & R) {
|
||||
try {
|
||||
if(Exists(FieldName, Value)) {
|
||||
@@ -699,6 +666,9 @@ namespace ORM {
|
||||
if(!ItemList.empty()) {
|
||||
OrderByString = " ORDER BY " + ItemList;
|
||||
}
|
||||
|
||||
std::cout << OrderByString << std::endl;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -759,11 +729,11 @@ namespace ORM {
|
||||
try {
|
||||
Command << i, Poco::Data::Keywords::now;
|
||||
} catch (const Poco::Exception &E) {
|
||||
// Logger_.log(E);
|
||||
// Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This may or may not be a problem.", i));
|
||||
if(!IgnoreExceptions) {
|
||||
return false;
|
||||
}
|
||||
Logger_.log(E);
|
||||
Logger_.error(Poco::format("The following statement '%s' generated an exception during a table upgrade. This maya or may not be a problem.", i));
|
||||
}
|
||||
if(!IgnoreExceptions) {
|
||||
return false;
|
||||
}
|
||||
Command.reset(Session);
|
||||
}
|
||||
@@ -839,32 +809,32 @@ namespace ORM {
|
||||
return ManipulateVectorMember(&RecordType::users, FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, true);
|
||||
}
|
||||
|
||||
inline bool DelConfiguration(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::deviceConfiguration, FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, true);
|
||||
}
|
||||
|
||||
inline bool DelVariable(field_name_t FieldName, const std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::variables, FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||
inline bool AddInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||
std::string FakeUUID{ Prefix + ":" + ChildUUID};
|
||||
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, true);
|
||||
}
|
||||
|
||||
inline bool DeleteInUse(field_name_t FieldName, const std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||
inline bool DeleteInUse(field_name_t FieldName, std::string & ParentUUID, const std::string & Prefix, const std::string & ChildUUID) {
|
||||
std::string FakeUUID{ Prefix + ":" + ChildUUID};
|
||||
return ManipulateVectorMember(&RecordType::inUse,FieldName, ParentUUID, FakeUUID, false);
|
||||
}
|
||||
|
||||
inline bool DeleteContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddContact(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::contacts,FieldName, ParentUUID, ChildUUID, true);
|
||||
}
|
||||
|
||||
inline bool DeleteLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, false);
|
||||
}
|
||||
|
||||
inline bool AddLocation(field_name_t FieldName, std::string & ParentUUID, const std::string & ChildUUID) {
|
||||
return ManipulateVectorMember(&RecordType::locations,FieldName, ParentUUID, ChildUUID, true);
|
||||
}
|
||||
|
||||
inline bool GetInUse(field_name_t FieldName, const std::string & UUID, std::vector<std::string> & UUIDs ) {
|
||||
RecordType R;
|
||||
if(GetRecord(FieldName,UUID,R)) {
|
||||
@@ -897,19 +867,19 @@ namespace ORM {
|
||||
}
|
||||
|
||||
protected:
|
||||
std::string TableName_;
|
||||
OpenWifi::DBType Type_;
|
||||
Poco::Data::SessionPool &Pool_;
|
||||
Poco::Logger &Logger_;
|
||||
std::string Prefix_;
|
||||
std::string TableName_;
|
||||
DBCache<RecordType> *Cache_= nullptr;
|
||||
private:
|
||||
OpenWifi::DBType Type_;
|
||||
std::string CreateFields_;
|
||||
std::string SelectFields_;
|
||||
std::string SelectList_;
|
||||
std::string UpdateFields_;
|
||||
std::vector<std::string> IndexCreation_;
|
||||
std::map<std::string,int> FieldNames_;
|
||||
std::string Prefix_;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,394 +0,0 @@
|
||||
//
|
||||
// Created by stephane bourque on 2022-02-21.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include "Poco/String.h"
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-variable"
|
||||
#endif
|
||||
|
||||
namespace OpenWifi::RESTAPI::Errors {
|
||||
static const std::string MissingUUID{"Missing UUID."};
|
||||
static const std::string MissingSerialNumber{"Missing Serial Number."};
|
||||
static const std::string InternalError{"Internal error. Please try later."};
|
||||
static const std::string InvalidJSONDocument{"Invalid JSON document."};
|
||||
static const std::string UnsupportedHTTPMethod{"Unsupported HTTP Method"};
|
||||
static const std::string StillInUse{"Element still in use."};
|
||||
static const std::string CouldNotBeDeleted{"Element could not be deleted."};
|
||||
static const std::string NameMustBeSet{"The name property must be set."};
|
||||
static const std::string ConfigBlockInvalid{"Configuration block type invalid."};
|
||||
static const std::string UnknownId{"Unknown UUID."};
|
||||
static const std::string InvalidDeviceTypes{"Unknown or invalid device type(s)."};
|
||||
static const std::string RecordNotCreated{"Record could not be created."};
|
||||
static const std::string RecordNotUpdated{"Record could not be updated."};
|
||||
static const std::string UnknownManagementPolicyUUID{"Unknown management policy UUID."};
|
||||
static const std::string CannotDeleteRoot{"Root Entity cannot be removed, only modified."};
|
||||
static const std::string MustCreateRootFirst{"Root entity must be created first."};
|
||||
static const std::string ParentUUIDMustExist{"Parent UUID must exist."};
|
||||
static const std::string ConfigurationMustExist{"Configuration must exist."};
|
||||
static const std::string MissingOrInvalidParameters{"Invalid or missing parameters."};
|
||||
static const std::string UnknownSerialNumber{"Unknown Serial Number."};
|
||||
static const std::string InvalidSerialNumber{"Invalid Serial Number."};
|
||||
static const std::string SerialNumberExists{"Serial Number already exists."};
|
||||
static const std::string ValidNonRootUUID{"Must be a non-root, and valid UUID."};
|
||||
static const std::string VenueMustExist{"Venue does not exist."};
|
||||
static const std::string NotBoth{"You cannot specify both Entity and Venue"};
|
||||
static const std::string EntityMustExist{"Entity must exist."};
|
||||
static const std::string ParentOrEntityMustBeSet{"Parent or Entity must be set."};
|
||||
static const std::string ContactMustExist{"Contact must exist."};
|
||||
static const std::string LocationMustExist{"Location must exist."};
|
||||
static const std::string OnlyWSSupported{"This endpoint only supports WebSocket."};
|
||||
static const std::string SerialNumberMismatch{"Serial Number mismatch."};
|
||||
static const std::string InvalidCommand{"Invalid command."};
|
||||
static const std::string NoRecordsDeleted{"No records deleted."};
|
||||
static const std::string DeviceNotConnected{"Device is not currently connected."};
|
||||
static const std::string CannotCreateWS{"Telemetry system could not create WS endpoint. Please try again."};
|
||||
static const std::string BothDeviceTypeRevision{"Both deviceType and revision must be set."};
|
||||
static const std::string IdOrSerialEmpty{"SerialNumber and Id must not be empty."};
|
||||
static const std::string MissingUserID{"Missing user ID."};
|
||||
static const std::string IdMustBe0{"To create a user, you must set the ID to 0"};
|
||||
static const std::string InvalidUserRole{"Invalid userRole."};
|
||||
static const std::string InvalidEmailAddress{"Invalid email address."};
|
||||
static const std::string PasswordRejected{"Password was rejected. This maybe an old password."};
|
||||
static const std::string InvalidIPRanges{"Invalid IP range specifications."};
|
||||
static const std::string InvalidLOrderBy{"Invalid orderBy specification."};
|
||||
static const std::string NeedMobileNumber{"You must provide at least one validated phone number."};
|
||||
static const std::string BadMFAMethod{"MFA only supports sms or email."};
|
||||
static const std::string InvalidCredentials{"Invalid credentials (username/password)."};
|
||||
static const std::string InvalidPassword{"Password does not conform to basic password rules."};
|
||||
static const std::string UserPendingVerification{"User access denied pending email verification."};
|
||||
static const std::string PasswordMustBeChanged{"Password must be changed."};
|
||||
static const std::string UnrecognizedRequest{"Ill-formed request. Please consult documentation."};
|
||||
static const std::string MissingAuthenticationInformation{"Missing authentication information."};
|
||||
static const std::string InsufficientAccessRights{"Insufficient access rights to complete the operation."};
|
||||
static const std::string ExpiredToken{"Token has expired, user must login."};
|
||||
static const std::string SubscriberMustExist{"Subscriber must exist."};
|
||||
static const std::string AuthenticatorVerificationIncomplete{"Authenticator validation is not complete."};
|
||||
static const std::string SMSCouldNotBeSentRetry{"SMS could not be sent to validate device, try later or change the phone number."};
|
||||
static const std::string SMSCouldNotValidate{"Code and number could not be validated"};
|
||||
static const std::string InvalidDeviceClass{"Invalid device class. Must be: any, venue, entity, or subscriber"};
|
||||
static const std::string SerialNumberAlreadyProvisioned{"This device has already been provisioned to a subscriber."};
|
||||
static const std::string SerialNumberNotTheProperClass{"Device is not available to subscribers. It ahs been assigned to another class of devices."};
|
||||
static const std::string UserAlreadyExists{"Username already exists."};
|
||||
static const std::string NotImplemented{"Function not implemented."};
|
||||
static const std::string VariableMustExist{"Specified variable does not exist."};
|
||||
static const std::string InvalidEntityType{"Invalid entity type."};
|
||||
static const std::string CannotDeleteSubEntity{"Cannot delete the default subscriber entity."};
|
||||
static const std::string OperatorIdMustExist{"Missing or bad Operator ID"};
|
||||
static const std::string CannotDeleteDefaultOperator{"Cannot delete the default operator."};
|
||||
static const std::string CannotCreateDefaultOperator{"Cannot create the default operator."};
|
||||
static const std::string InvalidRRM{"Invalid RRM value."};
|
||||
static const std::string InvalidIPAddresses{"Invalid IP addresses."};
|
||||
static const std::string InvalidBillingCode{"Empty of invalid billing code."};
|
||||
static const std::string InvalidBillingPeriod{"Invalid billing period."};
|
||||
static const std::string InvalidSubscriberId{"Invalid subscriber ID."};
|
||||
static const std::string InvalidContactId{"Invalid contact ID."};
|
||||
static const std::string InvalidLocationId{"Invalid location ID."};
|
||||
static const std::string InvalidContactType{"Invalid contact type."};
|
||||
static const std::string InvalidLocationType{"Invalid location type."};
|
||||
static const std::string InvalidOperatorId{"Invalid operator ID."};
|
||||
static const std::string InvalidServiceClassId{"Invalid service class ID."};
|
||||
static const std::string InvalidSubscriberDeviceId{"Invalid subscriber device ID."};
|
||||
static const std::string InvalidRegistrationOperatorId{"Invalid registration operator ID."};
|
||||
static const std::string InvalidRegistrationOperatorName{"Invalid registration operator name."};
|
||||
static const std::string RegistrationNameDuplicate{"Registration name must be unique."};
|
||||
}
|
||||
|
||||
namespace OpenWifi::RESTAPI::Protocol {
|
||||
static const char * CAPABILITIES = "capabilities";
|
||||
static const char * LOGS = "logs";
|
||||
static const char * HEALTHCHECKS = "healthchecks";
|
||||
static const char * STATISTICS = "statistics";
|
||||
static const char * STATUS = "status";
|
||||
static const char * SERIALNUMBER = "serialNumber";
|
||||
static const char * PERFORM = "perform";
|
||||
static const char * CONFIGURE = "configure";
|
||||
static const char * UPGRADE = "upgrade";
|
||||
static const char * REBOOT = "reboot";
|
||||
static const char * FACTORY = "factory";
|
||||
static const char * LEDS = "leds";
|
||||
static const char * TRACE = "trace";
|
||||
static const char * REQUEST = "request";
|
||||
static const char * WIFISCAN = "wifiscan";
|
||||
static const char * EVENTQUEUE = "eventqueue";
|
||||
static const char * RTTY = "rtty";
|
||||
static const char * COMMAND = "command";
|
||||
static const char * STARTDATE = "startDate";
|
||||
static const char * ENDDATE = "endDate";
|
||||
static const char * OFFSET = "offset";
|
||||
static const char * LIMIT = "limit";
|
||||
static const char * LIFETIME = "lifetime";
|
||||
static const char * UUID = "UUID";
|
||||
static const char * DATA = "data";
|
||||
static const char * CONFIGURATION = "configuration";
|
||||
static const char * WHEN = "when";
|
||||
static const char * URI = "uri";
|
||||
static const char * LOGTYPE = "logType";
|
||||
static const char * VALUES = "values";
|
||||
static const char * TYPES = "types";
|
||||
static const char * PAYLOAD = "payload";
|
||||
static const char * KEEPREDIRECTOR = "keepRedirector";
|
||||
static const char * NETWORK = "network";
|
||||
static const char * INTERFACE = "interface";
|
||||
static const char * BANDS = "bands";
|
||||
static const char * CHANNELS = "channels";
|
||||
static const char * VERBOSE = "verbose";
|
||||
static const char * MESSAGE = "message";
|
||||
static const char * STATE = "state";
|
||||
static const char * HEALTHCHECK = "healthcheck";
|
||||
static const char * PCAP_FILE_TYPE = "pcap";
|
||||
static const char * DURATION = "duration";
|
||||
static const char * NUMBEROFPACKETS = "numberOfPackets";
|
||||
static const char * FILTER = "filter";
|
||||
static const char * SELECT = "select";
|
||||
static const char * SERIALONLY = "serialOnly";
|
||||
static const char * COUNTONLY = "countOnly";
|
||||
static const char * DEVICEWITHSTATUS = "deviceWithStatus";
|
||||
static const char * DEVICESWITHSTATUS = "devicesWithStatus";
|
||||
static const char * DEVICES = "devices";
|
||||
static const char * COUNT = "count";
|
||||
static const char * SERIALNUMBERS = "serialNumbers";
|
||||
static const char * CONFIGURATIONS = "configurations";
|
||||
static const char * NAME = "name";
|
||||
static const char * COMMANDS = "commands";
|
||||
static const char * COMMANDUUID = "commandUUID";
|
||||
static const char * FIRMWARES = "firmwares";
|
||||
static const char * TOPIC = "topic";
|
||||
static const char * HOST = "host";
|
||||
static const char * OS = "os";
|
||||
static const char * HOSTNAME = "hostname";
|
||||
static const char * PROCESSORS = "processors";
|
||||
static const char * REASON = "reason";
|
||||
static const char * RELOAD = "reload";
|
||||
static const char * SUBSYSTEMS = "subsystems";
|
||||
static const char * FILEUUID = "uuid";
|
||||
static const char * USERID = "userId";
|
||||
static const char * PASSWORD = "password";
|
||||
static const char * TOKEN = "token";
|
||||
static const char * SETLOGLEVEL = "setloglevel";
|
||||
static const char * GETLOGLEVELS = "getloglevels";
|
||||
static const char * GETSUBSYSTEMNAMES = "getsubsystemnames";
|
||||
static const char * GETLOGLEVELNAMES = "getloglevelnames";
|
||||
static const char * STATS = "stats";
|
||||
static const char * PING = "ping";
|
||||
static const char * PARAMETERS = "parameters";
|
||||
static const char * VALUE = "value";
|
||||
static const char * LASTONLY = "lastOnly";
|
||||
static const char * NEWEST = "newest";
|
||||
static const char * ACTIVESCAN = "activeScan";
|
||||
static const char * OVERRIDEDFS = "override_dfs";
|
||||
static const char * LIST = "list";
|
||||
static const char * TAG = "tag";
|
||||
static const char * TAGLIST = "tagList";
|
||||
static const char * DESCRIPTION = "description";
|
||||
static const char * NOTES = "notes";
|
||||
static const char * DEVICETYPE = "deviceType";
|
||||
static const char * REVISION = "revision";
|
||||
static const char * AGES = "ages";
|
||||
static const char * REVISIONS = "revisions";
|
||||
static const char * DEVICETYPES = "deviceTypes";
|
||||
static const char * LATESTONLY = "latestOnly";
|
||||
static const char * IDONLY = "idOnly";
|
||||
static const char * REVISIONSET = "revisionSet";
|
||||
static const char * DEVICESET = "deviceSet";
|
||||
static const char * HISTORY = "history";
|
||||
static const char * ID = "id";
|
||||
static const char * VERSION = "version";
|
||||
static const char * TIMES = "times";
|
||||
static const char * UPTIME = "uptime";
|
||||
static const char * START = "start";
|
||||
|
||||
static const char * NEWPASSWORD = "newPassword";
|
||||
static const char * USERS = "users";
|
||||
static const char * WITHEXTENDEDINFO = "withExtendedInfo";
|
||||
|
||||
static const char * ERRORTEXT = "errorText";
|
||||
static const char * ERRORCODE = "errorCode";
|
||||
static const char * AVATARID = "avatarId";
|
||||
static const char * UNNAMED = "(unnamed)";
|
||||
static const char * UNSPECIFIED = "(unspecified)";
|
||||
static const char * CONTENTDISPOSITION = "Content-Disposition";
|
||||
static const char * CONTENTTYPE = "Content-Type";
|
||||
|
||||
static const char * REQUIREMENTS = "requirements";
|
||||
static const char * PASSWORDPATTERN = "passwordPattern";
|
||||
static const char * ACCESSPOLICY = "accessPolicy";
|
||||
static const char * PASSWORDPOLICY = "passwordPolicy";
|
||||
static const char * FORGOTPASSWORD = "forgotPassword";
|
||||
static const char * RESENDMFACODE = "resendMFACode";
|
||||
static const char * COMPLETEMFACHALLENGE = "completeMFAChallenge";
|
||||
static const char * ME = "me";
|
||||
static const char * TELEMETRY = "telemetry";
|
||||
static const char * INTERVAL = "interval";
|
||||
static const char * UI = "UI";
|
||||
static const char * BANDWIDTH = "bandwidth";
|
||||
}
|
||||
|
||||
namespace OpenWifi::uCentralProtocol {
|
||||
|
||||
const int SERIAL_NUMBER_LENGTH = 30;
|
||||
|
||||
// vocabulary used in the PROTOCOL.md file
|
||||
static const char *JSONRPC = "jsonrpc";
|
||||
static const char *ID = "id";
|
||||
static const char *UUID = "uuid";
|
||||
static const char *JSONRPC_VERSION = "2.0";
|
||||
static const char *METHOD = "method";
|
||||
static const char *PARAMS = "params";
|
||||
static const char *SERIAL = "serial";
|
||||
static const char *FIRMWARE = "firmware";
|
||||
static const char *CONNECT = "connect";
|
||||
static const char *STATE = "state";
|
||||
static const char *STATUS = "status";
|
||||
static const char *ERROR = "error";
|
||||
static const char *TEXT = "text";
|
||||
static const char *HEALTHCHECK = "healthcheck";
|
||||
static const char *LOG = "log";
|
||||
static const char *CRASHLOG = "crashlog";
|
||||
static const char *PING = "ping";
|
||||
static const char *CFGPENDING = "cfgpending";
|
||||
static const char *RECOVERY = "recovery";
|
||||
static const char *COMPRESS_64 = "compress_64";
|
||||
static const char *CAPABILITIES = "capabilities";
|
||||
static const char *REQUEST_UUID = "request_uuid";
|
||||
static const char *SANITY = "sanity";
|
||||
static const char *DATA = "data";
|
||||
static const char *LOGLINES = "loglines";
|
||||
static const char *SEVERITY = "severity";
|
||||
static const char *ACTIVE = "active";
|
||||
static const char *OVERRIDEDFS = "override_dfs";
|
||||
static const char *REBOOT = "reboot";
|
||||
static const char *WHEN = "when";
|
||||
static const char *CONFIG = "config";
|
||||
static const char *EMPTY_JSON_DOC = "{}";
|
||||
static const char *RESULT = "result";
|
||||
static const char *REQUEST = "request";
|
||||
static const char *PERFORM = "perform";
|
||||
static const char *CONFIGURE = "configure";
|
||||
static const char *PENDING = "pending";
|
||||
static const char *SUBMITTED_BY_SYSTEM = "*system";
|
||||
static const char *URI = "uri";
|
||||
static const char *COMMAND = "command";
|
||||
static const char *PAYLOAD = "payload";
|
||||
static const char *KEEP_REDIRECTOR = "keep_redirector";
|
||||
static const char *DURATION = "duration";
|
||||
static const char *PATTERN = "pattern";
|
||||
static const char *LEDS = "leds";
|
||||
static const char *ON = "on";
|
||||
static const char *OFF = "off";
|
||||
static const char *BLINK = "blink";
|
||||
static const char *PACKETS = "packets";
|
||||
static const char *NETWORK = "network";
|
||||
static const char *INTERFACE = "interface";
|
||||
static const char *TRACE = "trace";
|
||||
static const char *WIFISCAN = "wifiscan";
|
||||
static const char *TYPES = "types";
|
||||
static const char *EVENT = "event";
|
||||
static const char *MESSAGE = "message";
|
||||
static const char *RTTY = "rtty";
|
||||
static const char *TOKEN = "token";
|
||||
static const char *SERVER = "server";
|
||||
static const char *PORT = "port";
|
||||
static const char *USER = "user";
|
||||
static const char *TIMEOUT = "timeout";
|
||||
static const char *UPGRADE = "upgrade";
|
||||
static const char *FACTORY = "factory";
|
||||
static const char *VERBOSE = "verbose";
|
||||
static const char *BANDS = "bands";
|
||||
static const char *CHANNELS = "channels";
|
||||
static const char *PASSWORD = "password";
|
||||
static const char *DEVICEUPDATE = "deviceupdate";
|
||||
|
||||
static const char *SERIALNUMBER = "serialNumber";
|
||||
static const char *COMPATIBLE = "compatible";
|
||||
static const char *DISCONNECTION = "disconnection";
|
||||
static const char *TIMESTAMP = "timestamp";
|
||||
static const char *SYSTEM = "system";
|
||||
static const char *HOST = "host";
|
||||
static const char *CONNECTIONIP = "connectionIp";
|
||||
static const char *TELEMETRY = "telemetry";
|
||||
static const char *BANDWIDTH = "bandwidth";
|
||||
}
|
||||
|
||||
namespace OpenWifi::uCentralProtocol::Events {
|
||||
|
||||
static const char *CONNECT = "connect";
|
||||
static const char *STATE = "state";
|
||||
static const char *HEALTHCHECK = "healthcheck";
|
||||
static const char *LOG = "log";
|
||||
static const char *CRASHLOG = "crashlog";
|
||||
static const char *PING = "ping";
|
||||
static const char *CFGPENDING = "cfgpending";
|
||||
static const char *RECOVERY = "recovery";
|
||||
static const char *TELEMETRY = "telemetry";
|
||||
static const char *DEVICEUPDATE = "deviceupdate";
|
||||
|
||||
enum EVENT_MSG {
|
||||
ET_UNKNOWN,
|
||||
ET_CONNECT,
|
||||
ET_STATE,
|
||||
ET_HEALTHCHECK,
|
||||
ET_LOG,
|
||||
ET_CRASHLOG,
|
||||
ET_PING,
|
||||
ET_CFGPENDING,
|
||||
ET_RECOVERY,
|
||||
ET_DEVICEUPDATE,
|
||||
ET_TELEMETRY
|
||||
};
|
||||
|
||||
inline static EVENT_MSG EventFromString(const std::string & Method) {
|
||||
static std::vector<std::pair<const char *,EVENT_MSG>> Values{
|
||||
{ CFGPENDING , ET_CFGPENDING },
|
||||
{ CONNECT, ET_CONNECT },
|
||||
{ CRASHLOG, ET_CRASHLOG },
|
||||
{ DEVICEUPDATE, ET_DEVICEUPDATE },
|
||||
{ HEALTHCHECK, ET_HEALTHCHECK },
|
||||
{ LOG, ET_LOG },
|
||||
{ PING, ET_PING },
|
||||
{ RECOVERY, ET_RECOVERY },
|
||||
{ STATE, ET_STATE },
|
||||
{ TELEMETRY, ET_TELEMETRY }
|
||||
};
|
||||
|
||||
std::string L = Poco::toLower(Method);
|
||||
auto hint = std::find_if(cbegin(Values),cend(Values),[&](const std::pair<const char *,EVENT_MSG> &v) ->bool { return strcmp(v.first,L.c_str())==0; });
|
||||
if(hint == cend(Values))
|
||||
return ET_UNKNOWN;
|
||||
return hint->second;
|
||||
};
|
||||
}
|
||||
|
||||
namespace OpenWifi::Provisioning::DeviceClass {
|
||||
|
||||
static const char * ANY = "any";
|
||||
static const char * SUBSCRIBER = "subscriber";
|
||||
static const char * VENUE = "venue";
|
||||
static const char * ENTITY = "entity";
|
||||
|
||||
inline bool Validate(const char *s) {
|
||||
static std::vector<std::string> Values{ ANY, ENTITY, SUBSCRIBER, VENUE };
|
||||
return std::find(cbegin(Values), cend(Values), s) != cend(Values);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#if defined(__GNUC__ )
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
|
||||
131
src/framework/uCentral_Protocol.h
Normal file
131
src/framework/uCentral_Protocol.h
Normal file
@@ -0,0 +1,131 @@
|
||||
//
|
||||
// License type: BSD 3-Clause License
|
||||
// License copy: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
||||
//
|
||||
// Created by Stephane Bourque on 2021-03-04.
|
||||
// Arilia Wireless Inc.
|
||||
//
|
||||
#pragma once
|
||||
|
||||
#include "Poco/String.h"
|
||||
|
||||
namespace OpenWifi::uCentralProtocol {
|
||||
|
||||
const int SERIAL_NUMBER_LENGTH = 30;
|
||||
|
||||
// vocabulary used in the PROTOCOL.md file
|
||||
static const char * JSONRPC = "jsonrpc";
|
||||
static const char * ID = "id";
|
||||
static const char * UUID = "uuid";
|
||||
static const char * JSONRPC_VERSION = "2.0";
|
||||
static const char * METHOD = "method";
|
||||
static const char * PARAMS = "params";
|
||||
static const char * SERIAL = "serial";
|
||||
static const char * FIRMWARE = "firmware";
|
||||
static const char * CONNECT = "connect";
|
||||
static const char * STATE = "state";
|
||||
static const char * HEALTHCHECK = "healthcheck";
|
||||
static const char * LOG = "log";
|
||||
static const char * CRASHLOG = "crashlog";
|
||||
static const char * PING = "ping";
|
||||
static const char * CFGPENDING = "cfgpending";
|
||||
static const char * RECOVERY = "recovery";
|
||||
static const char * COMPRESS_64 = "compress_64";
|
||||
static const char * CAPABILITIES = "capabilities";
|
||||
static const char * REQUEST_UUID = "request_uuid";
|
||||
static const char * SANITY = "sanity";
|
||||
static const char * DATA = "data";
|
||||
static const char * LOGLINES = "loglines";
|
||||
static const char * SEVERITY = "severity";
|
||||
static const char * ACTIVE = "active";
|
||||
static const char * OVERRIDEDFS = "override_dfs";
|
||||
static const char * REBOOT = "reboot";
|
||||
static const char * WHEN = "when";
|
||||
static const char * CONFIG = "config";
|
||||
static const char * EMPTY_JSON_DOC = "{}";
|
||||
static const char * RESULT = "result";
|
||||
static const char * REQUEST = "request";
|
||||
static const char * PERFORM = "perform";
|
||||
static const char * CONFIGURE = "configure";
|
||||
static const char * PENDING = "pending";
|
||||
static const char * SUBMITTED_BY_SYSTEM = "*system";
|
||||
static const char * URI = "uri";
|
||||
static const char * COMMAND = "command";
|
||||
static const char * PAYLOAD = "payload";
|
||||
static const char * KEEP_REDIRECTOR = "keep_redirector";
|
||||
static const char * DURATION = "duration";
|
||||
static const char * PATTERN = "pattern";
|
||||
static const char * LEDS = "leds";
|
||||
static const char * ON = "on";
|
||||
static const char * OFF = "off";
|
||||
static const char * BLINK = "blink";
|
||||
static const char * PACKETS = "packets";
|
||||
static const char * NETWORK = "network";
|
||||
static const char * INTERFACE = "interface";
|
||||
static const char * TRACE = "trace";
|
||||
static const char * WIFISCAN = "wifiscan";
|
||||
static const char * TYPES = "types";
|
||||
static const char * EVENT = "event";
|
||||
static const char * MESSAGE = "message";
|
||||
static const char * RTTY = "rtty";
|
||||
static const char * TOKEN = "token";
|
||||
static const char * SERVER = "server";
|
||||
static const char * PORT = "port";
|
||||
static const char * USER = "user";
|
||||
static const char * TIMEOUT = "timeout";
|
||||
static const char * UPGRADE = "upgrade";
|
||||
static const char * FACTORY = "factory";
|
||||
static const char * VERBOSE = "verbose";
|
||||
static const char * BANDS = "bands";
|
||||
static const char * CHANNELS = "channels";
|
||||
static const char * PASSWORD = "password";
|
||||
static const char * DEVICEUPDATE = "deviceupdate";
|
||||
|
||||
static const char * SERIALNUMBER = "serialNumber";
|
||||
static const char * COMPATIBLE = "compatible";
|
||||
static const char * DISCONNECTION = "disconnection";
|
||||
static const char * TIMESTAMP = "timestamp";
|
||||
static const char * SYSTEM = "system";
|
||||
static const char * HOST = "host";
|
||||
static const char * CONNECTIONIP = "connectionIp";
|
||||
static const char * TELEMETRY = "telemetry";
|
||||
|
||||
enum EVENT_MSG {
|
||||
ET_UNKNOWN,
|
||||
ET_CONNECT,
|
||||
ET_STATE,
|
||||
ET_HEALTHCHECK,
|
||||
ET_LOG,
|
||||
ET_CRASHLOG,
|
||||
ET_PING,
|
||||
ET_CFGPENDING,
|
||||
ET_RECOVERY,
|
||||
ET_DEVICEUPDATE,
|
||||
ET_TELEMETRY
|
||||
};
|
||||
|
||||
inline static EVENT_MSG EventFromString(const std::string & Method) {
|
||||
if (!Poco::icompare(Method, CONNECT)) {
|
||||
return ET_CONNECT;
|
||||
} else if (!Poco::icompare(Method, STATE)) {
|
||||
return ET_STATE;
|
||||
} else if (!Poco::icompare(Method, HEALTHCHECK)) {
|
||||
return ET_HEALTHCHECK;
|
||||
} else if (!Poco::icompare(Method, LOG)) {
|
||||
return ET_LOG;
|
||||
} else if (!Poco::icompare(Method, CRASHLOG)) {
|
||||
return ET_CRASHLOG;
|
||||
} else if (!Poco::icompare(Method, PING)) {
|
||||
return ET_PING;
|
||||
} else if (!Poco::icompare(Method, CFGPENDING)) {
|
||||
return ET_CFGPENDING;
|
||||
} else if (!Poco::icompare(Method, RECOVERY)) {
|
||||
return ET_RECOVERY;
|
||||
} else if (!Poco::icompare(Method, DEVICEUPDATE)) {
|
||||
return ET_DEVICEUPDATE;
|
||||
} else if (!Poco::icompare(Method, TELEMETRY)) {
|
||||
return ET_TELEMETRY;
|
||||
} else
|
||||
return ET_UNKNOWN;
|
||||
};
|
||||
}
|
||||
@@ -8,58 +8,36 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
RTTYS_ClientConnection::RTTYS_ClientConnection(std::unique_ptr<Poco::Net::WebSocket> WS, std::string &Id,
|
||||
RTTYS_ClientConnection::RTTYS_ClientConnection(Poco::Net::WebSocket &WS, std::string &Id,
|
||||
Poco::Net::SocketReactor &Reactor)
|
||||
: WS_(std::move(WS)),
|
||||
Id_(std::move(Id)),
|
||||
SR_(Reactor),
|
||||
Logger_(RTTYS_server()->Logger()) {
|
||||
: WS_(WS), Id_(std::move(Id)), SR_(Reactor) {
|
||||
RTTYS_server()->Register(Id_, this);
|
||||
if(RTTYS_server()->CanConnect(Id_,this)) {
|
||||
Logger().information(fmt::format("{}: Starting WS connection, session: {}.", Id_, RTTYS_server()->DeviceSessionID(Id_)));
|
||||
SR_.addEventHandler(*WS_,
|
||||
// std::cout << "WebSocket connecting..." << std::endl;
|
||||
SR_.addEventHandler(WS_,
|
||||
Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ReadableNotification>(
|
||||
*this, &RTTYS_ClientConnection::onSocketReadable));
|
||||
SR_.addEventHandler(*WS_,
|
||||
SR_.addEventHandler(WS_,
|
||||
Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ShutdownNotification>(
|
||||
*this, &RTTYS_ClientConnection::onSocketShutdown));
|
||||
|
||||
auto DoLogin = [this]() -> void {
|
||||
int tries = 0 ;
|
||||
while(tries < 10) {
|
||||
if(RTTYS_server()->Login(this->Id_)) {
|
||||
Logger().information(fmt::format("{}: WS client connected to device, session: {}.", Id_, RTTYS_server()->DeviceSessionID(Id_)));
|
||||
this->Connected_=true;
|
||||
return;
|
||||
}
|
||||
std::this_thread::sleep_for(2000ms);
|
||||
tries++;
|
||||
}
|
||||
Logger().information(fmt::format("{}: WS client could not connect to device, session: {}.", Id_, RTTYS_server()->DeviceSessionID(Id_)));
|
||||
delete this;
|
||||
};
|
||||
|
||||
std::thread CompleteConnection(DoLogin);
|
||||
CompleteConnection.detach();
|
||||
RTTYS_server()->Login(Id_);
|
||||
Connected_ = true ;
|
||||
} else {
|
||||
Logger().information(fmt::format("{}: WS client cannot be connected.", Id_));
|
||||
// std::cout << "Cannot connect..." << std::endl;
|
||||
RTTYS_server()->DeRegister(Id_, this);
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
|
||||
RTTYS_ClientConnection::~RTTYS_ClientConnection() {
|
||||
Logger().information(fmt::format("{}: WS client disconnecting.", Id_));
|
||||
// std::cout << "WebSocket disconnecting..." << std::endl;
|
||||
if(Connected_) {
|
||||
SR_.removeEventHandler(
|
||||
*WS_, Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ReadableNotification>(
|
||||
WS_, Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ReadableNotification>(
|
||||
*this, &RTTYS_ClientConnection::onSocketReadable));
|
||||
SR_.removeEventHandler(
|
||||
*WS_, Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ShutdownNotification>(
|
||||
WS_, Poco::NObserver<RTTYS_ClientConnection, Poco::Net::ShutdownNotification>(
|
||||
*this, &RTTYS_ClientConnection::onSocketShutdown));
|
||||
}
|
||||
WS_->close();
|
||||
if(Connected_) {
|
||||
RTTYS_server()->Logout(Id_);
|
||||
RTTYS_server()->DeRegister(Id_, this);
|
||||
}
|
||||
@@ -69,14 +47,16 @@ namespace OpenWifi {
|
||||
|
||||
}
|
||||
|
||||
void RTTYS_ClientConnection::onSocketReadable([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
|
||||
|
||||
void RTTYS_ClientConnection::onSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf) {
|
||||
u_char Buffer[8192]{0};
|
||||
int flags;
|
||||
auto n = WS_->receiveFrame(Buffer_, sizeof(Buffer_), flags);
|
||||
auto n = WS_.receiveFrame(Buffer, sizeof(Buffer), flags);
|
||||
|
||||
auto Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;
|
||||
|
||||
switch(Op) {
|
||||
case Poco::Net::WebSocket::FRAME_OP_PING: {
|
||||
WS_->sendFrame("", 0,(int)Poco::Net::WebSocket::FRAME_OP_PONG | (int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
WS_.sendFrame("", 0,(int)Poco::Net::WebSocket::FRAME_OP_PONG | (int)Poco::Net::WebSocket::FRAME_FLAG_FIN);
|
||||
}
|
||||
break;
|
||||
case Poco::Net::WebSocket::FRAME_OP_PONG: {
|
||||
@@ -85,34 +65,34 @@ namespace OpenWifi {
|
||||
case Poco::Net::WebSocket::FRAME_OP_TEXT: {
|
||||
if (n == 0)
|
||||
return delete this;
|
||||
std::string s((char*)Buffer_, n);
|
||||
// std::cout << "TEXT:" << s << std::endl;
|
||||
try {
|
||||
auto Doc = nlohmann::json::parse(s);
|
||||
if (Doc.contains("type")) {
|
||||
auto Type = Doc["type"];
|
||||
if (Type == "winsize") {
|
||||
auto cols = Doc["cols"];
|
||||
auto rows = Doc["rows"];
|
||||
if(!RTTYS_server()->WindowSize(Id_,cols, rows)) {
|
||||
return delete this;
|
||||
}
|
||||
std::string s{(char*)Buffer};
|
||||
auto Doc = nlohmann::json::parse(s);
|
||||
if(Doc.contains("type")) {
|
||||
auto Type = Doc["type"];
|
||||
if(Type == "winsize") {
|
||||
auto cols = Doc["cols"];
|
||||
auto rows = Doc["rows"];;
|
||||
auto Device = RTTYS_server()->GetDevice(Id_);
|
||||
if(Device==nullptr) {
|
||||
return;
|
||||
}
|
||||
Device->WindowSize(cols,rows);
|
||||
}
|
||||
} catch (...) {
|
||||
// just ignore parse errors
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Poco::Net::WebSocket::FRAME_OP_BINARY: {
|
||||
if (n == 0)
|
||||
return delete this;
|
||||
if(!RTTYS_server()->SendKeyStrokes(Id_,Buffer_,n)) {
|
||||
return delete this;
|
||||
auto Device = RTTYS_server()->GetDevice(Id_);
|
||||
if(Device==nullptr) {
|
||||
return;
|
||||
}
|
||||
Device->KeyStrokes(Buffer,n);
|
||||
}
|
||||
break;
|
||||
case Poco::Net::WebSocket::FRAME_OP_CLOSE: {
|
||||
WS_.shutdown();
|
||||
return delete this;
|
||||
}
|
||||
break;
|
||||
@@ -124,19 +104,17 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
void RTTYS_ClientConnection::SendData( const u_char *Buf, size_t len ) {
|
||||
WS_->sendFrame(Buf, len, Poco::Net::WebSocket::FRAME_FLAG_FIN | Poco::Net::WebSocket::FRAME_OP_BINARY);
|
||||
void RTTYS_ClientConnection::SendData( const u_char *Buf, int len ) {
|
||||
WS_.sendFrame(Buf, len, Poco::Net::WebSocket::FRAME_FLAG_FIN | Poco::Net::WebSocket::FRAME_OP_BINARY);
|
||||
}
|
||||
|
||||
void RTTYS_ClientConnection::SendData( const std::string &s , bool login) {
|
||||
if(login) {
|
||||
RTTYS_server()->LoginDone(Id_);
|
||||
}
|
||||
WS_->sendFrame( s.c_str(), s.length());
|
||||
WS_.sendFrame( s.c_str(), s.length());
|
||||
}
|
||||
|
||||
void RTTYS_ClientConnection::onSocketShutdown([[maybe_unused]] const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
|
||||
RTTYS_server()->Close(Id_);
|
||||
void RTTYS_ClientConnection::onSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf) {
|
||||
delete this;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,31 +9,26 @@
|
||||
#include "Poco/Net/SocketReactor.h"
|
||||
#include "Poco/NObserver.h"
|
||||
#include "Poco/Net/SocketNotification.h"
|
||||
#include "Poco/FIFOBuffer.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
class RTTYS_ClientConnection {
|
||||
public:
|
||||
RTTYS_ClientConnection(std::unique_ptr<Poco::Net::WebSocket> WS, std::string &Id,
|
||||
RTTYS_ClientConnection(Poco::Net::WebSocket &WS, std::string &Id,
|
||||
Poco::Net::SocketReactor &Reactor);
|
||||
~RTTYS_ClientConnection();
|
||||
void onSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification> &pNf);
|
||||
void onSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification> &pNf);
|
||||
|
||||
void SendData( const u_char *Buf, size_t len );
|
||||
void SendData( const u_char *Buf, int len );
|
||||
void SendData( const std::string & S, bool login=false);
|
||||
|
||||
void Close();
|
||||
|
||||
private:
|
||||
std::unique_ptr<Poco::Net::WebSocket> WS_;
|
||||
std::string Id_;
|
||||
std::string Sid_;
|
||||
Poco::Net::WebSocket WS_;
|
||||
std::string Id_;
|
||||
std::string Sid_;
|
||||
Poco::Net::SocketReactor &SR_;
|
||||
std::atomic_bool Connected_=false;
|
||||
Poco::Logger & Logger_;
|
||||
u_char Buffer_[16000]{0};
|
||||
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
std::atomic_bool Connected_=false;
|
||||
};
|
||||
}
|
||||
@@ -17,19 +17,13 @@ namespace OpenWifi {
|
||||
Poco::Net::HTTPServerResponse &response) {
|
||||
Poco::URI uri(request.getURI());
|
||||
const auto P = uri.getPath();
|
||||
// std::cout << "WS: " << P << std::endl;
|
||||
auto T = Poco::StringTokenizer(P, "/");
|
||||
if (T.count() != 3)
|
||||
return;
|
||||
if (T[1] != "connect")
|
||||
return;
|
||||
try {
|
||||
Poco::Thread::current()->setName(fmt::format("WebRTTYRequest_WSHandler_{}", T[2]));
|
||||
auto ws_ptr = std::make_unique<Poco::Net::WebSocket>(request, response);
|
||||
new RTTYS_ClientConnection(std::move(ws_ptr), T[2], R_);
|
||||
} catch (...) {
|
||||
RTTYS_server()->Logger().warning("Exception during WS creation");
|
||||
}
|
||||
Poco::Net::WebSocket ws(request, response);
|
||||
new RTTYS_ClientConnection(ws, T[2], R_);
|
||||
};
|
||||
|
||||
static bool IsFileGZipped(const std::string &FileName) {
|
||||
@@ -48,10 +42,8 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
static void AddCORS(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse & Response, Poco::Logger & Logger_, uint64_t id) {
|
||||
Poco::Net::HTTPServerResponse & Response) {
|
||||
|
||||
Logger_.information(fmt::format("{}: Adding CORS", id));
|
||||
Response.setChunkedTransferEncoding(true);
|
||||
auto Origin = Request.find("Origin");
|
||||
if (Origin != Request.end()) {
|
||||
Response.set("Access-Control-Allow-Origin", Origin->second);
|
||||
@@ -71,29 +63,33 @@ namespace OpenWifi {
|
||||
Response.set("Connection", "Keep-Alive");
|
||||
Response.set("Keep-Alive", "timeout=120");
|
||||
Response.set("Accept-Ranges","bytes");
|
||||
}
|
||||
Response.setChunkedTransferEncoding(true);
|
||||
|
||||
static inline std::atomic_uint64_t rtty_ws_id = 1;
|
||||
/*
|
||||
std::cout << "==REQUEST===================================================" << std::endl;
|
||||
for(const auto &i:Request) {
|
||||
std::cout << " " << i.first << " : " << i.second << std::endl;
|
||||
}
|
||||
std::cout << "==RESPONSE===================================================" << std::endl;
|
||||
for(const auto &i:Response) {
|
||||
std::cout << " " << i.first << " : " << i.second << std::endl;
|
||||
}
|
||||
std::cout << "==END===================================================" << std::endl;
|
||||
*/
|
||||
}
|
||||
|
||||
void PageRequestHandler::handleRequest(Poco::Net::HTTPServerRequest &request,
|
||||
Poco::Net::HTTPServerResponse &response) {
|
||||
|
||||
Poco::Logger & Logger_ = RTTYS_server()->Logger();
|
||||
uint64_t id = rtty_ws_id++;
|
||||
|
||||
Logger_.information(fmt::format("{}: Starting request.",id));
|
||||
Poco::URI uri(request.getURI());
|
||||
auto Path = uri.getPath();
|
||||
|
||||
if(request.getMethod() == Poco::Net::HTTPRequest::HTTP_OPTIONS) {
|
||||
AddCORS(request,response, Logger_, id);
|
||||
response.send();
|
||||
Logger_.information(fmt::format("{}: Finishing OPTIONS request.",id));
|
||||
std::cout << "options..." << std::endl;
|
||||
AddCORS(request,response);
|
||||
return;
|
||||
} else if(request.getMethod() == Poco::Net::HTTPRequest::HTTP_HEAD){
|
||||
AddCORS(request,response, Logger_, id);
|
||||
response.send();
|
||||
Logger_.information(fmt::format("{}: Finishing HEAD request.",id));
|
||||
std::cout << "head..." << std::endl;
|
||||
AddCORS(request,response);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -104,51 +100,37 @@ namespace OpenWifi {
|
||||
if (ParsedPath.count() > 1) {
|
||||
if (ParsedPath[1] == "connect") {
|
||||
response.redirect(Poco::replace(Path,"/connect/","/rtty/"));
|
||||
RTTYS_server()->Logger().information(fmt::format("redirect: {}",Path));
|
||||
response.send();
|
||||
RTTYS_server()->Logger().information(Poco::format("... rtty connect redirect: %s",Path));
|
||||
return;
|
||||
} else if (ParsedPath[1] == "authorized") {
|
||||
AddCORS(request,response, Logger_, id);
|
||||
AddCORS(request,response);
|
||||
nlohmann::json doc;
|
||||
doc["authorized"] = true;
|
||||
response.setContentType("application/json");
|
||||
std::ostream &answer = response.send();
|
||||
answer << to_string(doc);
|
||||
Logger_.information(fmt::format("{}: Finishing authorization request.",id));
|
||||
return;
|
||||
} else if (ParsedPath[1] == "fontsize") {
|
||||
AddCORS(request,response, Logger_, id);
|
||||
AddCORS(request,response);
|
||||
nlohmann::json doc;
|
||||
doc["size"] = 16;
|
||||
AddCORS(request,response);
|
||||
response.setContentType("application/json");
|
||||
std::ostream &answer = response.send();
|
||||
answer << to_string(doc);
|
||||
Logger_.information(fmt::format("{}: Finishing fonstize request.",id));
|
||||
return;
|
||||
}
|
||||
}
|
||||
Path = RTTYS_server()->UIAssets() + Path;
|
||||
}
|
||||
|
||||
// std::cout << id << ": Serving path '" << Path << "'" << std::endl;
|
||||
|
||||
// simple test to block .. or ~ in path names.
|
||||
if(Path.find("../")!=std::string::npos) {
|
||||
Logger_.information(fmt::format("{}: Finishing request.",id));
|
||||
return;
|
||||
}
|
||||
|
||||
if(Path.find("~/")!=std::string::npos) {
|
||||
Logger_.information(fmt::format("{}: Finishing request.",id));
|
||||
return;
|
||||
}
|
||||
|
||||
Poco::File F(Path);
|
||||
AddCORS(request,response, Logger_, id);
|
||||
AddCORS(request,response);
|
||||
if(!F.exists()) {
|
||||
// std::cout << id << ": Path " << Path << " does not exist" << std::endl;
|
||||
response.setChunkedTransferEncoding(true);
|
||||
Path = RTTYS_server()->UIAssets() + "/index.html";
|
||||
response.sendFile(Path,"text/html");
|
||||
Logger_.information(fmt::format("{}: Finishing request.",id));
|
||||
return;
|
||||
}
|
||||
Poco::Path P(Path);
|
||||
@@ -159,15 +141,12 @@ namespace OpenWifi {
|
||||
Type = "text/html; charset=utf-8";
|
||||
else if (Ext == "js") {
|
||||
Type = "text/javascript; charset=utf-8";
|
||||
if(IsFileGZipped(Path)) {
|
||||
if(IsFileGZipped(Path))
|
||||
response.set("Content-Encoding", "gzip");
|
||||
}
|
||||
} else if (Ext == "css") {
|
||||
Type = "text/css; charset=utf-8";
|
||||
if(IsFileGZipped(Path)) {
|
||||
Logger_.information(fmt::format("{}: Downloading UI Assets.",id));
|
||||
if(IsFileGZipped(Path))
|
||||
response.set("Content-Encoding", "gzip");
|
||||
}
|
||||
} else if (Ext == "ico")
|
||||
Type = "image/x-icon";
|
||||
else if (Ext == "woff")
|
||||
@@ -179,7 +158,6 @@ namespace OpenWifi {
|
||||
|
||||
response.setContentLength(F.getSize());
|
||||
response.sendFile(Path, Type);
|
||||
Logger_.information(fmt::format("{}: Finishing request.",id));
|
||||
}
|
||||
|
||||
RTTY_Client_RequestHandlerFactory::RTTY_Client_RequestHandlerFactory(Poco::Net::SocketReactor &R)
|
||||
@@ -187,13 +165,12 @@ namespace OpenWifi {
|
||||
|
||||
Poco::Net::HTTPRequestHandler *
|
||||
RTTY_Client_RequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest &request) {
|
||||
Poco::Thread::current()->setName("WebRTTYRequest");
|
||||
try {
|
||||
if (request.find("Upgrade") != request.end() &&
|
||||
Poco::icompare(request["Upgrade"], "websocket") == 0) {
|
||||
Poco::Thread::current()->setName("WebRTTYRequest_WSHandler");
|
||||
return new RTTY_Client_WebSocketRequestHandler(Reactor_);
|
||||
} else {
|
||||
Poco::Thread::current()->setName("WebRTTYRequest_PageHandler");
|
||||
return new PageRequestHandler;
|
||||
}
|
||||
} catch (...) {
|
||||
|
||||
@@ -4,171 +4,110 @@
|
||||
|
||||
#include "RTTYS_device.h"
|
||||
#include "rttys/RTTYS_server.h"
|
||||
#include "rttys/RTTYS_ClientConnection.h"
|
||||
#include "Poco/Net/SecureStreamSocketImpl.h"
|
||||
#include "Poco/Net/StreamSocket.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
RTTY_Device_ConnectionHandler::RTTY_Device_ConnectionHandler(const Poco::Net::StreamSocket & socket) :
|
||||
Poco::Net::TCPServerConnection(socket),
|
||||
Logger_(RTTYS_server()->Logger()) {
|
||||
conn_id_ = global_device_connection_id++;
|
||||
RTTY_Device_ConnectionHandler::RTTY_Device_ConnectionHandler(Poco::Net::StreamSocket& socket,
|
||||
Poco::Net::SocketReactor & reactor):
|
||||
socket_(socket),
|
||||
reactor_(reactor)
|
||||
{
|
||||
reactor_.addEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::ReadableNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketReadable));
|
||||
reactor_.addEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::ShutdownNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketShutdown));
|
||||
// reactor_.addEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::WritableNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketWritable));
|
||||
}
|
||||
|
||||
RTTY_Device_ConnectionHandler::~RTTY_Device_ConnectionHandler() {
|
||||
running_ = false;
|
||||
while(!loop_done_) {
|
||||
Poco::Thread::sleep(10);
|
||||
RTTY_Device_ConnectionHandler::~RTTY_Device_ConnectionHandler()
|
||||
{
|
||||
reactor_.removeEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::ReadableNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketReadable));
|
||||
// reactor_.removeEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::WritableNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketWritable));
|
||||
reactor_.removeEventHandler(socket_, Poco::NObserver<RTTY_Device_ConnectionHandler, Poco::Net::ShutdownNotification>(*this, &RTTY_Device_ConnectionHandler::onSocketShutdown));
|
||||
socket_.close();
|
||||
if(!id_.empty()) {
|
||||
RTTYS_server()->DeRegister(id_, this);
|
||||
RTTYS_server()->Close(id_);
|
||||
} else {
|
||||
std::cout << "Device going down that never registered" << std::endl;
|
||||
}
|
||||
RTTYS_server()->DeRegister(id_, this);
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::AddCommand(u_char C) {
|
||||
std::lock_guard G(M_);
|
||||
// std::cout << conn_id_ << ": Adding command " << (int)C << std::endl;
|
||||
commands_.push_back(C);
|
||||
}
|
||||
|
||||
bool RTTY_Device_ConnectionHandler::ProcessCommands() {
|
||||
std::lock_guard G(M_);
|
||||
if(!commands_.empty()) {
|
||||
// std::cout << conn_id_ << ": Commands: " << commands_.size() << std::endl;
|
||||
for(const auto &i:commands_) {
|
||||
// std::cout << "Command: " << (int)i << std::endl;
|
||||
if(i==msgTypeLogin) {
|
||||
// std::cout << "Doing login..." << std::endl;
|
||||
Login();
|
||||
}
|
||||
else if(i==msgTypeLogout) {
|
||||
// std::cout << "Doing logout..." << std::endl;
|
||||
Logout();
|
||||
}
|
||||
}
|
||||
commands_.clear();
|
||||
std::string RTTY_Device_ConnectionHandler::SafeCopy( const u_char * buf, int MaxSize, int & NewPos) {
|
||||
std::string S;
|
||||
while(NewPos<MaxSize && buf[NewPos]!=0) {
|
||||
S += buf[NewPos++];
|
||||
}
|
||||
return true;
|
||||
|
||||
if(buf[NewPos]==0)
|
||||
NewPos++;
|
||||
|
||||
return S;
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::PrintBuf(const u_char * buf, int size) {
|
||||
|
||||
void RTTY_Device_ConnectionHandler::run() {
|
||||
running_ = true ;
|
||||
|
||||
Poco::Timespan pollTimeOut(0,100);
|
||||
Poco::Timespan pollError(0,1);
|
||||
Poco::Timespan recvTimeOut(120,0);
|
||||
|
||||
socket().setKeepAlive(true);
|
||||
socket().setNoDelay(true);
|
||||
socket().setReceiveBufferSize(64000);
|
||||
socket().setLinger(false,0);
|
||||
socket().setSendBufferSize(64000);
|
||||
socket().setReceiveTimeout(recvTimeOut);
|
||||
|
||||
while(running_) {
|
||||
|
||||
if(!ProcessCommands()) {
|
||||
running_=false;
|
||||
break;
|
||||
}
|
||||
|
||||
std::lock_guard G(M_);
|
||||
if (socket().poll(pollError, Poco::Net::Socket::SELECT_ERROR) == true) {
|
||||
running_=false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (socket().poll(pollTimeOut, Poco::Net::Socket::SELECT_READ) == false) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int received = socket().receiveBytes(inBuf_);
|
||||
if(received<0) {
|
||||
running_ = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if(received==0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!inBuf_.isEmpty() && running_) {
|
||||
// std::cout << conn_id_ << ": processing buffer" << std::endl;
|
||||
std::size_t msg_len;
|
||||
if (waiting_for_bytes_ == 0) {
|
||||
u_char header[3]{0};
|
||||
inBuf_.read((char *)&header[0], 3);
|
||||
last_command_ = header[0];
|
||||
msg_len = header[1] * 256 + header[2];
|
||||
} else {
|
||||
msg_len = received;
|
||||
}
|
||||
|
||||
switch (last_command_) {
|
||||
case msgTypeRegister: {
|
||||
do_msgTypeRegister(msg_len);
|
||||
} break;
|
||||
case msgTypeLogin: {
|
||||
do_msgTypeLogin(msg_len);
|
||||
} break;
|
||||
case msgTypeLogout: {
|
||||
do_msgTypeLogout(msg_len);
|
||||
} break;
|
||||
case msgTypeTermData: {
|
||||
do_msgTypeTermData(msg_len);
|
||||
} break;
|
||||
case msgTypeWinsize: {
|
||||
do_msgTypeWinsize(msg_len);
|
||||
} break;
|
||||
case msgTypeCmd: {
|
||||
do_msgTypeCmd(msg_len);
|
||||
} break;
|
||||
case msgTypeHeartbeat: {
|
||||
do_msgTypeHeartbeat(msg_len);
|
||||
} break;
|
||||
case msgTypeFile: {
|
||||
do_msgTypeFile(msg_len);
|
||||
} break;
|
||||
case msgTypeHttp: {
|
||||
do_msgTypeHttp(msg_len);
|
||||
} break;
|
||||
case msgTypeAck: {
|
||||
do_msgTypeAck(msg_len);
|
||||
} break;
|
||||
case msgTypeMax: {
|
||||
do_msgTypeMax(msg_len);
|
||||
} break;
|
||||
default:
|
||||
Logger().warning(fmt::format("{}: ID:{} Unknown command {}", conn_id_, id_, (int)last_command_));
|
||||
running_ = false;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
std::cout << "======================================" << std::endl;
|
||||
while(size) {
|
||||
std::cout << std::hex << (int) *buf++ << " ";
|
||||
size--;
|
||||
}
|
||||
Logger().information(fmt::format("{}: ID:{} Exiting", conn_id_, id_));
|
||||
loop_done_=true;
|
||||
RTTYS_server()->DeRegister(id_, this);
|
||||
std::cout << conn_id_ << ": loop exiting" << std::endl;
|
||||
std::cout << std::endl;
|
||||
std::cout << "======================================" << std::endl;
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::Stop() {
|
||||
running_ = true;
|
||||
int RTTY_Device_ConnectionHandler::SendMessage(RTTY_MSG_TYPE Type, const u_char * Buf, int BufLen) {
|
||||
u_char outBuf[ 256 ]{0};
|
||||
auto msg_len = BufLen + 1 ;
|
||||
auto total_len = msg_len + 3 ;
|
||||
outBuf[0] = Type;
|
||||
outBuf[1] = (msg_len >> 8);
|
||||
outBuf[2] = (msg_len & 0x00ff);
|
||||
outBuf[3] = sid_;
|
||||
std::memcpy(&outBuf[4], Buf, BufLen);
|
||||
// PrintBuf(outBuf,total_len);
|
||||
return socket_.sendBytes(outBuf,total_len) == total_len;
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::SendToClient(const u_char *Buf, int Len) {
|
||||
RTTYS_server()->SendToClient(id_, Buf, Len);
|
||||
int RTTY_Device_ConnectionHandler::SendMessage(RTTY_MSG_TYPE Type, std::string &S ) {
|
||||
u_char outBuf[ 256 ]{0};
|
||||
auto msg_len = S.size()+1 ;
|
||||
auto total_len= msg_len+3;
|
||||
outBuf[0] = Type;
|
||||
outBuf[1] = (msg_len >> 8);
|
||||
outBuf[2] = (msg_len & 0x00ff);
|
||||
outBuf[3] = sid_;
|
||||
std::strcpy((char*)&outBuf[4],S.c_str());
|
||||
// PrintBuf(outBuf,total_len);
|
||||
return socket_.sendBytes(outBuf,total_len) == total_len;
|
||||
}
|
||||
|
||||
int RTTY_Device_ConnectionHandler::SendMessage(RTTY_MSG_TYPE Type) {
|
||||
u_char outBuf[ 256 ]{0};
|
||||
auto msg_len = 0 ;
|
||||
auto total_len= msg_len+3+1;
|
||||
outBuf[0] = Type;
|
||||
outBuf[1] = (msg_len >> 8);
|
||||
outBuf[2] = (msg_len & 0x00ff);
|
||||
outBuf[3] = sid_;
|
||||
return socket_.sendBytes(outBuf,total_len) == total_len;
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::SendToClient(const u_char *Buf, int len) {
|
||||
auto Client = RTTYS_server()->GetClient(id_);
|
||||
if(Client!= nullptr)
|
||||
Client->SendData(Buf,len);
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::SendToClient(const std::string &S) {
|
||||
RTTYS_server()->SendToClient(id_, S);
|
||||
auto Client = RTTYS_server()->GetClient(id_);
|
||||
if(Client!= nullptr)
|
||||
Client->SendData(S);
|
||||
}
|
||||
|
||||
bool RTTY_Device_ConnectionHandler::KeyStrokes(const u_char *buf, size_t len) {
|
||||
std::lock_guard G(M_);
|
||||
void RTTY_Device_ConnectionHandler::KeyStrokes(const u_char *buf, int len) {
|
||||
u_char outBuf[16]{0};
|
||||
|
||||
if(len>(sizeof(outBuf)-5))
|
||||
return false;
|
||||
return;
|
||||
|
||||
auto total_len = 3 + 1 + len-1;
|
||||
outBuf[0] = msgTypeTermData;
|
||||
@@ -176,17 +115,12 @@ namespace OpenWifi {
|
||||
outBuf[2] = len +1-1;
|
||||
outBuf[3] = sid_;
|
||||
memcpy( &outBuf[4], &buf[1], len-1);
|
||||
try {
|
||||
socket().sendBytes(outBuf, total_len);
|
||||
return true;
|
||||
} catch (...) {
|
||||
return false;
|
||||
}
|
||||
socket_.sendBytes(outBuf, total_len);
|
||||
// PrintBuf(outBuf, total_len);
|
||||
}
|
||||
|
||||
bool RTTY_Device_ConnectionHandler::WindowSize(int cols, int rows) {
|
||||
std::lock_guard G(M_);
|
||||
u_char outBuf[8]{0};
|
||||
void RTTY_Device_ConnectionHandler::WindowSize(int cols, int rows) {
|
||||
u_char outBuf[32]{0};
|
||||
outBuf[0] = msgTypeWinsize;
|
||||
outBuf[1] = 0 ;
|
||||
outBuf[2] = 4 + 1 ;
|
||||
@@ -195,163 +129,167 @@ namespace OpenWifi {
|
||||
outBuf[5] = cols & 0x00ff;
|
||||
outBuf[6] = rows >> 8;
|
||||
outBuf[7] = rows & 0x00ff;
|
||||
try {
|
||||
socket().sendBytes(outBuf, 8);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
// PrintBuf(outBuf,8);
|
||||
socket_.sendBytes(outBuf,8);
|
||||
}
|
||||
|
||||
bool RTTY_Device_ConnectionHandler::Login() {
|
||||
std::lock_guard G(M_);
|
||||
u_char outBuf[3]{0};
|
||||
u_char outBuf[8]{0};
|
||||
outBuf[0] = msgTypeLogin;
|
||||
outBuf[1] = 0;
|
||||
outBuf[2] = 0;
|
||||
try {
|
||||
socket().sendBytes(outBuf, 3);
|
||||
} catch (const Poco::IOException &E) {
|
||||
// std::cout << "1 " << E.what() << " " << E.name() << " "<< E.className() << " "<< E.message() << std::endl;
|
||||
return false;
|
||||
} catch (const Poco::Exception &E) {
|
||||
// std::cout << "2 " << E.what() << " " << E.name() << std::endl;
|
||||
return false;
|
||||
}
|
||||
Logger().debug(fmt::format("{}: Device {} login", conn_id_, id_));
|
||||
// PrintBuf(outBuf,3);
|
||||
socket_.sendBytes(outBuf,3 );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTTY_Device_ConnectionHandler::Logout() {
|
||||
std::lock_guard G(M_);
|
||||
u_char outBuf[4]{0};
|
||||
u_char outBuf[64];
|
||||
outBuf[0] = msgTypeLogout;
|
||||
outBuf[1] = 0;
|
||||
outBuf[2] = 1;
|
||||
outBuf[3] = sid_;
|
||||
Logger().debug(fmt::format("{}: ID:{} Logout", conn_id_, id_));
|
||||
try {
|
||||
socket().sendBytes(outBuf, 4);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
RTTYS_server()->Logger().debug(Poco::format("Device %s logging out", id_));
|
||||
// PrintBuf(outBuf,4);
|
||||
socket_.sendBytes(outBuf,4 );
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string RTTY_Device_ConnectionHandler::ReadString() {
|
||||
std::string Res;
|
||||
void RTTY_Device_ConnectionHandler::onSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification>& pNf)
|
||||
{
|
||||
try
|
||||
{
|
||||
u_char inBuf[16000]{0};
|
||||
int len = socket_.receiveBytes(&inBuf[0],sizeof(inBuf));
|
||||
// std::cout << "DEVICE MSG RECEIVED: " << std::dec << len << " bytes" << std::endl;
|
||||
if (len > 0) {
|
||||
// std::cout << "DEVICE MSG RECEIVED: " << std::dec << len << " bytes" << std::endl;
|
||||
// PrintBuf(inBuf,len);
|
||||
RTTY_MSG_TYPE msg;
|
||||
if(inBuf[0]>=(u_char)msgTypeMax) {
|
||||
RTTYS_server()->Logger().debug(Poco::format("Bad message for Session: %s", id_));
|
||||
return delete this;
|
||||
}
|
||||
|
||||
while(inBuf_.used()) {
|
||||
char C;
|
||||
inBuf_.read(&C,1);
|
||||
if(C==0) {
|
||||
break;
|
||||
}
|
||||
Res += C;
|
||||
}
|
||||
msg = (RTTY_MSG_TYPE) inBuf[0];
|
||||
int MsgLen = (int) inBuf[1] * 256 + (int) inBuf[2];
|
||||
|
||||
return Res;
|
||||
}
|
||||
if(MsgLen > sizeof(inBuf))
|
||||
return;
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeRegister([[maybe_unused]] std::size_t msg_len) {
|
||||
socket().receiveBytes(inBuf_);
|
||||
id_ = ReadString();
|
||||
desc_ = ReadString();
|
||||
token_ = ReadString();
|
||||
serial_ = RTTYS_server()->SerialNumber(id_);
|
||||
switch(msg) {
|
||||
case msgTypeRegister: {
|
||||
id_ = std::string((char*)&inBuf[3]);
|
||||
desc_ = std::string((char*)&inBuf[3 + id_.size() + 1]);
|
||||
token_ = std::string((char*)&inBuf[3 + id_.size() + 1 + desc_.size() + 1]);
|
||||
|
||||
Poco::Thread::current()->setName(fmt::format("RTTY-device-thread-{}:{}:{}", conn_id_, id_, serial_));
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Description:{} Device registration", conn_id_, id_, serial_, desc_));
|
||||
if (RTTYS_server()->Register(id_, token_, this)) {
|
||||
u_char OutBuf[8];
|
||||
OutBuf[0] = msgTypeRegister;
|
||||
OutBuf[1] = 0;
|
||||
OutBuf[2] = 4;
|
||||
OutBuf[3] = 0;
|
||||
OutBuf[4] = 'O';
|
||||
OutBuf[5] = 'K';
|
||||
OutBuf[6] = 0;
|
||||
if(socket().sendBytes(OutBuf, 7) !=7) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Description:{} Could not complete registration", conn_id_, id_, serial_, desc_));
|
||||
running_ = false;
|
||||
}
|
||||
} else {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Description:{} Could not complete registration", conn_id_, id_, serial_, desc_));
|
||||
running_ = false;
|
||||
}
|
||||
}
|
||||
if(RTTYS_server()->ValidEndPoint(id_,token_)) {
|
||||
if(!RTTYS_server()->AmIRegistered(id_,token_,this)) {
|
||||
u_char OutBuf[12];
|
||||
OutBuf[0] = msgTypeRegister;
|
||||
OutBuf[1] = 0;
|
||||
OutBuf[2] = 4;
|
||||
OutBuf[3] = 0;
|
||||
OutBuf[4] = 'O';
|
||||
OutBuf[5] = 'K';
|
||||
OutBuf[6] = 0;
|
||||
socket_.sendBytes(OutBuf, 7);
|
||||
RTTYS_server()->Register(id_, this);
|
||||
serial_ = RTTYS_server()->SerialNumber(id_);
|
||||
RTTYS_server()->Logger().debug(Poco::format(
|
||||
"Registration for SerialNumber: %s, Description: %s",
|
||||
serial_, desc_));
|
||||
} else {
|
||||
RTTYS_server()->Logger().debug(Poco::format(
|
||||
"Registration for SerialNumber: %s, already done",
|
||||
serial_));
|
||||
}
|
||||
} else {
|
||||
RTTYS_server()->Logger().debug(Poco::format(
|
||||
"Registration failed - invalid (id,token) pair. for Session: %s, Description: %s",
|
||||
id_, desc_));
|
||||
return delete this;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeLogin([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for login", conn_id_, id_, serial_));
|
||||
nlohmann::json doc;
|
||||
char Error;
|
||||
inBuf_.read(&Error, 1);
|
||||
inBuf_.read(&sid_, 1);
|
||||
doc["type"] = "login";
|
||||
doc["err"] = Error;
|
||||
const auto login_msg = to_string(doc);
|
||||
SendToClient(login_msg);
|
||||
}
|
||||
case msgTypeLogin: {
|
||||
RTTYS_server()->Logger().debug(Poco::format("Device created session for SerialNumber: %s, session: %s", serial_, id_));
|
||||
nlohmann::json doc;
|
||||
auto error = inBuf[3];
|
||||
sid_ = inBuf[4];
|
||||
doc["type"] = "login";
|
||||
doc["err"] = error;
|
||||
const auto login_msg = to_string(doc);
|
||||
SendToClient(login_msg);
|
||||
}
|
||||
break;
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeLogout([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for logout", conn_id_, id_, serial_));
|
||||
}
|
||||
case msgTypeLogout: {
|
||||
std::cout << "msgTypeLogout" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeTermData(std::size_t msg_len) {
|
||||
if(waiting_for_bytes_!=0) {
|
||||
// std::cout << conn_id_ << ": S2:" << inBuf_.used() << std::endl;
|
||||
auto to_read = std::min(inBuf_.used(),waiting_for_bytes_);
|
||||
inBuf_.read(&scratch_[0], to_read);
|
||||
SendToClient((u_char *)&scratch_[0], (int) to_read);
|
||||
if(to_read<waiting_for_bytes_)
|
||||
waiting_for_bytes_ -= to_read;
|
||||
else
|
||||
waiting_for_bytes_ = 0 ;
|
||||
} else {
|
||||
if(inBuf_.used()<msg_len) {
|
||||
// std::cout << conn_id_ << ": S1:" << msg_len << std::endl;
|
||||
auto read_count = inBuf_.read(&scratch_[0], inBuf_.used());
|
||||
SendToClient((u_char *)&scratch_[0], read_count);
|
||||
waiting_for_bytes_ = msg_len - read_count;
|
||||
case msgTypeTermData: {
|
||||
SendToClient(&inBuf[3],MsgLen);
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeWinsize: {
|
||||
std::cout << "msgTypeWinsize" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeCmd: {
|
||||
std::cout << "msgTypeCmd" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeHeartbeat: {
|
||||
// std::cout << "msgTypeHeartbeat: " << MsgLen << " bytes" << std::endl;
|
||||
// PrintBuf(&inBuf[0], len);
|
||||
u_char MsgBuf[32]{0};
|
||||
MsgBuf[0] = msgTypeHeartbeat;
|
||||
socket_.sendBytes(MsgBuf,3);
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeFile: {
|
||||
std::cout << "msgTypeFile" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeHttp: {
|
||||
std::cout << "msgTypeHttp" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeAck: {
|
||||
std::cout << "msgTypeAck" << std::endl;
|
||||
}
|
||||
break;
|
||||
|
||||
case msgTypeMax: {
|
||||
std::cout << "msgTypeMax" << std::endl;
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// std::cout << conn_id_ << ": S0:" << msg_len << std::endl;
|
||||
inBuf_.read(&scratch_[0], msg_len);
|
||||
SendToClient((u_char *)&scratch_[0], (int)msg_len);
|
||||
waiting_for_bytes_=0;
|
||||
RTTYS_server()->Logger().debug(Poco::format("DeRegistration: %s shutting down session %s.", serial_, id_));
|
||||
return delete this;
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception & E)
|
||||
{
|
||||
RTTYS_server()->Logger().debug(Poco::format("DeRegistration: %s exception, session %s.", serial_, id_));
|
||||
RTTYS_server()->Logger().log(E);
|
||||
return delete this;
|
||||
}
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeWinsize([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeWinsize", conn_id_, id_, serial_));
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeCmd([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeCmd", conn_id_, id_, serial_));
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeHeartbeat([[maybe_unused]] std::size_t msg_len) {
|
||||
// std::cout << conn_id_ << ": Device msgTypeHeartbeat: " << std::endl;
|
||||
u_char MsgBuf[3]{0};
|
||||
MsgBuf[0] = msgTypeHeartbeat;
|
||||
socket().sendBytes(MsgBuf, 3);
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeFile([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeFile", conn_id_, id_, serial_));
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeHttp([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeHttp", conn_id_, id_, serial_));
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeAck([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeAck", conn_id_, id_, serial_));
|
||||
}
|
||||
|
||||
void RTTY_Device_ConnectionHandler::do_msgTypeMax([[maybe_unused]] std::size_t msg_len) {
|
||||
Logger().debug(fmt::format("{}: ID:{} Serial:{} Asking for msgTypeMax", conn_id_, id_, serial_));
|
||||
void RTTY_Device_ConnectionHandler::onSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf)
|
||||
{
|
||||
std::cout << "Device " << id_ << " closing socket." << std::endl;
|
||||
delete this;
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <array>
|
||||
|
||||
#include "framework/MicroService.h"
|
||||
#include "Poco/FIFOBuffer.h"
|
||||
#include "Poco/Net/SocketReactor.h"
|
||||
#include "Poco/Net/SocketNotifier.h"
|
||||
#include "Poco/Net/SocketNotification.h"
|
||||
#include "Poco/Net/HTTPServerResponse.h"
|
||||
#include "Poco/NObserver.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
inline static const std::size_t RTTY_DEVICE_BUFSIZE=64000;
|
||||
|
||||
inline static std::atomic_uint64_t global_device_connection_id = 1;
|
||||
|
||||
class RTTY_Device_ConnectionHandler : public Poco::Net::TCPServerConnection {
|
||||
class RTTY_Device_ConnectionHandler {
|
||||
public:
|
||||
|
||||
enum RTTY_MSG_TYPE {
|
||||
msgTypeRegister = 0,
|
||||
msgTypeLogin,
|
||||
@@ -29,54 +31,33 @@ class RTTY_Device_ConnectionHandler : public Poco::Net::TCPServerConnection {
|
||||
msgTypeAck,
|
||||
msgTypeMax };
|
||||
|
||||
explicit RTTY_Device_ConnectionHandler(const Poco::Net::StreamSocket & socket) ;
|
||||
RTTY_Device_ConnectionHandler(Poco::Net::StreamSocket& socket, Poco::Net::SocketReactor & reactor);
|
||||
~RTTY_Device_ConnectionHandler();
|
||||
|
||||
void run() final;
|
||||
void onSocketReadable(const Poco::AutoPtr<Poco::Net::ReadableNotification>& pNf);
|
||||
void onSocketShutdown(const Poco::AutoPtr<Poco::Net::ShutdownNotification>& pNf);
|
||||
|
||||
std::string SafeCopy( const u_char * buf, int MaxSize, int & NewPos);
|
||||
void PrintBuf(const u_char * buf, int size);
|
||||
int SendMessage( RTTY_MSG_TYPE Type, const u_char * Buf, int len);
|
||||
int SendMessage( RTTY_MSG_TYPE Type, std::string &S );
|
||||
int SendMessage( RTTY_MSG_TYPE Type);
|
||||
|
||||
bool Login();
|
||||
bool Logout();
|
||||
void Stop();
|
||||
|
||||
void SendToClient(const u_char *buf, int len);
|
||||
void SendToClient(const std::string &S);
|
||||
bool WindowSize(int cols, int rows);
|
||||
bool KeyStrokes(const u_char *buf, size_t len);
|
||||
std::string ReadString();
|
||||
inline auto SessionID() const { return conn_id_; }
|
||||
void AddCommand(u_char C);
|
||||
|
||||
void WindowSize(int cols, int rows);
|
||||
void KeyStrokes(const u_char *buf, int len);
|
||||
private:
|
||||
std::atomic_bool running_=false;
|
||||
std::atomic_bool loop_done_=false;
|
||||
std::recursive_mutex M_;
|
||||
Poco::Logger &Logger_;
|
||||
Poco::Net::StreamSocket socket_;
|
||||
Poco::Net::SocketReactor& reactor_;
|
||||
std::string id_;
|
||||
std::string token_;
|
||||
std::string desc_;
|
||||
std::string serial_;
|
||||
char sid_=0;
|
||||
Poco::FIFOBuffer inBuf_{64000};
|
||||
std::array<char,32000> scratch_{0};
|
||||
std::size_t waiting_for_bytes_{0};
|
||||
u_char last_command_=0;
|
||||
uint64_t conn_id_=0;
|
||||
std::vector<u_char> commands_;
|
||||
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
|
||||
void do_msgTypeRegister(std::size_t msg_len);
|
||||
void do_msgTypeLogin(std::size_t msg_len);
|
||||
void do_msgTypeLogout(std::size_t msg_len);
|
||||
void do_msgTypeTermData(std::size_t msg_len);
|
||||
void do_msgTypeWinsize(std::size_t msg_len);
|
||||
void do_msgTypeCmd(std::size_t msg_len);
|
||||
void do_msgTypeHeartbeat(std::size_t msg_len);
|
||||
void do_msgTypeFile(std::size_t msg_len);
|
||||
void do_msgTypeHttp(std::size_t msg_len);
|
||||
void do_msgTypeAck(std::size_t msg_len);
|
||||
void do_msgTypeMax(std::size_t msg_len);
|
||||
|
||||
bool ProcessCommands();
|
||||
int sid_=0;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -2,11 +2,8 @@
|
||||
// Created by stephane bourque on 2021-11-23.
|
||||
//
|
||||
|
||||
#include "rttys/RTTYS_server.h"
|
||||
#include "rttys/RTTYS_WebServer.h"
|
||||
#include "rttys/RTTYS_device.h"
|
||||
#include "rttys/RTTYS_ClientConnection.h"
|
||||
|
||||
#include "RTTYS_server.h"
|
||||
#include "RTTYS_WebServer.h"
|
||||
namespace OpenWifi {
|
||||
|
||||
int RTTYS_server::Start() {
|
||||
@@ -23,41 +20,41 @@ namespace OpenWifi {
|
||||
auto RootCa = MicroService::instance().ConfigPath("openwifi.restapi.host.0.rootca");
|
||||
Poco::Crypto::X509Certificate Root(RootCa);
|
||||
|
||||
auto DeviceSecureContext = new Poco::Net::Context(Poco::Net::Context::SERVER_USE,
|
||||
auto DSContext = new Poco::Net::Context(Poco::Net::Context::SERVER_USE,
|
||||
KeyFileName, CertFileName, "",
|
||||
Poco::Net::Context::VERIFY_RELAXED);
|
||||
|
||||
DeviceSecureContext->addCertificateAuthority(Root);
|
||||
DeviceSecureContext->disableStatelessSessionResumption();
|
||||
DeviceSecureContext->enableSessionCache();
|
||||
DeviceSecureContext->setSessionCacheSize(0);
|
||||
DeviceSecureContext->setSessionTimeout(10);
|
||||
DeviceSecureContext->enableExtendedCertificateVerification(true);
|
||||
SSL_CTX *SSLCtxDevice = DeviceSecureContext->sslContext();
|
||||
SSL_CTX_dane_enable(SSLCtxDevice);
|
||||
DSContext->addCertificateAuthority(Root);
|
||||
DSContext->disableStatelessSessionResumption();
|
||||
DSContext->enableSessionCache();
|
||||
DSContext->setSessionCacheSize(0);
|
||||
DSContext->setSessionTimeout(10);
|
||||
DSContext->enableExtendedCertificateVerification(true);
|
||||
SSL_CTX *SSLCtxD = DSContext->sslContext();
|
||||
SSL_CTX_dane_enable(SSLCtxD);
|
||||
|
||||
Poco::Net::SecureServerSocket DeviceSocket(DSport, 64, DeviceSecureContext);
|
||||
Poco::Net::TCPServerParams* pParams = new Poco::Net::TCPServerParams();
|
||||
pParams->setMaxThreads(50);
|
||||
pParams->setMaxQueued(100);
|
||||
// pParams->setThreadIdleTime(100);
|
||||
Poco::Net::SecureServerSocket DeviceSocket(DSport, 64, DSContext);
|
||||
DeviceSocket.setNoDelay(true);
|
||||
|
||||
DeviceAcceptor_ = std::make_unique<Poco::Net::TCPServer>(new Poco::Net::TCPServerConnectionFactoryImpl<RTTY_Device_ConnectionHandler>(), DeviceSocket, pParams);
|
||||
DeviceAcceptor_->start();
|
||||
DeviceAcceptor_ =
|
||||
std::make_unique<Poco::Net::SocketAcceptor<RTTY_Device_ConnectionHandler>>(
|
||||
DeviceSocket, DeviceReactor_);
|
||||
|
||||
auto ClientSecureContext =
|
||||
DeviceReactorThread_.start(DeviceReactor_);
|
||||
|
||||
auto CSContext =
|
||||
new Poco::Net::Context(Poco::Net::Context::SERVER_USE, KeyFileName, CertFileName,
|
||||
"", Poco::Net::Context::VERIFY_RELAXED);
|
||||
ClientSecureContext->addCertificateAuthority(Root);
|
||||
ClientSecureContext->disableStatelessSessionResumption();
|
||||
ClientSecureContext->enableSessionCache();
|
||||
ClientSecureContext->setSessionCacheSize(0);
|
||||
ClientSecureContext->setSessionTimeout(10);
|
||||
ClientSecureContext->enableExtendedCertificateVerification(true);
|
||||
SSL_CTX *SSLCtxClient = ClientSecureContext->sslContext();
|
||||
SSL_CTX_dane_enable(SSLCtxClient);
|
||||
CSContext->addCertificateAuthority(Root);
|
||||
CSContext->disableStatelessSessionResumption();
|
||||
CSContext->enableSessionCache();
|
||||
CSContext->setSessionCacheSize(0);
|
||||
CSContext->setSessionTimeout(10);
|
||||
CSContext->enableExtendedCertificateVerification(true);
|
||||
SSL_CTX *SSLCtxC = DSContext->sslContext();
|
||||
SSL_CTX_dane_enable(SSLCtxC);
|
||||
|
||||
Poco::Net::SecureServerSocket ClientSocket(CSport, 64, ClientSecureContext);
|
||||
Poco::Net::SecureServerSocket ClientSocket(CSport, 64, CSContext);
|
||||
ClientSocket.setNoDelay(true);
|
||||
|
||||
auto HttpParams = new Poco::Net::HTTPServerParams;
|
||||
@@ -67,8 +64,8 @@ namespace OpenWifi {
|
||||
|
||||
WebServer_ = std::make_unique<Poco::Net::HTTPServer>(
|
||||
new RTTY_Client_RequestHandlerFactory(ClientReactor_), ClientSocket, HttpParams);
|
||||
ClientReactorThread_.setName("RTTYWebServerClientThread");
|
||||
ClientReactorThread_.start(ClientReactor_);
|
||||
ClientReactorThread_.setName("RTTYWebServerClientThread");
|
||||
WebServer_->start();
|
||||
}
|
||||
|
||||
@@ -78,199 +75,27 @@ namespace OpenWifi {
|
||||
void RTTYS_server::Stop() {
|
||||
if(Internal_) {
|
||||
WebServer_->stopAll();
|
||||
DeviceAcceptor_->stop();
|
||||
DeviceReactor_.stop();
|
||||
DeviceReactorThread_.join();
|
||||
ClientReactor_.stop();
|
||||
ClientReactorThread_.join();
|
||||
}
|
||||
}
|
||||
|
||||
void RTTYS_server::Register(const std::string &Id, RTTYS_ClientConnection *Client) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end()) {
|
||||
It->second.Client = Client;
|
||||
It->second.ClientConnected = OpenWifi::Now();
|
||||
}
|
||||
}
|
||||
|
||||
bool RTTYS_server::SendToClient(const std::string &Id, const u_char *Buf, std::size_t Len) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Client!= nullptr) {
|
||||
It->second.Client->SendData(Buf,Len);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTTYS_server::SendToClient(const std::string &Id, const std::string &s) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Client!= nullptr) {
|
||||
It->second.Client->SendData(s);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void RTTYS_server::DeRegister(const std::string &Id, RTTYS_ClientConnection *Client) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end() && It->second.Client==Client) {
|
||||
if(It->second.Device!= nullptr) {
|
||||
It->second.Device->Stop();
|
||||
}
|
||||
It->second.ClientConnected=0;
|
||||
It->second.Client= nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool RTTYS_server::Register(const std::string &Id, const std::string &Token, RTTY_Device_ConnectionHandler *Device) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end()) {
|
||||
It->second.Device = Device;
|
||||
It->second.Token = Token;
|
||||
It->second.DeviceConnected = OpenWifi::Now();
|
||||
Logger().information(fmt::format("Creating session: {}, device:'{}'",Id,It->second.SerialNumber));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void RTTYS_server::DeRegister(const std::string &Id, RTTY_Device_ConnectionHandler *Device) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Device==Device) {
|
||||
It->second.Device = nullptr;
|
||||
It->second.DeviceConnected = 0 ;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool RTTYS_server::SendKeyStrokes(const std::string &Id, const u_char *buffer, std::size_t s) {
|
||||
std::lock_guard G(M_);
|
||||
auto It=EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(It->second.Device!= nullptr)
|
||||
return It->second.Device->KeyStrokes(buffer,s);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTTYS_server::WindowSize(const std::string &Id, int cols, int rows) {
|
||||
std::lock_guard G(M_);
|
||||
auto It=EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(It->second.Device!= nullptr)
|
||||
return It->second.Device->WindowSize(cols,rows);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool RTTYS_server::CreateEndPoint(const std::string &Id, const std::string & Token, const std::string & UserName, const std::string & SerialNumber ) {
|
||||
std::lock_guard G(M_);
|
||||
|
||||
EndPoint E;
|
||||
E.Done = false;
|
||||
E.Token = Token;
|
||||
E.TimeStamp = std::time(nullptr);
|
||||
E.SerialNumber = SerialNumber;
|
||||
E.UserName = UserName;
|
||||
EndPoints_[Id] = E;
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string RTTYS_server::SerialNumber(const std::string & Id) {
|
||||
std::lock_guard G(M_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return "";
|
||||
return It->second.SerialNumber;
|
||||
}
|
||||
|
||||
void RTTYS_server::LoginDone(const std::string & Id) {
|
||||
std::lock_guard G(M_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return;
|
||||
Logger().information(fmt::format("User: {}, Serial: {} logged in.",It->second.UserName, It->second.SerialNumber ));
|
||||
}
|
||||
|
||||
bool RTTYS_server::ValidEndPoint(const std::string &Id, const std::string &Token) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return false;
|
||||
}
|
||||
uint64_t Now = std::time(nullptr);
|
||||
return ((It->second.Token == Token) && ((Now-It->second.TimeStamp)<30));
|
||||
}
|
||||
|
||||
bool RTTYS_server::CanConnect( const std::string &Id, RTTYS_ClientConnection *Conn) {
|
||||
std::lock_guard G(M_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Client==Conn) {
|
||||
It->second.ClientConnected = std::time(nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool RTTYS_server::IsDeviceRegistered( const std::string &Id, const std::string &Token, [[maybe_unused]] RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(M_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It == EndPoints_.end() || It->second.Token != Token )
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t RTTYS_server::DeviceSessionID(const std::string & Id) {
|
||||
auto it = EndPoints_.find(Id);
|
||||
if(it==EndPoints_.end()) {
|
||||
std::cout << "No ID found" << std::endl;
|
||||
return 0;
|
||||
} else {
|
||||
if(it->second.Device== nullptr) {
|
||||
std::cout << "No device for ID found" << std::endl;
|
||||
return 0;
|
||||
} else {
|
||||
return it->second.Device->SessionID();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool RTTYS_server::Login(const std::string & Id) {
|
||||
std::lock_guard G(M_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It == EndPoints_.end()) {
|
||||
std::cout << "cannot find login " << Id << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
if(It->second.Device!= nullptr) {
|
||||
// std::cout << "login " << Id << " session " << It->second.Device->SessionID() << std::endl;
|
||||
// It->second.Device->AddCommand(RTTY_Device_ConnectionHandler::msgTypeLogin);
|
||||
// std::cout << "login done" << Id << std::endl;
|
||||
return It->second.Device->Login();
|
||||
}
|
||||
|
||||
std::cout << "no device so cannot login " << Id << std::endl;
|
||||
return false;
|
||||
if(It->second.Device!= nullptr)
|
||||
It->second.Device->Login();
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RTTYS_server::Logout(const std::string & Id) {
|
||||
std::lock_guard G(M_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It == EndPoints_.end()) {
|
||||
@@ -282,7 +107,7 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
bool RTTYS_server::Close(const std::string & Id) {
|
||||
std::lock_guard G(M_);
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It == EndPoints_.end()) {
|
||||
@@ -290,7 +115,10 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
if(It->second.Device!= nullptr)
|
||||
It->second.Device->Stop();
|
||||
delete It->second.Client;
|
||||
It->second.Client = nullptr;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,20 +2,18 @@
|
||||
// Created by stephane bourque on 2021-11-23.
|
||||
//
|
||||
|
||||
#pragma once
|
||||
#ifndef UCENTRALGW_RTTYS_SERVER_H
|
||||
#define UCENTRALGW_RTTYS_SERVER_H
|
||||
|
||||
#include "framework/MicroService.h"
|
||||
#include "Poco/Net/SocketReactor.h"
|
||||
#include "Poco/Net/SocketAcceptor.h"
|
||||
|
||||
// #include "rttys/RTTYS_ClientConnection.h"
|
||||
|
||||
#include "RTTYS_device.h"
|
||||
#include "rttys/RTTYS_ClientConnection.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
class RTTY_Device_ConnectionHandler;
|
||||
class RTTYS_ClientConnection;
|
||||
|
||||
class RTTYS_server : public SubSystemServer
|
||||
{
|
||||
public:
|
||||
@@ -28,25 +26,154 @@ namespace OpenWifi {
|
||||
void Stop() final;
|
||||
|
||||
inline auto UIAssets() { return RTTY_UIAssets_; }
|
||||
// inline auto UI() { return UI_; }
|
||||
|
||||
inline void Register(const std::string &Id, RTTYS_ClientConnection *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
EndPoints_[Id] = EndPoint{ .Client = Conn };
|
||||
} else {
|
||||
It->second.Client = Conn;
|
||||
}
|
||||
}
|
||||
|
||||
inline void DeRegister(const std::string &Id, RTTYS_ClientConnection *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return;
|
||||
if(It->second.Client!=Conn)
|
||||
return;
|
||||
It->second.Client = nullptr;
|
||||
It->second.Done = true;
|
||||
It->second.ClientConnected = 0 ;
|
||||
}
|
||||
|
||||
inline RTTYS_ClientConnection * GetClient(const std::string &Id) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return It->second.Client;
|
||||
}
|
||||
|
||||
inline void Register(const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
EndPoints_[Id] = EndPoint{.Device = Conn };
|
||||
Logger().information(Poco::format("Registering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
} else {
|
||||
It->second.Device = Conn;
|
||||
}
|
||||
}
|
||||
|
||||
inline void DeRegister(const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return;
|
||||
if(It->second.Device!=Conn)
|
||||
return;
|
||||
Logger().information(Poco::format("DeRegistering session: %s, device:'%s'",Id,It->second.SerialNumber));
|
||||
It->second.Device = nullptr;
|
||||
It->second.Done = true;
|
||||
It->second.DeviceConnected = 0 ;
|
||||
}
|
||||
|
||||
inline RTTY_Device_ConnectionHandler * GetDevice(const std::string &id) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return nullptr;
|
||||
}
|
||||
return It->second.Device;
|
||||
}
|
||||
|
||||
inline bool CreateEndPoint(const std::string &Id, const std::string & Token, const std::string & UserName, const std::string & SerialNumber ) {
|
||||
std::lock_guard G(Mutex_);
|
||||
EndPoint E;
|
||||
E.Done = false;
|
||||
E.Token = Token;
|
||||
E.TimeStamp = std::time(nullptr);
|
||||
E.SerialNumber = SerialNumber;
|
||||
E.UserName = UserName;
|
||||
EndPoints_[Id] = E;
|
||||
return true;
|
||||
}
|
||||
|
||||
inline std::string SerialNumber(const std::string & Id) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return "";
|
||||
return It->second.SerialNumber;
|
||||
}
|
||||
|
||||
inline void LoginDone(const std::string & Id) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end())
|
||||
return;
|
||||
Logger().information(Poco::format("User: %s, Serial: %s logged in.",It->second.UserName, It->second.SerialNumber ));
|
||||
}
|
||||
|
||||
inline bool ValidEndPoint(const std::string &Id, const std::string &Token) {
|
||||
std::lock_guard G(Mutex_);
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It==EndPoints_.end()) {
|
||||
return false;
|
||||
}
|
||||
uint64_t Now = std::time(nullptr);
|
||||
return ((It->second.Token == Token) && ((Now-It->second.TimeStamp)<30));
|
||||
}
|
||||
|
||||
inline bool CanConnect( const std::string &Id, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Device==Conn && It->second.DeviceConnected==0) {
|
||||
It->second.DeviceConnected = std::time(nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool CanConnect( const std::string &Id, RTTYS_ClientConnection *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It!=EndPoints_.end() && It->second.Client==Conn && It->second.ClientConnected==0) {
|
||||
It->second.ClientConnected = std::time(nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool AmIRegistered( const std::string &Id, const std::string &Token, RTTY_Device_ConnectionHandler *Conn) {
|
||||
std::lock_guard G(Mutex_);
|
||||
|
||||
auto It = EndPoints_.find(Id);
|
||||
if(It == EndPoints_.end())
|
||||
return false;
|
||||
|
||||
if(It->second.Token != Token)
|
||||
return false;
|
||||
|
||||
if(It->second.Device==Conn)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void Register(const std::string &Id, RTTYS_ClientConnection *Client);
|
||||
void DeRegister(const std::string &Id, RTTYS_ClientConnection *Client);
|
||||
bool Register(const std::string &Id, const std::string &Token, RTTY_Device_ConnectionHandler *Device);
|
||||
void DeRegister(const std::string &Id, RTTY_Device_ConnectionHandler *Device);
|
||||
bool CreateEndPoint(const std::string &Id, const std::string & Token, const std::string & UserName, const std::string & SerialNumber );
|
||||
std::string SerialNumber(const std::string & Id);
|
||||
void LoginDone(const std::string & Id);
|
||||
bool ValidEndPoint(const std::string &Id, const std::string &Token);
|
||||
bool CanConnect( const std::string &Id, RTTYS_ClientConnection *Conn);
|
||||
bool IsDeviceRegistered( const std::string &Id, const std::string &Token, [[maybe_unused]] RTTY_Device_ConnectionHandler *Conn);
|
||||
bool Login(const std::string & Id_);
|
||||
bool Logout(const std::string & Id_);
|
||||
bool Close(const std::string & Id_);
|
||||
uint64_t DeviceSessionID(const std::string & Id);
|
||||
bool SendKeyStrokes(const std::string &Id, const u_char *buffer, std::size_t s);
|
||||
bool WindowSize(const std::string &Id, int cols, int rows);
|
||||
bool SendToClient(const std::string &id, const u_char *Buf, std::size_t Len);
|
||||
bool SendToClient(const std::string &id, const std::string &s);
|
||||
|
||||
struct EndPoint {
|
||||
std::string Token;
|
||||
@@ -65,15 +192,17 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
private:
|
||||
std::recursive_mutex M_;
|
||||
Poco::Net::SocketReactor DeviceReactor_;
|
||||
Poco::Net::SocketReactor ClientReactor_;
|
||||
Poco::Thread DeviceReactorThread_;
|
||||
Poco::Thread ClientReactorThread_;
|
||||
std::string RTTY_UIAssets_;
|
||||
std::atomic_bool Internal_ = false;
|
||||
|
||||
std::map<std::string, EndPoint> EndPoints_; // id, endpoint
|
||||
|
||||
std::unique_ptr<Poco::Net::SocketAcceptor<RTTY_Device_ConnectionHandler>> DeviceAcceptor_;
|
||||
std::unique_ptr<Poco::Net::HTTPServer> WebServer_;
|
||||
std::unique_ptr<Poco::Net::TCPServer> DeviceAcceptor_;
|
||||
|
||||
explicit RTTYS_server() noexcept:
|
||||
SubSystemServer("RTTY_Server", "RTTY-SVR", "rtty.server")
|
||||
@@ -84,3 +213,5 @@ namespace OpenWifi {
|
||||
inline RTTYS_server * RTTYS_server() { return RTTYS_server::instance(); }
|
||||
|
||||
} // namespace OpenWifi
|
||||
|
||||
#endif // UCENTRALGW_RTTYS_SERVER_H
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -99,7 +99,7 @@ namespace OpenWifi {
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -111,7 +111,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -132,7 +132,7 @@ namespace OpenWifi {
|
||||
BlackListDevices.erase(SerialNumber);
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -155,7 +155,7 @@ namespace OpenWifi {
|
||||
|
||||
return Select.rowsExtracted()==1;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -202,7 +202,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -63,7 +63,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning( fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -110,7 +110,7 @@ bool Storage::CreateDeviceCapabilities(std::string &SerialNumber, std::string &C
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -348,7 +348,6 @@ typedef Poco::Tuple<
|
||||
Select << ConvertParams(St),
|
||||
Poco::Data::Keywords::into(R),
|
||||
Poco::Data::Keywords::use(UUID);
|
||||
ConvertCommandRecord(R,Command);
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
@@ -396,7 +395,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -430,7 +429,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -451,13 +450,13 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::CommandCompleted(std::string &UUID, const Poco::JSON::Object & ReturnVars,
|
||||
bool Storage::CommandCompleted(std::string &UUID, const Poco::JSON::Object::Ptr & ReturnVars,
|
||||
const std::chrono::duration<double, std::milli> & execution_time,
|
||||
bool FullCommand) {
|
||||
try {
|
||||
@@ -468,8 +467,8 @@ typedef Poco::Tuple<
|
||||
uint64_t ErrorCode = 0;
|
||||
std::string ErrorText, ResultStr;
|
||||
|
||||
if (ReturnVars.has("result")) {
|
||||
auto ResultObj = ReturnVars.get("result");
|
||||
if (ReturnVars->has("result")) {
|
||||
auto ResultObj = ReturnVars->get("result");
|
||||
auto ResultFields = ResultObj.extract<Poco::JSON::Object::Ptr>();
|
||||
if (ResultFields->has("status")) {
|
||||
auto StatusObj = ResultFields->get("status");
|
||||
@@ -503,7 +502,7 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -586,10 +585,10 @@ typedef Poco::Tuple<
|
||||
|
||||
return true;
|
||||
} else {
|
||||
Logger().warning(fmt::format("File {} is too large.", FileName.path()));
|
||||
Logger().warning(Poco::format("File %s is too large.", FileName.path()));
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -651,7 +650,7 @@ typedef Poco::Tuple<
|
||||
return true;
|
||||
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -709,7 +708,7 @@ typedef Poco::Tuple<
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -66,10 +66,9 @@ namespace OpenWifi {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Select(Sess);
|
||||
|
||||
std::string St{"SELECT FROM DefaultConfigs WHERE Name=?"};
|
||||
Select << ConvertParams(St) ,
|
||||
Poco::Data::Keywords::into(TmpName) ,
|
||||
Name;
|
||||
Select << "SELECT Name FROM DefaultConfigs WHERE Name='%s'",
|
||||
Poco::Data::Keywords::into(TmpName),
|
||||
Name;
|
||||
Select.execute();
|
||||
|
||||
if (!TmpName.empty())
|
||||
@@ -78,6 +77,7 @@ namespace OpenWifi {
|
||||
Config::Config Cfg(DefConfig.Configuration);
|
||||
|
||||
if (Cfg.Valid()) {
|
||||
uint64_t Now = std::time(nullptr);
|
||||
Poco::Data::Statement Insert(Sess);
|
||||
|
||||
std::string St{"INSERT INTO DefaultConfigs ( " + DB_DefConfig_SelectFields + " ) "
|
||||
@@ -95,7 +95,7 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -140,7 +140,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ namespace OpenWifi {
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ namespace OpenWifi {
|
||||
return Select.rowsExtracted()==1;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -215,7 +215,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -241,11 +241,11 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
}
|
||||
Logger().information(fmt::format("AUTO-PROVISIONING: no default configuration for model:{}", Model));
|
||||
Logger().information(Poco::format("AUTO-PROVISIONING: no default configuration for model:%s", Model));
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ namespace OpenWifi {
|
||||
return Count;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return Count;
|
||||
}
|
||||
|
||||
@@ -24,83 +24,67 @@
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
const static std::string DB_DeviceSelectFields{
|
||||
"SerialNumber,"
|
||||
"DeviceType, "
|
||||
"MACAddress, "
|
||||
"Manufacturer, "
|
||||
"Configuration, "
|
||||
"Notes, "
|
||||
"Owner, "
|
||||
"Location, "
|
||||
"Firmware,"
|
||||
"Compatible,"
|
||||
"FWUpdatePolicy,"
|
||||
"UUID, "
|
||||
"CreationTimestamp, "
|
||||
"LastConfigurationChange, "
|
||||
"LastConfigurationDownload, "
|
||||
"LastFWUpdate, "
|
||||
"Venue, "
|
||||
"DevicePassword, "
|
||||
"subscriber, "
|
||||
"entity, "
|
||||
"modified, "
|
||||
"locale "
|
||||
};
|
||||
const static std::string DB_DeviceSelectFields{ "SerialNumber,"
|
||||
"DeviceType, "
|
||||
"MACAddress, "
|
||||
"Manufacturer, "
|
||||
"Configuration, "
|
||||
"Notes, "
|
||||
"Owner, "
|
||||
"Location, "
|
||||
"Firmware,"
|
||||
"Compatible,"
|
||||
"FWUpdatePolicy,"
|
||||
"UUID, "
|
||||
"CreationTimestamp, "
|
||||
"LastConfigurationChange, "
|
||||
"LastConfigurationDownload, "
|
||||
"LastFWUpdate, "
|
||||
"Venue, "
|
||||
"DevicePassword "};
|
||||
|
||||
const static std::string DB_DeviceUpdateFields{
|
||||
"SerialNumber=?,"
|
||||
"DeviceType=?, "
|
||||
"MACAddress=?, "
|
||||
"Manufacturer=?, "
|
||||
"Configuration=?, "
|
||||
"Notes=?, "
|
||||
"Owner=?, "
|
||||
"Location=?, "
|
||||
"Firmware=?,"
|
||||
"Compatible=?,"
|
||||
"FWUpdatePolicy=?,"
|
||||
"UUID=?, "
|
||||
"CreationTimestamp=?, "
|
||||
"LastConfigurationChange=?, "
|
||||
"LastConfigurationDownload=?, "
|
||||
"LastFWUpdate=?, "
|
||||
"Venue=?,"
|
||||
"DevicePassword=?, "
|
||||
"subscriber=?, "
|
||||
"entity=?, "
|
||||
"modified=?, "
|
||||
"locale=? "
|
||||
};
|
||||
const static std::string DB_DeviceUpdateFields{ "SerialNumber=?,"
|
||||
"DeviceType=?, "
|
||||
"MACAddress=?, "
|
||||
"Manufacturer=?, "
|
||||
"Configuration=?, "
|
||||
"Notes=?, "
|
||||
"Owner=?, "
|
||||
"Location=?, "
|
||||
"Firmware=?,"
|
||||
"Compatible=?,"
|
||||
"FWUpdatePolicy=?,"
|
||||
"UUID=?, "
|
||||
"CreationTimestamp=?, "
|
||||
"LastConfigurationChange=?, "
|
||||
"LastConfigurationDownload=?, "
|
||||
"LastFWUpdate=?, "
|
||||
"Venue=?,"
|
||||
"DevicePassword=? "};
|
||||
|
||||
const static std::string DB_DeviceInsertValues{" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "};
|
||||
const static std::string DB_DeviceInsertValues{" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) "};
|
||||
|
||||
typedef Poco::Tuple<
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
uint64_t,
|
||||
std::string
|
||||
> DeviceRecordTuple;
|
||||
typedef std::vector<DeviceRecordTuple> DeviceRecordList;
|
||||
typedef Poco::Tuple<
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
std::string,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
uint64_t,
|
||||
std::string,
|
||||
std::string
|
||||
> DeviceRecordTuple;
|
||||
typedef std::vector<DeviceRecordTuple> DeviceRecordList;
|
||||
|
||||
void ConvertDeviceRecord(const DeviceRecordTuple & R, GWObjects::Device &D) {
|
||||
D.SerialNumber = R.get<0>();
|
||||
@@ -121,10 +105,6 @@ namespace OpenWifi {
|
||||
D.LastFWUpdate = R.get<15>();
|
||||
D.Venue = R.get<16>();
|
||||
D.DevicePassword = R.get<17>();
|
||||
D.subscriber = R.get<18>();
|
||||
D.entity = R.get<19>();
|
||||
D.modified = R.get<20>();
|
||||
D.locale = R.get<21>();
|
||||
}
|
||||
|
||||
void ConvertDeviceRecord(const GWObjects::Device &D, DeviceRecordTuple & R) {
|
||||
@@ -146,10 +126,6 @@ namespace OpenWifi {
|
||||
R.set<15>(D.LastFWUpdate);
|
||||
R.set<16>(D.Venue);
|
||||
R.set<17>(D.DevicePassword);
|
||||
R.set<18>(D.subscriber);
|
||||
R.set<19>(D.entity);
|
||||
R.set<20>(D.modified);
|
||||
R.set<21>(D.locale);
|
||||
}
|
||||
|
||||
bool Storage::GetDeviceCount(uint64_t &Count) {
|
||||
@@ -164,7 +140,7 @@ namespace OpenWifi {
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch(const Poco::Exception & E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -181,7 +157,7 @@ namespace OpenWifi {
|
||||
Select.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E ) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -191,7 +167,7 @@ namespace OpenWifi {
|
||||
|
||||
Config::Config Cfg(Configuration);
|
||||
if (!Cfg.Valid()) {
|
||||
poco_warning(Logger(),fmt::format("CONFIG-UPDATE({}): Configuration was not valid", SerialNumber));
|
||||
Logger().warning(Poco::format("CONFIG-UPDATE(%s): Configuration was not valid", SerialNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -216,14 +192,14 @@ namespace OpenWifi {
|
||||
Poco::Data::Keywords::use(R),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
poco_information(Logger(),fmt::format("DEVICE-CONFIGURATION-UPDATED({}): New UUID is {}", SerialNumber, NewUUID));
|
||||
Logger().information(Poco::format("DEVICE-CONFIGURATION-UPDATED(%s): New UUID is %Lu", SerialNumber, NewUUID));
|
||||
Configuration = D.Configuration;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -246,7 +222,6 @@ namespace OpenWifi {
|
||||
Config::Config Cfg(DeviceDetails.Configuration);
|
||||
uint64_t Now = std::time(nullptr);
|
||||
|
||||
DeviceDetails.modified = OpenWifi::Now();
|
||||
DeviceDetails.CreationTimestamp = DeviceDetails.LastConfigurationDownload =
|
||||
DeviceDetails.UUID = DeviceDetails.LastConfigurationChange = Now;
|
||||
|
||||
@@ -269,33 +244,29 @@ namespace OpenWifi {
|
||||
SerialNumberCache()->AddSerialNumber(DeviceDetails.SerialNumber);
|
||||
return true;
|
||||
} else {
|
||||
poco_warning(Logger(),"Cannot create device: invalid configuration.");
|
||||
Logger().warning("Cannot create device: invalid configuration.");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
poco_warning(Logger(),fmt::format("Device {} already exists.", SerialNumber));
|
||||
Logger().warning(Poco::format("Device %s already exists.", SerialNumber));
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static std::string InsertRadiosCountyRegulation(std::string &Config, const Poco::Net::IPAddress & IPAddress) {
|
||||
std::string FoundCountry;
|
||||
static void InsertRadiosCountyRegulation(std::string &Config, const Poco::Net::IPAddress & IPAddress) {
|
||||
try {
|
||||
auto C = nlohmann::json::parse(Config);
|
||||
if(C.contains("radios") && C["radios"].is_array()) {
|
||||
auto Radios = C["radios"];
|
||||
auto Country = FindCountryFromIP()->Get(IPAddress);
|
||||
for(auto &i:Radios) {
|
||||
if(i.contains("country") && !i["country"].empty() && i["country"]!="**")
|
||||
continue;
|
||||
if(FoundCountry.empty())
|
||||
FoundCountry = FindCountryFromIP()->Get(IPAddress);
|
||||
i["country"] = FoundCountry;
|
||||
i["country"] = Country;
|
||||
}
|
||||
C["radios"] = Radios;
|
||||
Config = to_string(C);
|
||||
@@ -303,15 +274,14 @@ namespace OpenWifi {
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return FoundCountry;
|
||||
}
|
||||
|
||||
#define __DBGLOG__ std::cout << __LINE__ << std::endl;
|
||||
// #define __DBGLOG__ Logger().information(Poco::format("-->%u", (uint32_t) __LINE__));
|
||||
|
||||
bool Storage::CreateDefaultDevice(std::string &SerialNumber, std::string &Capabilities, std::string & Firmware, std::string &Compat, const Poco::Net::IPAddress & IPAddress) {
|
||||
|
||||
GWObjects::Device D;
|
||||
poco_information(Logger(),fmt::format("AUTO-CREATION({})", SerialNumber));
|
||||
Logger().information(Poco::format("AUTO-CREATION(%s)", SerialNumber));
|
||||
uint64_t Now = time(nullptr);
|
||||
Config::Capabilities Caps(Capabilities);
|
||||
GWObjects::DefaultConfiguration DefConfig;
|
||||
@@ -344,7 +314,8 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
// We need to insert the country code according to the IP in the radios section...
|
||||
D.locale = InsertRadiosCountyRegulation(D.Configuration, IPAddress);
|
||||
InsertRadiosCountyRegulation(D.Configuration, IPAddress);
|
||||
|
||||
D.SerialNumber = Poco::toLower(SerialNumber);
|
||||
Compat = D.Compatible = Caps.Compatible();
|
||||
D.DeviceType = Daemon()->IdentifyDevice(D.Compatible);
|
||||
@@ -358,6 +329,44 @@ namespace OpenWifi {
|
||||
return CreateDevice(D);
|
||||
}
|
||||
|
||||
bool Storage::SetLocation(std::string & SerialNumber, std::string & LocationUUID) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Update(Sess);
|
||||
|
||||
std::string St{"UPDATE Devices SET Location=? WHERE SerialNumber=?"};
|
||||
|
||||
Update << ConvertParams(St) ,
|
||||
Poco::Data::Keywords::use(LocationUUID),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::SetVenue(std::string & SerialNumber, std::string & VenueUUID) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Update(Sess);
|
||||
|
||||
std::string St{"UPDATE Devices SET Venue=? WHERE SerialNumber=?"};
|
||||
|
||||
Update << ConvertParams(St) ,
|
||||
Poco::Data::Keywords::use(VenueUUID),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::GetDeviceFWUpdatePolicy(std::string &SerialNumber, std::string &Policy) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
@@ -371,7 +380,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -389,7 +398,25 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::SetOwner(std::string & SerialNumber, std::string & OwnerUUID) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Update(Sess);
|
||||
std::string St{"UPDATE Devices SET Owner=? WHERE SerialNumber=?"};
|
||||
|
||||
Update << ConvertParams(St) ,
|
||||
Poco::Data::Keywords::use(OwnerUUID),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -422,7 +449,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -458,7 +485,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -483,7 +510,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -508,7 +535,28 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::GetDevicesWithoutFirmware(std::string &Compatible, std::string &Version, std::vector<std::string> &SerialNumbers) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Select(Sess);
|
||||
|
||||
std::string St{"SELECT SerialNumber FROM Devices WHERE Compatible=? AND Firmware!=?"};
|
||||
|
||||
Select << ConvertParams(St),
|
||||
Poco::Data::Keywords::into(SerialNumbers),
|
||||
Poco::Data::Keywords::use(Compatible),
|
||||
Poco::Data::Keywords::use(Version);
|
||||
Select.execute();
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -520,9 +568,9 @@ namespace OpenWifi {
|
||||
|
||||
DeviceRecordTuple R;
|
||||
|
||||
NewDeviceDetails.modified = OpenWifi::Now();
|
||||
ConvertDeviceRecord(NewDeviceDetails,R);
|
||||
// NewDeviceDetails.LastConfigurationChange = std::time(nullptr);
|
||||
|
||||
NewDeviceDetails.LastConfigurationChange = std::time(nullptr);
|
||||
std::string St2{"UPDATE Devices SET " +
|
||||
DB_DeviceUpdateFields +
|
||||
" WHERE SerialNumber=?"};
|
||||
@@ -530,11 +578,11 @@ namespace OpenWifi {
|
||||
Poco::Data::Keywords::use(R),
|
||||
Poco::Data::Keywords::use(NewDeviceDetails.SerialNumber);
|
||||
Update.execute();
|
||||
// GetDevice(NewDeviceDetails.SerialNumber,NewDeviceDetails);
|
||||
GetDevice(NewDeviceDetails.SerialNumber,NewDeviceDetails);
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -550,7 +598,7 @@ namespace OpenWifi {
|
||||
Poco::Data::Keywords::into(Records);
|
||||
Select.execute();
|
||||
|
||||
for (auto &i: Records) {
|
||||
for (auto i: Records) {
|
||||
GWObjects::Device D;
|
||||
ConvertDeviceRecord(i, D);
|
||||
Devices.push_back(D);
|
||||
@@ -558,12 +606,12 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::ExistingConfiguration(std::string &SerialNumber, [[maybe_unused]] uint64_t CurrentConfig, std::string &NewConfig, uint64_t & NewUUID) {
|
||||
bool Storage::ExistingConfiguration(std::string &SerialNumber, uint64_t CurrentConfig, std::string &NewConfig, uint64_t & NewUUID) {
|
||||
std::string SS;
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
@@ -596,7 +644,26 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::SetDeviceCompatibility(std::string &SerialNumber, std::string &Compatible) {
|
||||
try {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Update(Sess);
|
||||
|
||||
std::string st{"UPDATE Devices SET Compatible=? WHERE SerialNumber=?"};
|
||||
|
||||
Update << ConvertParams(st),
|
||||
Poco::Data::Keywords::use(Compatible),
|
||||
Poco::Data::Keywords::use(SerialNumber);
|
||||
Update.execute();
|
||||
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -620,11 +687,11 @@ namespace OpenWifi {
|
||||
NumberOfDevices++;
|
||||
More = RSet.moveNext();
|
||||
}
|
||||
Logger().information(fmt::format("Added {} serial numbers to cache.", NumberOfDevices));
|
||||
Logger().information(Poco::format("Added %lu serial numbers to cache.", NumberOfDevices));
|
||||
return true;
|
||||
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -761,7 +828,7 @@ namespace OpenWifi {
|
||||
}
|
||||
return true;
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -127,7 +127,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -162,7 +162,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -178,7 +178,7 @@ namespace OpenWifi {
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -147,12 +147,14 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Storage::GetNewestLogData(std::string &SerialNumber, uint64_t HowMany, std::vector<GWObjects::DeviceLog> &Stats, uint64_t Type) {
|
||||
typedef std::vector<DeviceLogsRecordTuple> RecordList;
|
||||
|
||||
try {
|
||||
DeviceLogsRecordList Records;
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
@@ -174,7 +176,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -189,7 +191,7 @@ namespace OpenWifi {
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ namespace OpenWifi {
|
||||
Poco::Data::Session Sess = Pool_->get();
|
||||
Poco::Data::Statement Insert(Sess);
|
||||
|
||||
uint64_t Now = time(nullptr);
|
||||
Logger().information("Device:" + Stats.SerialNumber + " Stats size:" + std::to_string(Stats.Data.size()));
|
||||
std::string St{"INSERT INTO Statistics ( " +
|
||||
DB_StatsSelectFields +
|
||||
@@ -54,7 +55,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -97,7 +98,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -124,7 +125,7 @@ namespace OpenWifi {
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -157,7 +158,7 @@ bool Storage::DeleteStatisticsData(std::string &SerialNumber, uint64_t FromDate,
|
||||
return true;
|
||||
}
|
||||
catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -172,7 +173,7 @@ bool Storage::DeleteStatisticsData(std::string &SerialNumber, uint64_t FromDate,
|
||||
Delete.execute();
|
||||
return true;
|
||||
} catch (const Poco::Exception &E) {
|
||||
Logger().warning(fmt::format("{}: Failed with: {}", std::string(__func__), E.displayText()));
|
||||
Logger().warning(Poco::format("%s: Failed with: %s", std::string(__func__), E.displayText()));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -77,11 +77,7 @@ namespace OpenWifi {
|
||||
"CreationTimestamp BIGINT, "
|
||||
"LastConfigurationChange BIGINT, "
|
||||
"LastConfigurationDownload BIGINT, "
|
||||
"LastFWUpdate BIGINT, "
|
||||
"subscriber VARCHAR(64), "
|
||||
"entity VARCHAR(64), "
|
||||
"modified BIGINT,"
|
||||
"locale varchar(32) "
|
||||
"LastFWUpdate BIGINT "
|
||||
",INDEX DeviceOwner (Owner ASC),"
|
||||
"INDEX LocationIndex (Location ASC))", Poco::Data::Keywords::now;
|
||||
} else if(dbType_==sqlite || dbType_==pgsql) {
|
||||
@@ -103,32 +99,12 @@ namespace OpenWifi {
|
||||
"CreationTimestamp BIGINT, "
|
||||
"LastConfigurationChange BIGINT, "
|
||||
"LastConfigurationDownload BIGINT, "
|
||||
"LastFWUpdate BIGINT ,"
|
||||
"subscriber VARCHAR(64) , "
|
||||
"entity VARCHAR(64) , "
|
||||
"modified BIGINT,"
|
||||
"locale varchar(32) "
|
||||
"LastFWUpdate BIGINT "
|
||||
")", Poco::Data::Keywords::now;
|
||||
Sess << "CREATE INDEX IF NOT EXISTS DeviceOwner ON Devices (Owner ASC)", Poco::Data::Keywords::now;
|
||||
Sess << "CREATE INDEX IF NOT EXISTS DeviceLocation ON Devices (Location ASC)", Poco::Data::Keywords::now;
|
||||
}
|
||||
|
||||
// we must upgrade old DBs
|
||||
std::vector<std::string> Script{
|
||||
"alter table devices add column subscriber varchar(64)",
|
||||
"alter table devices add column entity varchar(64)",
|
||||
"alter table devices add column modified bigint",
|
||||
"alter table devices add column locale varchar(32)"
|
||||
};
|
||||
|
||||
for(const auto &i:Script) {
|
||||
try {
|
||||
Sess << i, Poco::Data::Keywords::now;
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
} catch(const Poco::Exception &E) {
|
||||
Logger().log(E);
|
||||
}
|
||||
|
||||
@@ -38,9 +38,9 @@ browser_list=(firefox sensible-browser xdg-open w3m links links2 lynx youtube-dl
|
||||
browser=""
|
||||
|
||||
if [ -z ${OWSEC_USERNAME+x} ]; then
|
||||
username="script.runner@arilia.com"
|
||||
username="script.runner@arilia.com"
|
||||
else
|
||||
username=${OWSEC_USERNAME}
|
||||
username=${OWSEC_USERNAME}
|
||||
fi
|
||||
if [ -z ${OWSEC_PASSWORD+x} ]; then
|
||||
password="Snoopy99!!!"
|
||||
@@ -612,88 +612,6 @@ iptocountry() {
|
||||
jq < ${result_file}
|
||||
}
|
||||
|
||||
check_response() {
|
||||
|
||||
if [ -s "$1" ]; then
|
||||
ERROR_CODE="$(jq -r '.ErrorCode' < $1)"
|
||||
|
||||
if [[ -n "$ERROR_CODE" && "$ERROR_CODE" != 'null' ]]; then
|
||||
echo "Error: got HTTP error code $ERROR_CODE, exiting"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
else
|
||||
echo "Error: result file not found or empty"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
test_service() {
|
||||
echo
|
||||
echo "----------------------"
|
||||
echo "Get system information"
|
||||
echo "----------------------"
|
||||
systeminfo
|
||||
check_response $result_file
|
||||
|
||||
echo
|
||||
echo "-----------------"
|
||||
echo "Get device status"
|
||||
echo "-----------------"
|
||||
getdevicestatus $1
|
||||
check_response $result_file
|
||||
DEVICE_STATUS="$(jq -r '.connected' < $result_file)"
|
||||
|
||||
if [ "$DEVICE_STATUS" != true ]; then
|
||||
echo "Error: AP is in disconnected state"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "--------------------"
|
||||
echo "Create network trace"
|
||||
echo "--------------------"
|
||||
trace $1 5 up
|
||||
check_response $result_file
|
||||
TRACE_STATUS="$(jq -r '.status' < $result_file)"
|
||||
|
||||
if [ "$TRACE_STATUS" != 'completed' ]; then
|
||||
echo "Error: failed to create network trace"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TRACE_ID="$(jq -r '.UUID' < $result_file)"
|
||||
|
||||
echo
|
||||
echo "-----------------"
|
||||
echo "Get network trace"
|
||||
echo "-----------------"
|
||||
getfile $1 $TRACE_ID
|
||||
|
||||
TRACE_RESPONSE="$(jq < $TRACE_ID.pcap 2>/dev/null)"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
check_response $TRACE_ID.pcap
|
||||
else
|
||||
echo "Successfully downloaded trace to file $TRACE_ID.pcap"
|
||||
fi
|
||||
|
||||
echo
|
||||
echo "-----------------------------"
|
||||
echo "Create and start RTTY session"
|
||||
echo "-----------------------------"
|
||||
rtty $1
|
||||
check_response $result_file
|
||||
RTTY_STATUS="$(curl -s -w '%{http_code}' $url)"
|
||||
|
||||
if [[ "$RTTY_STATUS" != 200 && "$RTTY_STATUS" != 302 ]]; then
|
||||
echo "Error: failed to start RTTY session, HTTP status code $RTTY_STATUS"
|
||||
exit 1
|
||||
else
|
||||
echo "RTTY session at $url was successfully started"
|
||||
fi
|
||||
}
|
||||
|
||||
help() {
|
||||
echo
|
||||
echo "getdevice <serial> Get the device JSON document."
|
||||
@@ -762,26 +680,24 @@ help() {
|
||||
echo "setloglevel <sys> <level> Set the logging system level for individual subsystems."
|
||||
echo " sys:ufileuploader/websocket/storage/restapi/commandmanager/auth/deviceregistry/all"
|
||||
echo " level:none/fatal/critical/error/warning/notice/information/debug/trace"
|
||||
echo "getloglevels Get the log levels of all the subsystems"
|
||||
echo "getloglevels Get the log levels of all the subsystems"
|
||||
echo "getloglevelnames Get the list of log level names possible"
|
||||
echo "getsubsystemnames Get the subsystems that can be used when setting log levels."
|
||||
echo "getfile <serial> <uuid> <name> Get the file associated with trace command <uuid> for device <serial>"
|
||||
echo " The file will be saved with the name <name>"
|
||||
echo " The file will be saved with the name <name>"
|
||||
echo
|
||||
echo "rtty <serial> Get the details for an rtty session."
|
||||
echo "rtty <serial> Get the details for an rtty session."
|
||||
echo
|
||||
echo "lifetimestats <serial> Get the lifetime stats counters for a device"
|
||||
echo "laststats <serial> Get the last statistics for a device"
|
||||
echo "neweststats <serial> Get the newest statistics for a device"
|
||||
echo "lifetimestats <serial> Get the lifetime stats counters for a device"
|
||||
echo "laststats <serial> Get the last statistics for a device"
|
||||
echo "neweststats <serial> Get the newest statistics for a device"
|
||||
echo
|
||||
echo "ouilookup <serial> Lookup an OUI"
|
||||
echo "ouilookup <serial> Lookup an OUI"
|
||||
echo
|
||||
echo "dashboard Get the dashboard document"
|
||||
echo "systeminfo Get information on the system running the service."
|
||||
echo "dashboard Get the dashboard document"
|
||||
echo "systeminfo Get information on the system running the service."
|
||||
echo
|
||||
echo "wstest Testing the WebSocket interface."
|
||||
echo
|
||||
echo "test_service <serial> Run a set of CLI commands for testing purposes"
|
||||
echo "wstest Testing the WebSocket interface."
|
||||
echo
|
||||
echo
|
||||
echo "To pass additional flags to the CURL command, create an environment variable called FLAGS and git ve the values you"
|
||||
@@ -858,6 +774,5 @@ case "$1" in
|
||||
"wstest") login; wstest; logout;;
|
||||
"caplist") login; caplist; logout;;
|
||||
"iptocountry") login; iptocountry $2; logout;;
|
||||
"test_service") login; test_service $2; logout;;
|
||||
*) help ;;
|
||||
esac
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user