mirror of
https://github.com/Telecominfraproject/wlan-cloud-ucentralfms.git
synced 2025-10-29 18:02:20 +00:00
Compare commits
22 Commits
v2.9.0-RC2
...
release/v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4d5cb5caf0 | ||
|
|
bd16c21df0 | ||
|
|
4a3274b169 | ||
|
|
88f7ab6bfa | ||
|
|
153d4ee11e | ||
|
|
21cb6ae297 | ||
|
|
a22acace01 | ||
|
|
8db90d4c36 | ||
|
|
c6a9b72872 | ||
|
|
e0507ceb82 | ||
|
|
afc8b942cb | ||
|
|
5737ab7c00 | ||
|
|
1b59208fa2 | ||
|
|
f5ee31bd8b | ||
|
|
9f9faafb1c | ||
|
|
dc9d155b78 | ||
|
|
b8a7a7aff9 | ||
|
|
3195679fee | ||
|
|
d1a9556b27 | ||
|
|
c45850b749 | ||
|
|
ab859d1f77 | ||
|
|
da5720cf8d |
@@ -25,8 +25,18 @@ else()
|
|||||||
file(WRITE build ${BUILD_NUM})
|
file(WRITE build ${BUILD_NUM})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS 1)
|
find_package(Git QUIET)
|
||||||
add_definitions(-DAPP_VERSION="${CMAKE_PROJECT_VERSION}" -DBUILD_NUMBER="${BUILD_NUM}" -DAWS_CUSTOM_MEMORY_MANAGEMENT)
|
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||||
|
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
RESULT_VARIABLE GIT_RESULT
|
||||||
|
OUTPUT_VARIABLE GIT_HASH)
|
||||||
|
if(NOT GIT_RESULT EQUAL "0")
|
||||||
|
message(FATAL_ERROR "git describe --always --tags failed with ${GIT_RESULT}")
|
||||||
|
endif()
|
||||||
|
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
|
||||||
|
endif()
|
||||||
|
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
|
||||||
|
|
||||||
set(Boost_USE_STATIC_LIBS OFF)
|
set(Boost_USE_STATIC_LIBS OFF)
|
||||||
set(Boost_USE_MULTITHREADED ON)
|
set(Boost_USE_MULTITHREADED ON)
|
||||||
@@ -48,8 +58,11 @@ endif()
|
|||||||
|
|
||||||
include_directories(/usr/local/include /usr/local/opt/openssl/include src include/kafka /usr/local/opt/mysql-client/include)
|
include_directories(/usr/local/include /usr/local/opt/openssl/include src include/kafka /usr/local/opt/mysql-client/include)
|
||||||
|
|
||||||
|
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
||||||
|
|
||||||
add_executable( owfms
|
add_executable( owfms
|
||||||
build
|
build
|
||||||
|
src/ow_version.h.in
|
||||||
src/framework/CountryCodes.h
|
src/framework/CountryCodes.h
|
||||||
src/framework/KafkaTopics.h
|
src/framework/KafkaTopics.h
|
||||||
src/framework/MicroService.h
|
src/framework/MicroService.h
|
||||||
|
|||||||
18
Dockerfile
18
Dockerfile
@@ -4,14 +4,13 @@ RUN apk add --update --no-cache \
|
|||||||
openssl openssh \
|
openssl openssh \
|
||||||
ncurses-libs \
|
ncurses-libs \
|
||||||
bash util-linux coreutils curl libcurl \
|
bash util-linux coreutils curl libcurl \
|
||||||
make cmake gcc g++ libstdc++ libgcc git zlib-dev \
|
make cmake gcc g++ libstdc++ libgcc git zlib-dev nlohmann-json \
|
||||||
openssl-dev boost-dev curl-dev util-linux-dev \
|
openssl-dev boost-dev curl-dev util-linux-dev \
|
||||||
unixodbc-dev postgresql-dev mariadb-dev \
|
unixodbc-dev postgresql-dev mariadb-dev \
|
||||||
librdkafka-dev
|
librdkafka-dev
|
||||||
|
|
||||||
RUN git clone https://github.com/stephb9959/poco /poco
|
RUN git clone https://github.com/stephb9959/poco /poco
|
||||||
RUN git clone https://github.com/stephb9959/cppkafka /cppkafka
|
RUN git clone https://github.com/stephb9959/cppkafka /cppkafka
|
||||||
RUN git clone https://github.com/nlohmann/json /json
|
|
||||||
RUN git clone https://github.com/pboettch/json-schema-validator /json-schema-validator
|
RUN git clone https://github.com/pboettch/json-schema-validator /json-schema-validator
|
||||||
RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp /aws-sdk-cpp
|
RUN git clone --recurse-submodules https://github.com/aws/aws-sdk-cpp /aws-sdk-cpp
|
||||||
|
|
||||||
@@ -39,13 +38,6 @@ RUN cmake ..
|
|||||||
RUN cmake --build . --config Release -j8
|
RUN cmake --build . --config Release -j8
|
||||||
RUN cmake --build . --target install
|
RUN cmake --build . --target install
|
||||||
|
|
||||||
WORKDIR /json
|
|
||||||
RUN mkdir cmake-build
|
|
||||||
WORKDIR cmake-build
|
|
||||||
RUN cmake ..
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
WORKDIR /json-schema-validator
|
WORKDIR /json-schema-validator
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
WORKDIR cmake-build
|
WORKDIR cmake-build
|
||||||
@@ -56,11 +48,14 @@ RUN make install
|
|||||||
ADD CMakeLists.txt build /owfms/
|
ADD CMakeLists.txt build /owfms/
|
||||||
ADD cmake /owfms/cmake
|
ADD cmake /owfms/cmake
|
||||||
ADD src /owfms/src
|
ADD src /owfms/src
|
||||||
|
ADD .git /owfms/.git
|
||||||
|
|
||||||
WORKDIR /owfms
|
WORKDIR /owfms
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
WORKDIR /owfms/cmake-build
|
WORKDIR /owfms/cmake-build
|
||||||
RUN cmake ..
|
RUN cmake .. \
|
||||||
|
-Dcrypto_LIBRARY=/usr/lib/libcrypto.so \
|
||||||
|
-DBUILD_SHARED_LIBS=ON
|
||||||
RUN cmake --build . --config Release -j8
|
RUN cmake --build . --config Release -j8
|
||||||
|
|
||||||
FROM alpine
|
FROM alpine
|
||||||
@@ -75,7 +70,7 @@ RUN addgroup -S "$OWFMS_USER" && \
|
|||||||
RUN mkdir /openwifi
|
RUN mkdir /openwifi
|
||||||
RUN mkdir -p "$OWFMS_ROOT" "$OWFMS_CONFIG" && \
|
RUN mkdir -p "$OWFMS_ROOT" "$OWFMS_CONFIG" && \
|
||||||
chown "$OWFMS_USER": "$OWFMS_ROOT" "$OWFMS_CONFIG"
|
chown "$OWFMS_USER": "$OWFMS_ROOT" "$OWFMS_CONFIG"
|
||||||
RUN apk add --update --no-cache librdkafka curl-dev mariadb-connector-c libpq unixodbc su-exec gettext ca-certificates bash jq curl
|
RUN apk add --update --no-cache librdkafka curl-dev mariadb-connector-c libpq unixodbc su-exec gettext ca-certificates bash jq curl postgresql-client
|
||||||
|
|
||||||
COPY --from=builder /owfms/cmake-build/owfms /openwifi/owfms
|
COPY --from=builder /owfms/cmake-build/owfms /openwifi/owfms
|
||||||
COPY --from=builder /cppkafka/cmake-build/src/lib/* /lib/
|
COPY --from=builder /cppkafka/cmake-build/src/lib/* /lib/
|
||||||
@@ -85,6 +80,7 @@ COPY --from=builder /aws-sdk-cpp/cmake-build/aws-cpp-sdk-s3/libaws-cpp-sdk-s3.so
|
|||||||
|
|
||||||
COPY owfms.properties.tmpl /
|
COPY owfms.properties.tmpl /
|
||||||
COPY docker-entrypoint.sh /
|
COPY docker-entrypoint.sh /
|
||||||
|
COPY wait-for-postgres.sh /
|
||||||
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
||||||
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem
|
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem
|
||||||
|
|
||||||
|
|||||||
2
helm/.gitignore
vendored
2
helm/.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
*.swp
|
*.swp
|
||||||
|
Chart.lock
|
||||||
|
charts
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ name: owfms
|
|||||||
version: 0.1.0
|
version: 0.1.0
|
||||||
dependencies:
|
dependencies:
|
||||||
- name: postgresql
|
- name: postgresql
|
||||||
repository: https://charts.bitnami.com/bitnami
|
repository: https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral-helm/
|
||||||
version: 10.9.2
|
version: 10.9.2
|
||||||
condition: postgresql.enabled
|
condition: postgresql.enabled
|
||||||
- name: mysql
|
- name: mysql
|
||||||
repository: https://charts.bitnami.com/bitnami
|
repository: https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral-helm/
|
||||||
version: 8.8.3
|
version: 8.8.3
|
||||||
condition: mysql.enabled
|
condition: mysql.enabled
|
||||||
- name: mariadb
|
- name: mariadb
|
||||||
repository: https://charts.bitnami.com/bitnami
|
repository: https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral-helm/
|
||||||
version: 9.4.2
|
version: 9.4.2
|
||||||
condition: mariadb.enabled
|
condition: mariadb.enabled
|
||||||
|
|||||||
@@ -30,3 +30,13 @@ Create chart name and version as used by the chart label.
|
|||||||
{{- define "owfms.chart" -}}
|
{{- define "owfms.chart" -}}
|
||||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- define "owfms.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 }}
|
{{- range $ingress, $ingressValue := .Values.ingresses }}
|
||||||
{{- if $ingressValue.enabled }}
|
{{- if $ingressValue.enabled }}
|
||||||
---
|
---
|
||||||
apiVersion: extensions/v1beta1
|
apiVersion: {{ include "owfms.ingress.apiVersion" $root }}
|
||||||
kind: Ingress
|
kind: Ingress
|
||||||
metadata:
|
metadata:
|
||||||
name: {{ include "owfms.fullname" $root }}-{{ $ingress }}
|
name: {{ include "owfms.fullname" $root }}-{{ $ingress }}
|
||||||
@@ -36,9 +36,23 @@ spec:
|
|||||||
paths:
|
paths:
|
||||||
{{- range $ingressValue.paths }}
|
{{- range $ingressValue.paths }}
|
||||||
- path: {{ .path }}
|
- path: {{ .path }}
|
||||||
|
{{- if $root.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
|
||||||
|
pathType: {{ .pathType | default "ImplementationSpecific" }}
|
||||||
|
{{- end }}
|
||||||
backend:
|
backend:
|
||||||
|
{{- if $root.Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
|
||||||
|
service:
|
||||||
|
name: {{ include "owfms.fullname" $root }}-{{ .serviceName }}
|
||||||
|
port:
|
||||||
|
{{- if kindIs "string" .servicePort }}
|
||||||
|
name: {{ .servicePort }}
|
||||||
|
{{- else }}
|
||||||
|
number: {{ .servicePort }}
|
||||||
|
{{- end }}
|
||||||
|
{{- else }}
|
||||||
serviceName: {{ include "owfms.fullname" $root }}-{{ .serviceName }}
|
serviceName: {{ include "owfms.fullname" $root }}-{{ .serviceName }}
|
||||||
servicePort: {{ .servicePort }}
|
servicePort: {{ .servicePort }}
|
||||||
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fullnameOverride: ""
|
|||||||
images:
|
images:
|
||||||
owfms:
|
owfms:
|
||||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owfms
|
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owfms
|
||||||
tag: main
|
tag: v2.4.0
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
# regcred:
|
# regcred:
|
||||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||||
@@ -51,6 +51,7 @@ ingresses:
|
|||||||
- restapi.chart-example.local
|
- restapi.chart-example.local
|
||||||
paths:
|
paths:
|
||||||
- path: /
|
- path: /
|
||||||
|
pathType: ImplementationSpecific
|
||||||
serviceName: owfms
|
serviceName: owfms
|
||||||
servicePort: restapi
|
servicePort: restapi
|
||||||
|
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ using namespace std::chrono_literals;
|
|||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
|
#include "ow_version.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
enum UNAUTHORIZED_REASON {
|
enum UNAUTHORIZED_REASON {
|
||||||
@@ -1900,7 +1902,7 @@ namespace OpenWifi {
|
|||||||
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
|
QB_.SerialNumber = GetParameter(RESTAPI::Protocol::SERIALNUMBER, "");
|
||||||
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
|
QB_.StartDate = GetParameter(RESTAPI::Protocol::STARTDATE, 0);
|
||||||
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
|
QB_.EndDate = GetParameter(RESTAPI::Protocol::ENDDATE, 0);
|
||||||
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 1);
|
QB_.Offset = GetParameter(RESTAPI::Protocol::OFFSET, 0);
|
||||||
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
|
QB_.Limit = GetParameter(RESTAPI::Protocol::LIMIT, 100);
|
||||||
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
|
QB_.Filter = GetParameter(RESTAPI::Protocol::FILTER, "");
|
||||||
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
|
QB_.Select = GetParameter(RESTAPI::Protocol::SELECT, "");
|
||||||
@@ -1912,7 +1914,7 @@ namespace OpenWifi {
|
|||||||
QB_.AdditionalInfo = GetBoolParameter(RESTAPI::Protocol::WITHEXTENDEDINFO,false);
|
QB_.AdditionalInfo = GetBoolParameter(RESTAPI::Protocol::WITHEXTENDEDINFO,false);
|
||||||
|
|
||||||
if(QB_.Offset<1)
|
if(QB_.Offset<1)
|
||||||
QB_.Offset=1;
|
QB_.Offset=0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2393,10 +2395,10 @@ namespace OpenWifi {
|
|||||||
Poco::Logger & L, RESTAPI_GenericServer & S);
|
Poco::Logger & L, RESTAPI_GenericServer & S);
|
||||||
|
|
||||||
|
|
||||||
class RESTAPI_server : public SubSystemServer {
|
class RESTAPI_ExtServer : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
static RESTAPI_server *instance() {
|
static RESTAPI_ExtServer *instance() {
|
||||||
static RESTAPI_server *instance_ = new RESTAPI_server;
|
static RESTAPI_ExtServer *instance_ = new RESTAPI_ExtServer;
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
int Start() override;
|
int Start() override;
|
||||||
@@ -2410,7 +2412,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
inline void reinitialize(Poco::Util::Application &self) override;
|
inline void reinitialize(Poco::Util::Application &self) override;
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path) {
|
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path, uint64_t Id) {
|
||||||
RESTAPIHandler::BindingMap Bindings;
|
RESTAPIHandler::BindingMap Bindings;
|
||||||
return RESTAPI_external_server(Path, Bindings, Logger_, Server_);
|
return RESTAPI_external_server(Path, Bindings, Logger_, Server_);
|
||||||
}
|
}
|
||||||
@@ -2420,19 +2422,19 @@ namespace OpenWifi {
|
|||||||
Poco::ThreadPool Pool_;
|
Poco::ThreadPool Pool_;
|
||||||
RESTAPI_GenericServer Server_;
|
RESTAPI_GenericServer Server_;
|
||||||
|
|
||||||
RESTAPI_server() noexcept:
|
RESTAPI_ExtServer() noexcept:
|
||||||
SubSystemServer("RESTAPIServer", "RESTAPIServer", "openwifi.restapi")
|
SubSystemServer("RESTAPIServer", "RESTAPIServer", "openwifi.restapi")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline RESTAPI_server * RESTAPI_server() { return RESTAPI_server::instance(); };
|
inline RESTAPI_ExtServer * RESTAPI_ExtServer() { return RESTAPI_ExtServer::instance(); };
|
||||||
|
|
||||||
class RequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
class ExtRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
||||||
public:
|
public:
|
||||||
RequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
explicit ExtRequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
||||||
Logger_(RESTAPI_server::instance()->Logger()),
|
Logger_(RESTAPI_ExtServer::instance()->Logger()),
|
||||||
Server_(Server)
|
Server_(Server)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2440,15 +2442,16 @@ namespace OpenWifi {
|
|||||||
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
||||||
Poco::URI uri(Request.getURI());
|
Poco::URI uri(Request.getURI());
|
||||||
auto *Path = uri.getPath().c_str();
|
auto *Path = uri.getPath().c_str();
|
||||||
return RESTAPI_server()->CallServer(Path);
|
return RESTAPI_ExtServer()->CallServer(Path, TransactionId_++);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Poco::Logger &Logger_;
|
static inline std::atomic_uint64_t TransactionId_ = 1;
|
||||||
RESTAPI_GenericServer &Server_;
|
Poco::Logger &Logger_;
|
||||||
|
RESTAPI_GenericServer &Server_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int RESTAPI_server::Start() {
|
inline int RESTAPI_ExtServer::Start() {
|
||||||
Logger_.information("Starting.");
|
Logger_.information("Starting.");
|
||||||
Server_.InitLogging();
|
Server_.InitLogging();
|
||||||
|
|
||||||
@@ -2467,7 +2470,7 @@ namespace OpenWifi {
|
|||||||
Params->setMaxQueued(200);
|
Params->setMaxQueued(200);
|
||||||
Params->setKeepAlive(true);
|
Params->setKeepAlive(true);
|
||||||
|
|
||||||
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new RequestHandlerFactory(Server_), Pool_, Sock, Params);
|
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new ExtRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
||||||
NewServer->start();
|
NewServer->start();
|
||||||
RESTServers_.push_back(std::move(NewServer));
|
RESTServers_.push_back(std::move(NewServer));
|
||||||
}
|
}
|
||||||
@@ -2475,11 +2478,11 @@ namespace OpenWifi {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class RESTAPI_InternalServer : public SubSystemServer {
|
class RESTAPI_IntServer : public SubSystemServer {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static RESTAPI_InternalServer *instance() {
|
static RESTAPI_IntServer *instance() {
|
||||||
static RESTAPI_InternalServer *instance_ = new RESTAPI_InternalServer;
|
static RESTAPI_IntServer *instance_ = new RESTAPI_IntServer;
|
||||||
return instance_;
|
return instance_;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2488,12 +2491,13 @@ namespace OpenWifi {
|
|||||||
Logger_.information("Stopping ");
|
Logger_.information("Stopping ");
|
||||||
for( const auto & svr : RESTServers_ )
|
for( const auto & svr : RESTServers_ )
|
||||||
svr->stop();
|
svr->stop();
|
||||||
Pool_.stopAll();
|
Pool_.joinAll();
|
||||||
|
RESTServers_.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void reinitialize(Poco::Util::Application &self) override;
|
inline void reinitialize(Poco::Util::Application &self) override;
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path) {
|
inline Poco::Net::HTTPRequestHandler *CallServer(const char *Path, uint64_t Id) {
|
||||||
RESTAPIHandler::BindingMap Bindings;
|
RESTAPIHandler::BindingMap Bindings;
|
||||||
return RESTAPI_internal_server(Path, Bindings, Logger_, Server_);
|
return RESTAPI_internal_server(Path, Bindings, Logger_, Server_);
|
||||||
}
|
}
|
||||||
@@ -2502,30 +2506,31 @@ namespace OpenWifi {
|
|||||||
Poco::ThreadPool Pool_;
|
Poco::ThreadPool Pool_;
|
||||||
RESTAPI_GenericServer Server_;
|
RESTAPI_GenericServer Server_;
|
||||||
|
|
||||||
RESTAPI_InternalServer() noexcept: SubSystemServer("RESTAPIInternalServer", "REST-ISRV", "openwifi.internal.restapi")
|
RESTAPI_IntServer() noexcept: SubSystemServer("RESTAPIInternalServer", "REST-ISRV", "openwifi.internal.restapi")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
inline RESTAPI_InternalServer * RESTAPI_InternalServer() { return RESTAPI_InternalServer::instance(); };
|
inline RESTAPI_IntServer * RESTAPI_IntServer() { return RESTAPI_IntServer::instance(); };
|
||||||
|
|
||||||
class InternalRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
class IntRequestHandlerFactory : public Poco::Net::HTTPRequestHandlerFactory {
|
||||||
public:
|
public:
|
||||||
InternalRequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
explicit IntRequestHandlerFactory(RESTAPI_GenericServer & Server) :
|
||||||
Logger_(RESTAPI_InternalServer()->Logger()),
|
Logger_(RESTAPI_IntServer()->Logger()),
|
||||||
Server_(Server){}
|
Server_(Server){}
|
||||||
|
|
||||||
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
inline Poco::Net::HTTPRequestHandler *createRequestHandler(const Poco::Net::HTTPServerRequest &Request) override {
|
||||||
Poco::URI uri(Request.getURI());
|
Poco::URI uri(Request.getURI());
|
||||||
auto *Path = uri.getPath().c_str();
|
auto *Path = uri.getPath().c_str();
|
||||||
return RESTAPI_InternalServer()->CallServer(Path);
|
return RESTAPI_IntServer()->CallServer(Path, TransactionId_++);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
|
static inline std::atomic_uint64_t TransactionId_ = 1;
|
||||||
Poco::Logger & Logger_;
|
Poco::Logger & Logger_;
|
||||||
RESTAPI_GenericServer & Server_;
|
RESTAPI_GenericServer & Server_;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline int RESTAPI_InternalServer::Start() {
|
inline int RESTAPI_IntServer::Start() {
|
||||||
Logger_.information("Starting.");
|
Logger_.information("Starting.");
|
||||||
Server_.InitLogging();
|
Server_.InitLogging();
|
||||||
|
|
||||||
@@ -2543,7 +2548,7 @@ namespace OpenWifi {
|
|||||||
Params->setMaxQueued(200);
|
Params->setMaxQueued(200);
|
||||||
Params->setKeepAlive(true);
|
Params->setKeepAlive(true);
|
||||||
|
|
||||||
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new InternalRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
auto NewServer = std::make_unique<Poco::Net::HTTPServer>(new IntRequestHandlerFactory(Server_), Pool_, Sock, Params);
|
||||||
NewServer->start();
|
NewServer->start();
|
||||||
RESTServers_.push_back(std::move(NewServer));
|
RESTServers_.push_back(std::move(NewServer));
|
||||||
}
|
}
|
||||||
@@ -2673,7 +2678,7 @@ namespace OpenWifi {
|
|||||||
std::string MyPrivateEndPoint_;
|
std::string MyPrivateEndPoint_;
|
||||||
std::string MyPublicEndPoint_;
|
std::string MyPublicEndPoint_;
|
||||||
std::string UIURI_;
|
std::string UIURI_;
|
||||||
std::string Version_{std::string(APP_VERSION) + "("+ BUILD_NUMBER + ")"};
|
std::string Version_{ OW_VERSION::VERSION + "("+ OW_VERSION::BUILD + ")" + " - " + OW_VERSION::HASH };
|
||||||
BusEventManager BusEventManager_;
|
BusEventManager BusEventManager_;
|
||||||
std::mutex InfraMutex_;
|
std::mutex InfraMutex_;
|
||||||
std::default_random_engine RandomEngine_;
|
std::default_random_engine RandomEngine_;
|
||||||
@@ -2824,8 +2829,8 @@ namespace OpenWifi {
|
|||||||
// add the default services
|
// add the default services
|
||||||
SubSystems_.push_back(KafkaManager());
|
SubSystems_.push_back(KafkaManager());
|
||||||
SubSystems_.push_back(ALBHealthCheckServer());
|
SubSystems_.push_back(ALBHealthCheckServer());
|
||||||
SubSystems_.push_back(RESTAPI_server());
|
SubSystems_.push_back(RESTAPI_ExtServer());
|
||||||
SubSystems_.push_back(RESTAPI_InternalServer());
|
SubSystems_.push_back(RESTAPI_IntServer());
|
||||||
|
|
||||||
Poco::Net::initializeSSL();
|
Poco::Net::initializeSSL();
|
||||||
Poco::Net::HTTPStreamFactory::registerFactory();
|
Poco::Net::HTTPStreamFactory::registerFactory();
|
||||||
@@ -3395,14 +3400,14 @@ namespace OpenWifi {
|
|||||||
Consumer.unsubscribe();
|
Consumer.unsubscribe();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void RESTAPI_server::reinitialize(Poco::Util::Application &self) {
|
inline void RESTAPI_ExtServer::reinitialize(Poco::Util::Application &self) {
|
||||||
MicroService::instance().LoadConfigurationFile();
|
MicroService::instance().LoadConfigurationFile();
|
||||||
Logger_.information("Reinitializing.");
|
Logger_.information("Reinitializing.");
|
||||||
Stop();
|
Stop();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RESTAPI_InternalServer::reinitialize(Poco::Util::Application &self) {
|
void RESTAPI_IntServer::reinitialize(Poco::Util::Application &self) {
|
||||||
MicroService::instance().LoadConfigurationFile();
|
MicroService::instance().LoadConfigurationFile();
|
||||||
Logger_.information("Reinitializing.");
|
Logger_.information("Reinitializing.");
|
||||||
Stop();
|
Stop();
|
||||||
@@ -3726,7 +3731,7 @@ namespace OpenWifi {
|
|||||||
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired)) {
|
if (AuthClient()->IsAuthorized( SessionToken_, UserInfo_, Expired)) {
|
||||||
#endif
|
#endif
|
||||||
if(Server_.LogIt(Request->getMethod(),true)) {
|
if(Server_.LogIt(Request->getMethod(),true)) {
|
||||||
Logger_.debug(Poco::format("X-REQ-ALLOWED(%s): User='%s@%s' Method='%s' Path='%s",
|
Logger_.debug(Poco::format("X-REQ-ALLOWED(%s): User='%s@%s' Method='%s' Path='%s'",
|
||||||
UserInfo_.userinfo.email,
|
UserInfo_.userinfo.email,
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->clientAddress().toString(),
|
Request->clientAddress().toString(),
|
||||||
@@ -3736,7 +3741,7 @@ namespace OpenWifi {
|
|||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
if(Server_.LogBadTokens(true)) {
|
if(Server_.LogBadTokens(true)) {
|
||||||
Logger_.debug(Poco::format("X-REQ-DENIED(%s): Method='%s' Path='%s",
|
Logger_.debug(Poco::format("X-REQ-DENIED(%s): Method='%s' Path='%s'",
|
||||||
Utils::FormatIPv6(Request->clientAddress().toString()),
|
Utils::FormatIPv6(Request->clientAddress().toString()),
|
||||||
Request->getMethod(), Request->getURI()));
|
Request->getMethod(), Request->getURI()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,8 +2,7 @@
|
|||||||
// Created by stephane bourque on 2021-10-06.
|
// Created by stephane bourque on 2021-10-06.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef OPENWIFI_STORAGE_H
|
#pragma once
|
||||||
#define OPENWIFI_STORAGE_H
|
|
||||||
|
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/Data/SessionPool.h"
|
#include "Poco/Data/SessionPool.h"
|
||||||
@@ -54,13 +53,13 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
[[nodiscard]] inline std::string ComputeRange(uint64_t From, uint64_t HowMany) {
|
[[nodiscard]] inline std::string ComputeRange(uint64_t From, uint64_t HowMany) {
|
||||||
if(dbType_==sqlite) {
|
if(dbType_==sqlite) {
|
||||||
return " LIMIT " + std::to_string(From-1) + ", " + std::to_string(HowMany) + " ";
|
return " LIMIT " + std::to_string(From) + ", " + std::to_string(HowMany) + " ";
|
||||||
} else if(dbType_==pgsql) {
|
} else if(dbType_==pgsql) {
|
||||||
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
|
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
|
||||||
} else if(dbType_==mysql) {
|
} else if(dbType_==mysql) {
|
||||||
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
|
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
|
||||||
}
|
}
|
||||||
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From-1) + " ";
|
return " LIMIT " + std::to_string(HowMany) + " OFFSET " + std::to_string(From) + " ";
|
||||||
}
|
}
|
||||||
|
|
||||||
inline std::string ConvertParams(const std::string & S) const {
|
inline std::string ConvertParams(const std::string & S) const {
|
||||||
@@ -165,5 +164,3 @@ namespace OpenWifi {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //OPENWIFI_STORAGE_H
|
|
||||||
|
|||||||
13
src/ow_version.h.in
Normal file
13
src/ow_version.h.in
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-12-06.
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace OW_VERSION {
|
||||||
|
inline static const std::string VERSION{"@CMAKE_PROJECT_VERSION@"};
|
||||||
|
inline static const std::string BUILD{"@BUILD_NUM@"};
|
||||||
|
inline static const std::string HASH{"@GIT_HASH@"};
|
||||||
|
}
|
||||||
@@ -65,7 +65,7 @@ namespace OpenWifi {
|
|||||||
if(LatestFirmwareCache()->AddToCache(F.deviceType,F.revision,F.id,F.imageDate)) {
|
if(LatestFirmwareCache()->AddToCache(F.deviceType,F.revision,F.id,F.imageDate)) {
|
||||||
F.latest = true ;
|
F.latest = true ;
|
||||||
Poco::Data::Statement Update(Sess);
|
Poco::Data::Statement Update(Sess);
|
||||||
std::string st{"UPDATE " + DBNAME_FIRMWARES + " SET latest=0 WHERE deviceType=? AND Latest=1"};
|
std::string st{"UPDATE " + DBNAME_FIRMWARES + " SET latest=false WHERE deviceType=? AND Latest=true"};
|
||||||
Update << ConvertParams(st),
|
Update << ConvertParams(st),
|
||||||
Poco::Data::Keywords::use(F.deviceType);
|
Poco::Data::Keywords::use(F.deviceType);
|
||||||
Update.execute();
|
Update.execute();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace OpenWifi {
|
|||||||
"location varchar, "
|
"location varchar, "
|
||||||
"uploader varchar, "
|
"uploader varchar, "
|
||||||
"digest varchar, "
|
"digest varchar, "
|
||||||
"latest int, "
|
"latest boolean, "
|
||||||
"notes text, "
|
"notes text, "
|
||||||
"created bigint"
|
"created bigint"
|
||||||
};
|
};
|
||||||
@@ -88,7 +88,7 @@ namespace OpenWifi {
|
|||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
std::string,
|
std::string,
|
||||||
uint64_t,
|
bool,
|
||||||
std::string,
|
std::string,
|
||||||
uint64_t> FirmwaresRecord;
|
uint64_t> FirmwaresRecord;
|
||||||
typedef std::vector<FirmwaresRecord> FirmwaresRecordList;
|
typedef std::vector<FirmwaresRecord> FirmwaresRecordList;
|
||||||
|
|||||||
26
wait-for-postgres.sh
Executable file
26
wait-for-postgres.sh
Executable file
@@ -0,0 +1,26 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# wait-for-postgres.sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
host="$1"
|
||||||
|
shift
|
||||||
|
|
||||||
|
export PGUSER=$(grep 'storage.type.postgresql.username' $OWFMS_CONFIG/owfms.properties | awk -F '= ' '{print $2}')
|
||||||
|
export PGPASSWORD=$(grep 'storage.type.postgresql.password' $OWFMS_CONFIG/owfms.properties | awk -F '= ' '{print $2}')
|
||||||
|
|
||||||
|
until psql -h "$host" -c '\q'; do
|
||||||
|
>&2 echo "Postgres is unavailable - sleeping"
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
>&2 echo "Postgres is up - executing command"
|
||||||
|
|
||||||
|
if [ "$1" = '/openwifi/owfms' -a "$(id -u)" = '0' ]; then
|
||||||
|
if [ "$RUN_CHOWN" = 'true' ]; then
|
||||||
|
chown -R "$OWFMS_USER": "$OWFMS_ROOT" "$OWFMS_CONFIG"
|
||||||
|
fi
|
||||||
|
exec su-exec "$OWFMS_USER" "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec "$@"
|
||||||
Reference in New Issue
Block a user