Skip to content

Commit

Permalink
Fixing Namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
stephb9959 committed Aug 31, 2021
1 parent 8172b9c commit 9f9e1b4
Show file tree
Hide file tree
Showing 30 changed files with 310 additions and 417 deletions.
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(ucentralgw VERSION 2.1.0)
project(owgw VERSION 2.2.0)

set(CMAKE_CXX_STANDARD 17)

Expand Down Expand Up @@ -50,7 +50,7 @@ endif()

include_directories(/usr/local/include /usr/local/opt/openssl/include src include/kafka /usr/local/opt/mysql-client/include)

add_executable( ucentralgw
add_executable( owgw
build
src/Daemon.cpp src/Daemon.h
src/RESTAPI_server.cpp src/RESTAPI_server.h
Expand Down Expand Up @@ -98,21 +98,21 @@ add_executable( ucentralgw
src/OpenWifiTypes.h)

if(NOT SMALL_BUILD)
target_sources(ucentralgw PUBLIC src/KafkaManager.cpp src/KafkaManager.h)
target_sources(owgw PUBLIC src/KafkaManager.cpp src/KafkaManager.h)
endif()

INSTALL(TARGETS ucentralgw
INSTALL(TARGETS owgw
RUNTIME DESTINATION /usr/bin
)

target_link_libraries(ucentralgw PUBLIC
target_link_libraries(owgw PUBLIC
${Poco_LIBRARIES} ${Boost_LIBRARIES} ${ZLIB_LIBRARIES})
if(NOT SMALL_BUILD)
target_link_libraries(ucentralgw PUBLIC
target_link_libraries(owgw PUBLIC
${MySQL_LIBRARIES} ${ZLIB_LIBRARIES}
CppKafka::cppkafka
)
if(UNIX AND NOT APPLE)
target_link_libraries(ucentralgw PUBLIC PocoJSON)
target_link_libraries(owgw PUBLIC PocoJSON)
endif()
endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ then
exit 1
fi
if [[ ! -f ucentralgw.properties ]]
if [[ ! -f owgw.properties ]]
then
echo "Configuration file ucentralgw.properties is missing in the current directory"
exit 2
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
33
3
2 changes: 1 addition & 1 deletion docker_run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ then
exit 1
fi

if [[ ! -f ucentralgw.properties ]]
if [[ ! -f owgw.properties ]]
then
echo "Configuration file ucentral.properties is missing in the current directory"
exit 2
Expand Down
107 changes: 53 additions & 54 deletions ucentralgw.properties.priv → owgw.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# address of one of your interfaces
#
ucentral.websocket.host.0.backlog = 500
ucentral.websocket.host.0.rootca = $UCENTRALGW_ROOT/certs/root.pem
ucentral.websocket.host.0.issuer = $UCENTRALGW_ROOT/certs/issuer.pem
ucentral.websocket.host.0.cert = $UCENTRALGW_ROOT/certs/websocket-cert.pem
ucentral.websocket.host.0.key = $UCENTRALGW_ROOT/certs/websocket-key.pem
ucentral.websocket.host.0.clientcas = $UCENTRALGW_ROOT/certs/clientcas.pem
ucentral.websocket.host.0.cas = $UCENTRALGW_ROOT/certs/cas
ucentral.websocket.host.0.rootca = $OWGW_ROOT/certs/root.pem
ucentral.websocket.host.0.issuer = $OWGW_ROOT/certs/issuer.pem
ucentral.websocket.host.0.cert = $OWGW_ROOT/certs/websocket-cert.pem
ucentral.websocket.host.0.key = $OWGW_ROOT/certs/websocket-key.pem
ucentral.websocket.host.0.clientcas = $OWGW_ROOT/certs/clientcas.pem
ucentral.websocket.host.0.cas = $OWGW_ROOT/certs/cas
ucentral.websocket.host.0.address = *
ucentral.websocket.host.0.port = 15002
ucentral.websocket.host.0.security = strict
Expand All @@ -19,60 +19,60 @@ ucentral.websocket.maxreactors = 20
#
# REST API access
#
ucentral.restapi.host.0.backlog = 100
ucentral.restapi.host.0.security = relaxed
ucentral.restapi.host.0.rootca = $UCENTRALGW_ROOT/certs/restapi-ca.pem
ucentral.restapi.host.0.address = *
ucentral.restapi.host.0.port = 16002
ucentral.restapi.host.0.cert = $UCENTRALGW_ROOT/certs/restapi-cert.pem
ucentral.restapi.host.0.key = $UCENTRALGW_ROOT/certs/restapi-key.pem
ucentral.restapi.host.0.key.password = mypassword

ucentral.internal.restapi.host.0.backlog = 100
ucentral.internal.restapi.host.0.security = relaxed
ucentral.internal.restapi.host.0.rootca = $UCENTRALGW_ROOT/certs/restapi-ca.pem
ucentral.internal.restapi.host.0.address = *
ucentral.internal.restapi.host.0.port = 17002
ucentral.internal.restapi.host.0.cert = $UCENTRALGW_ROOT/certs/restapi-cert.pem
ucentral.internal.restapi.host.0.key = $UCENTRALGW_ROOT/certs/restapi-key.pem
ucentral.internal.restapi.host.0.key.password = mypassword
openwifi.restapi.host.0.backlog = 100
openwifi.restapi.host.0.security = relaxed
openwifi.restapi.host.0.rootca = $OWGW_ROOT/certs/restapi-ca.pem
openwifi.restapi.host.0.address = *
openwifi.restapi.host.0.port = 16002
openwifi.restapi.host.0.cert = $OWGW_ROOT/certs/restapi-cert.pem
openwifi.restapi.host.0.key = $OWGW_ROOT/certs/restapi-key.pem
openwifi.restapi.host.0.key.password = mypassword

openwifi.internal.restapi.host.0.backlog = 100
openwifi.internal.restapi.host.0.security = relaxed
openwifi.internal.restapi.host.0.rootca = $OWGW_ROOT/certs/restapi-ca.pem
openwifi.internal.restapi.host.0.address = *
openwifi.internal.restapi.host.0.port = 17002
openwifi.internal.restapi.host.0.cert = $OWGW_ROOT/certs/restapi-cert.pem
openwifi.internal.restapi.host.0.key = $OWGW_ROOT/certs/restapi-key.pem
openwifi.internal.restapi.host.0.key.password = mypassword

#
# Used to upload files to the service.
# You should replace the 'name' vaalue with the IP address of your gateway or an FQDN
# that your devices can reach
#
ucentral.fileuploader.host.0.backlog = 100
ucentral.fileuploader.host.0.rootca = $UCENTRALGW_ROOT/certs/restapi-ca.pem
ucentral.fileuploader.host.0.security = relaxed
ucentral.fileuploader.host.0.address = *
ucentral.fileuploader.host.0.name = ucentral.dpaas.arilia.com
ucentral.fileuploader.host.0.port = 16003
ucentral.fileuploader.host.0.cert = $UCENTRALGW_ROOT/certs/restapi-cert.pem
ucentral.fileuploader.host.0.key = $UCENTRALGW_ROOT/certs/restapi-key.pem
ucentral.fileuploader.host.0.key.password = mypassword
ucentral.fileuploader.path = $UCENTRALGW_ROOT/uploads
ucentral.fileuploader.maxsize = 10000
openwifi.fileuploader.host.0.backlog = 100
openwifi.fileuploader.host.0.rootca = $OWGW_ROOT/certs/restapi-ca.pem
openwifi.fileuploader.host.0.security = relaxed
openwifi.fileuploader.host.0.address = *
openwifi.fileuploader.host.0.name = ucentral.dpaas.arilia.com
openwifi.fileuploader.host.0.port = 16003
openwifi.fileuploader.host.0.cert = $OWGW_ROOT/certs/restapi-cert.pem
openwifi.fileuploader.host.0.key = $OWGW_ROOT/certs/restapi-key.pem
openwifi.fileuploader.host.0.key.password = mypassword
openwifi.fileuploader.path = $OWGW_ROOT/uploads
openwifi.fileuploader.maxsize = 10000

#
# Generic section that all microservices must have
#
ucentral.service.key = $UCENTRALGW_ROOT/certs/restapi-key.pem
ucentral.service.key.password = mypassword
ucentral.system.data = $UCENTRALGW_ROOT/data
ucentral.system.debug = true
ucentral.system.uri.private = https://localhost:17002
ucentral.system.uri.public = https://local.dpaas.arilia.com:16002
ucentral.system.uri.ui = https://ucentral-ui.arilia.com
ucentral.system.commandchannel = /tmp/app.ucentralgw
openwifi.service.key = $OWGW_ROOT/certs/restapi-key.pem
openwifi.service.key.password = mypassword
openwifi.system.data = $OWGW_ROOT/data
openwifi.system.debug = true
openwifi.system.uri.private = https://localhost:17002
openwifi.system.uri.public = https://ucentral.dpaas.arilia.com:16002
openwifi.system.uri.ui = https://ucentral-ui.arilia.com
openwifi.system.commandchannel = /tmp/app.ucentralgw

#
# Gateway Microservice Specific Section
#
ucentral.autoprovisioning = true
ucentral.devicetypes.0 = AP:linksys_ea8300,edgecore_eap101,linksys_e8450-ubi
ucentral.devicetypes.1 = SWITCH:edgecore_ecs4100-12ph
ucentral.devicetypes.2 = IOT:esp32
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://linuxnet.ca/ieee/oui.txt
firmware.autoupdate.policy.default = auto

Expand All @@ -98,13 +98,12 @@ alb.port = 16102
#
# Kafka
#
ucentral.kafka.group.id = gateway
ucentral.kafka.client.id = gateway1
ucentral.kafka.enable = true
# ucentral.kafka.brokerlist = a1.arilia.com:9092
ucentral.kafka.brokerlist = debfarm1-node-c.arilia.com:9092
ucentral.kafka.auto.commit = false
ucentral.kafka.queue.buffering.max.ms = 50
openwifi.kafka.group.id = gateway
openwifi.kafka.client.id = gateway1
openwifi.kafka.enable = true
openwifi.kafka.brokerlist = a1.arilia.com:9092
openwifi.kafka.auto.commit = false
openwifi.kafka.queue.buffering.max.ms = 50

#
# This section select which form of persistence you need
Expand Down Expand Up @@ -164,7 +163,7 @@ logging.channels.c1.formatter = f1

# This is where the logs will be written. This path MUST exist
logging.channels.c2.class = FileChannel
logging.channels.c2.path = $UCENTRALGW_ROOT/logs/log
logging.channels.c2.path = $OWGW_ROOT/logs/log
logging.channels.c2.formatter.class = PatternFormatter
logging.channels.c2.formatter.pattern = %Y-%m-%d %H:%M:%S %s: [%p] %t
logging.channels.c2.rotation = 20 M
Expand Down
4 changes: 2 additions & 2 deletions ucentralgw.service → owgw.service
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Wants=network-online.target

[Service]
Type=simple
Environment="UCENTRALGW_ROOT=/home/admin/dev/wlan-cloud-ucentralgw"
ExecStart=/home/admin/dev/wlan-cloud-ucentralgw/cmake-build/ucentralgw
Environment="OWGW_ROOT=/home/admin/dev/wlan-cloud-ucentralgw"
ExecStart=/home/admin/dev/wlan-cloud-ucentralgw/cmake-build/owgw
WorkingDirectory=/home/admin/dev/wlan-cloud-ucentralgw
# ExecReload=/bin/kill -s HUP $MAINPID
User=admin
Expand Down
4 changes: 2 additions & 2 deletions set_env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

export UCENTRALGW_CONFIG=`pwd`
export UCENTRALGW_ROOT=`pwd`
export OWGW_CONFIG=`pwd`
export OWGW_ROOT=`pwd`
14 changes: 9 additions & 5 deletions src/ALBHealthCheckServer.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
//
// Created by stephane bourque on 2021-06-04.
// 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.
//

#ifndef UCENTRALGW_ALBHEALTHCHECKSERVER_H
Expand All @@ -26,12 +30,12 @@ namespace OpenWifi {
/// Return a HTML document with the current date and time.
{
public:
ALBRequestHandler(Poco::Logger & L)
explicit ALBRequestHandler(Poco::Logger & L)
: Logger_(L)
{
}

void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response)
void handleRequest(Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override
{
Logger_.information(Poco::format("ALB-REQUEST(%s): New ALB request.",Request.clientAddress().toString()));
Response.setChunkedTransferEncoding(true);
Expand Down Expand Up @@ -83,7 +87,7 @@ namespace OpenWifi {
return instance_;
}

int Start() {
int Start() override {
if(Daemon()->ConfigGetBool("alb.enable",false)) {
Port_ = (int)Daemon()->ConfigGetInt("alb.port",15015);
Socket_ = std::make_unique<Poco::Net::ServerSocket>(Port_);
Expand All @@ -95,7 +99,7 @@ namespace OpenWifi {
return 0;
}

void Stop() {
void Stop() override {
if(Server_)
Server_->stop();
}
Expand Down
6 changes: 3 additions & 3 deletions src/Daemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,14 @@ namespace OpenWifi {
void Daemon::initialize(Poco::Util::Application &self) {
MicroService::initialize(*this);
Config::Config::Init();
AutoProvisioning_ = config().getBool("ucentral.autoprovisioning",false);
AutoProvisioning_ = config().getBool("openwifi.autoprovisioning",false);

// DeviceTypeIdentifications_
Types::StringVec Keys;
config().keys("ucentral.devicetypes",Keys);
config().keys("openwifi.devicetypes",Keys);
for(const auto & i:Keys)
{
std::string Line = config().getString("ucentral.devicetypes."+i);
std::string Line = config().getString("openwifi.devicetypes."+i);
auto P1 = Line.find_first_of(':');
auto Type = Line.substr(0, P1);
auto List = Line.substr(P1+1);
Expand Down
16 changes: 8 additions & 8 deletions src/Daemon.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,32 @@

namespace OpenWifi {

static const char * vDAEMON_PROPERTIES_FILENAME = "ucentralgw.properties";
static const char * vDAEMON_PROPERTIES_FILENAME = "owgw.properties";
static const char * vDAEMON_ROOT_ENV_VAR = "UCENTRALGW_ROOT";
static const char * vDAEMON_CONFIG_ENV_VAR = "UCENTRALGW_CONFIG";
static const char * vDAEMON_APP_NAME = uSERVICE_GATEWAY.c_str();
static const uint64_t vDAEMON_BUS_TIMER = 10000;

class Daemon : public MicroService {
public:
explicit Daemon(std::string PropFile,
std::string RootEnv,
std::string ConfigEnv,
std::string AppName,
explicit Daemon(const std::string & PropFile,
const std::string & RootEnv,
const std::string & ConfigEnv,
const std::string & AppName,
uint64_t BusTimer,
Types::SubSystemVec SubSystems) :
const Types::SubSystemVec & SubSystems) :
MicroService( PropFile, RootEnv, ConfigEnv, AppName, BusTimer, SubSystems) {};

bool AutoProvisioning() const { return AutoProvisioning_ ; }
[[nodiscard]] std::string IdentifyDevice(const std::string & Compatible) const;
void initialize(Poco::Util::Application &self);
void initialize(Poco::Util::Application &self) override;
static Daemon *instance();
inline DeviceDashboard & GetDashboard() { return DB_; }
private:
static Daemon *instance_;
bool AutoProvisioning_ = false;
Types::StringMapStringSet DeviceTypeIdentifications_;
DeviceDashboard DB_;
DeviceDashboard DB_{};

};

Expand Down
4 changes: 2 additions & 2 deletions src/FileUploader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace OpenWifi {

Logger_.information(l);

Poco::File UploadsDir(Daemon()->ConfigPath("ucentral.fileuploader.path","/tmp"));
Poco::File UploadsDir(Daemon()->ConfigPath("openwifi.fileuploader.path","/tmp"));
Path_ = UploadsDir.path();
if(!UploadsDir.exists()) {
try {
Expand Down Expand Up @@ -72,7 +72,7 @@ namespace OpenWifi {
Servers_.push_back(std::move(NewServer));
}

MaxSize_ = 1000 * Daemon()->ConfigGetInt("ucentral.fileuploader.maxsize", 10000);
MaxSize_ = 1000 * Daemon()->ConfigGetInt("openwifi.fileuploader.maxsize", 10000);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion src/FileUploader.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ namespace OpenWifi {
uint64_t MaxSize_=10000000;

explicit FileUploader() noexcept:
SubSystemServer("FileUploader", "FILE-UPLOAD", "ucentral.fileuploader")
SubSystemServer("FileUploader", "FILE-UPLOAD", "openwifi.fileuploader")
{
SubMutexGuard Guard(Mutex_);
}
Expand Down
Loading

0 comments on commit 9f9e1b4

Please sign in to comment.