Fixing Namespace

This commit is contained in:
stephb9959
2021-08-31 14:53:11 -07:00
parent 8172b9c55e
commit 9f9e1b4cdb
30 changed files with 311 additions and 418 deletions

View File

@@ -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)
@@ -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
@@ -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()

View File

@@ -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

2
build
View File

@@ -1 +1 @@
33
3

View File

@@ -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

View File

@@ -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
@@ -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
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
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.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
@@ -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
@@ -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

View File

@@ -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

View File

@@ -1,4 +1,4 @@
#!/bin/bash
export UCENTRALGW_CONFIG=`pwd`
export UCENTRALGW_ROOT=`pwd`
export OWGW_CONFIG=`pwd`
export OWGW_ROOT=`pwd`

View File

@@ -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
@@ -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);
@@ -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_);
@@ -95,7 +99,7 @@ namespace OpenWifi {
return 0;
}
void Stop() {
void Stop() override {
if(Server_)
Server_->stop();
}

View File

@@ -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);

View File

@@ -31,7 +31,7 @@
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();
@@ -39,24 +39,24 @@ namespace OpenWifi {
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_{};
};

View File

@@ -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 {
@@ -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;
}

View File

@@ -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_);
}

View File

@@ -17,13 +17,13 @@ namespace OpenWifi {
class KafkaManager *KafkaManager::instance_ = nullptr;
KafkaManager::KafkaManager() noexcept:
SubSystemServer("KafkaManager", "KAFKA-SVR", "ucentral.kafka")
SubSystemServer("KafkaManager", "KAFKA-SVR", "openwifi.kafka")
{
}
void KafkaManager::initialize(Poco::Util::Application & self) {
SubSystemServer::initialize(self);
KafkaEnabled_ = Daemon()->ConfigGetBool("ucentral.kafka.enable",false);
KafkaEnabled_ = Daemon()->ConfigGetBool("openwifi.kafka.enable",false);
}
#ifdef SMALL_BUILD
@@ -55,8 +55,8 @@ namespace OpenWifi {
void KafkaManager::ProducerThr() {
cppkafka::Configuration Config({
{ "client.id", Daemon()->ConfigGetString("ucentral.kafka.client.id") },
{ "metadata.broker.list", Daemon()->ConfigGetString("ucentral.kafka.brokerlist") }
{ "client.id", Daemon()->ConfigGetString("openwifi.kafka.client.id") },
{ "metadata.broker.list", Daemon()->ConfigGetString("openwifi.kafka.brokerlist") }
});
SystemInfoWrapper_ = R"lit({ "system" : { "id" : )lit" +
std::to_string(Daemon()->ID()) +
@@ -96,10 +96,10 @@ namespace OpenWifi {
void KafkaManager::ConsumerThr() {
cppkafka::Configuration Config({
{ "client.id", Daemon()->ConfigGetString("ucentral.kafka.client.id") },
{ "metadata.broker.list", Daemon()->ConfigGetString("ucentral.kafka.brokerlist") },
{ "group.id", Daemon()->ConfigGetString("ucentral.kafka.group.id") },
{ "enable.auto.commit", Daemon()->ConfigGetBool("ucentral.kafka.auto.commit",false) },
{ "client.id", Daemon()->ConfigGetString("openwifi.kafka.client.id") },
{ "metadata.broker.list", Daemon()->ConfigGetString("openwifi.kafka.brokerlist") },
{ "group.id", Daemon()->ConfigGetString("openwifi.kafka.group.id") },
{ "enable.auto.commit", Daemon()->ConfigGetBool("openwifi.kafka.auto.commit",false) },
{ "auto.offset.reset", "latest" } ,
{ "enable.partition.eof", false }
});
@@ -125,8 +125,8 @@ namespace OpenWifi {
}
});
bool AutoCommit = Daemon()->ConfigGetBool("ucentral.kafka.auto.commit",false);
auto BatchSize = Daemon()->ConfigGetInt("ucentral.kafka.consumer.batchsize",20);
bool AutoCommit = Daemon()->ConfigGetBool("openwifi.kafka.auto.commit",false);
auto BatchSize = Daemon()->ConfigGetInt("openwifi.kafka.consumer.batchsize",20);
Types::StringVec Topics;
for(const auto &i:Notifiers_)
@@ -174,7 +174,7 @@ namespace OpenWifi {
return std::move( SystemInfoWrapper_ + PayLoad + "}");
}
void KafkaManager::PostMessage(std::string topic, std::string key, std::string PayLoad, bool WrapMessage ) {
void KafkaManager::PostMessage(const std::string &topic, const std::string & key, const std::string &PayLoad, bool WrapMessage ) {
if(KafkaEnabled_) {
SubMutexGuard G(Mutex_);
KMessage M{

View File

@@ -41,7 +41,7 @@ namespace OpenWifi {
int Start() override;
void Stop() override;
void PostMessage(std::string topic, std::string key, std::string payload, bool WrapMessage = true);
void PostMessage(const std::string &topic, const std::string & key, const std::string &payload, bool WrapMessage = true);
[[nodiscard]] std::string WrapSystemId(const std::string & PayLoad);
[[nodiscard]] bool Enabled() { return KafkaEnabled_; }
int RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction & F);

View File

@@ -1,6 +1,11 @@
//
// Created by stephane bourque on 2021-06-22.
// 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.
//
#include <cstdlib>
#include <boost/algorithm/string.hpp>
@@ -182,7 +187,7 @@ namespace OpenWifi {
} else {
config().setString(LogFilePathKey, LogDir_);
}
Poco::File DataDir(ConfigPath("ucentral.system.data"));
Poco::File DataDir(ConfigPath("openwifi.system.data"));
DataDir_ = DataDir.path();
if(!DataDir.exists()) {
try {
@@ -191,16 +196,16 @@ namespace OpenWifi {
logger().log(E);
}
}
std::string KeyFile = ConfigPath("ucentral.service.key");
std::string KeyFilePassword = ConfigPath("ucentral.service.key.password" , "" );
std::string KeyFile = ConfigPath("openwifi.service.key");
std::string KeyFilePassword = ConfigPath("openwifi.service.key.password" , "" );
AppKey_ = Poco::SharedPtr<Poco::Crypto::RSAKey>(new Poco::Crypto::RSAKey("", KeyFile, KeyFilePassword));
Cipher_ = CipherFactory_.createCipher(*AppKey_);
ID_ = Utils::GetSystemId();
if(!DebugMode_)
DebugMode_ = ConfigGetBool("ucentral.system.debug",false);
MyPrivateEndPoint_ = ConfigGetString("ucentral.system.uri.private");
MyPublicEndPoint_ = ConfigGetString("ucentral.system.uri.public");
UIURI_ = ConfigGetString("ucentral.system.uri.ui");
DebugMode_ = ConfigGetBool("openwifi.system.debug",false);
MyPrivateEndPoint_ = ConfigGetString("openwifi.system.uri.private");
MyPublicEndPoint_ = ConfigGetString("openwifi.system.uri.public");
UIURI_ = ConfigGetString("openwifi.system.uri.ui");
MyHash_ = CreateHash(MyPublicEndPoint_);
InitializeSubSystemServers();
ServerApplication::initialize(self);
@@ -427,7 +432,7 @@ namespace OpenWifi {
Poco::Thread::trySleep((unsigned long)Daemon()->DaemonBusTimer());
if(!Running_)
break;
auto Msg = Daemon()->MakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE);
Msg = Daemon()->MakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE);
KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS,Daemon()->PrivateEndPoint(),Msg, false);
}
Msg = Daemon()->MakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_LEAVE);

View File

@@ -1,5 +1,9 @@
//
// Created by stephane bourque on 2021-06-22.
// 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_MICROSERVICE_H
@@ -29,11 +33,12 @@
namespace OpenWifi {
static const std::string uSERVICE_SECURITY{"ucentralsec"};
static const std::string uSERVICE_GATEWAY{"ucentralgw"};
static const std::string uSERVICE_FIRMWARE{ "ucentralfms"};
static const std::string uSERVICE_SECURITY{"owsec"};
static const std::string uSERVICE_GATEWAY{"owgw"};
static const std::string uSERVICE_FIRMWARE{ "owfms"};
static const std::string uSERVICE_TOPOLOGY{ "owtopo"};
static const std::string uSERVICE_PROVISIONING{ "owprov"};
static const std::string uSERVICE_OWLS{ "owls"};
class MyErrorHandler : public Poco::ErrorHandler {
public:
@@ -82,9 +87,6 @@ namespace OpenWifi {
DAEMON_APP_NAME(std::move(AppName)),
DAEMON_BUS_TIMER(BusTimer),
SubSystems_(std::move(Subsystems)) {
std::string V{APP_VERSION};
std::string B{BUILD_NUMBER};
Version_ = V + "(" + B + ")";
}
int main(const ArgVec &args) override;
@@ -136,9 +138,9 @@ namespace OpenWifi {
[[nodiscard]] MicroServiceMetaVec GetServices();
[[nodiscard]] bool IsValidAPIKEY(const Poco::Net::HTTPServerRequest &Request);
void SavePID();
inline uint64_t GetPID() { return Poco::Process::id(); };
[[nodiscard]] inline const std::string GetPublicAPIEndPoint() const { return MyPublicEndPoint_ + "/api/v1"; };
static void SavePID();
static inline uint64_t GetPID() { return Poco::Process::id(); };
[[nodiscard]] inline const std::string GetPublicAPIEndPoint() { return MyPublicEndPoint_ + "/api/v1"; };
[[nodiscard]] inline const std::string & GetUIURI() const { return UIURI_;};
private:
@@ -159,7 +161,7 @@ namespace OpenWifi {
std::string MyPrivateEndPoint_;
std::string MyPublicEndPoint_;
std::string UIURI_;
std::string Version_;
std::string Version_{std::string(APP_VERSION) + "("+ BUILD_NUMBER + ")"};
BusEventManager BusEventManager_;
SubMutex InfraMutex_;

View File

@@ -1,17 +1,20 @@
//
// Created by stephane bourque on 2021-07-01.
// 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.
//
//
#include <iostream>
#include "OpenAPIRequest.h"
#include "Poco/Net/HTTPSClientSession.h"
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/StreamCopier.h>
#include <Poco/JSON/Parser.h>
#include <Poco/Path.h>
#include <Poco/URI.h>
#include <Poco/Exception.h>
#include "Utils.h"
@@ -19,12 +22,12 @@
namespace OpenWifi {
OpenAPIRequestGet::OpenAPIRequestGet( const std::string & ServiceType,
const std::string & EndPoint,
OpenAPIRequestGet::OpenAPIRequestGet( std::string ServiceType,
std::string EndPoint,
Types::StringPairVec & QueryData,
uint64_t msTimeout):
Type_(ServiceType),
EndPoint_(EndPoint),
Type_(std::move(ServiceType)),
EndPoint_(std::move(EndPoint)),
QueryData_(QueryData),
msTimeout_(msTimeout) {

View File

@@ -1,5 +1,9 @@
//
// Created by stephane bourque on 2021-07-01.
// 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_OPENAPIREQUEST_H
@@ -13,8 +17,8 @@ namespace OpenWifi {
class OpenAPIRequestGet {
public:
explicit OpenAPIRequestGet( const std::string & Type,
const std::string & EndPoint,
explicit OpenAPIRequestGet( std::string Type,
std::string EndPoint,
Types::StringPairVec & QueryData,
uint64_t msTimeout);
int Do(Poco::JSON::Object::Ptr &ResponseObject);

View File

@@ -1,5 +1,9 @@
//
// Created by stephane bourque on 2021-06-13.
// 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_UCENTRALTYPES_H
@@ -16,6 +20,8 @@
#include <queue>
#include "Poco/StringTokenizer.h"
#include "Poco/JSON/Parser.h"
#include "Poco/JSON/Stringifier.h"
namespace OpenWifi::Types {
typedef std::pair<std::string,std::string> StringPair;
@@ -42,26 +48,58 @@ namespace OpenWifi::Types {
}
inline std::string to_string( const StringVec &V) {
std::string Result;
bool first=true;
Poco::JSON::Array O;
for(const auto &i:V) {
if(first) {
Result += i;
first = false;
} else {
Result += ",";
Result += i;
}
O.add(i);
}
std::stringstream SS;
Poco::JSON::Stringifier::stringify(O,SS);
return SS.str();
}
inline std::string to_string( const StringPairVec &V) {
Poco::JSON::Array O;
for(const auto &i:V) {
Poco::JSON::Array OO;
OO.add(i.first);
OO.add(i.second);
O.add(OO);
}
std::stringstream SS;
Poco::JSON::Stringifier::stringify(O,SS);
return SS.str();
}
inline void from_string(const std::string &S, StringPairVec &V) {
try {
Poco::JSON::Parser P;
auto O = P.parse(S).extract<Poco::JSON::Array::Ptr>();
for(const auto &i:*O) {
auto Inner = i.extract<Poco::JSON::Array::Ptr>();
for(const auto &j:*Inner) {
auto S1 = i[0].toString();
auto S2 = i[1].toString();
V.push_back(std::make_pair(S1,S2));
}
}
} catch (...) {
}
return Result;
}
inline void from_string(const std::string &S, StringVec &V) {
Poco::StringTokenizer Tokens(S,",",Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
try {
Poco::JSON::Parser P;
auto O = P.parse(S).extract<Poco::JSON::Array::Ptr>();
for(auto const &i:Tokens)
V.emplace_back(i);
for(auto const &i:*O) {
V.push_back(i.toString());
}
} catch (...) {
}
}
};

View File

@@ -22,7 +22,7 @@ namespace OpenWifi {
class RESTAPI_InternalServer *RESTAPI_InternalServer::instance_ = nullptr;
RESTAPI_InternalServer::RESTAPI_InternalServer() noexcept: SubSystemServer("RESTAPIInternalServer", "REST-ISRV", "ucentral.internal.restapi")
RESTAPI_InternalServer::RESTAPI_InternalServer() noexcept: SubSystemServer("RESTAPIInternalServer", "REST-ISRV", "openwifi.internal.restapi")
{
}

View File

@@ -160,7 +160,7 @@ namespace OpenWifi::SecurityObjects {
typedef std::vector<ProfileAction> ProfileActionVec;
struct SecurityProfile {
uint64_t id;
uint64_t id=0;
std::string name;
std::string description;
ProfileActionVec policy;

View File

@@ -34,7 +34,6 @@ namespace OpenWifi {
return;
}
auto serialOnly = GetBoolParameter(RESTAPI::Protocol::SERIALONLY, false);
auto countOnly = GetBoolParameter(RESTAPI::Protocol::COUNTONLY, false);
auto deviceWithStatus =
GetBoolParameter(RESTAPI::Protocol::DEVICEWITHSTATUS, false);
@@ -69,7 +68,7 @@ namespace OpenWifi {
else
RetObj.set(RESTAPI::Protocol::DEVICES, Objects);
} else if (countOnly == true) {
} else if (QB_.CountOnly == true) {
uint64_t Count = 0;
if (Storage()->GetDeviceCount(Count)) {
RetObj.set(RESTAPI::Protocol::COUNT, Count);

View File

@@ -150,6 +150,22 @@ namespace OpenWifi {
return Return;
}
bool RESTAPIHandler::AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, std::string &Value) {
if(O->has(Field)) {
Value = O->get(Field).toString();
return true;
}
return false;
}
bool RESTAPIHandler::AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, uint64_t &Value) {
if(O->has(Field)) {
Value = O->get(Field);
return true;
}
return false;
}
void RESTAPIHandler::AddCORS(Poco::Net::HTTPServerRequest &Request,
Poco::Net::HTTPServerResponse &Response) {
auto Origin = Request.find("Origin");
@@ -384,6 +400,13 @@ namespace OpenWifi {
Poco::JSON::Stringifier::stringify(Object, Answer);
}
void RESTAPIHandler::ReturnCountOnly(Poco::Net::HTTPServerRequest &Request, uint64_t Count,
Poco::Net::HTTPServerResponse &Response) {
Poco::JSON::Object Answer;
Answer.set("count", Count);
ReturnObject(Request,Answer,Response);
}
bool RESTAPIHandler::InitQueryBlock() {
if(QueryBlockInitialized_)
return true;
@@ -399,6 +422,7 @@ namespace OpenWifi {
QB_.LogType = GetParameter(RESTAPI::Protocol::LOGTYPE,0);
QB_.LastOnly = GetBoolParameter(RESTAPI::Protocol::LASTONLY,false);
QB_.Newest = GetBoolParameter(RESTAPI::Protocol::NEWEST,false);
QB_.CountOnly = GetBoolParameter(RESTAPI::Protocol::COUNTONLY,false);
if(QB_.Offset<1)
QB_.Offset=1;

View File

@@ -25,6 +25,7 @@
#include "Poco/NullStream.h"
#include "RESTAPI_SecurityObjects.h"
#include "RESTAPI_utils.h"
namespace OpenWifi {
@@ -86,7 +87,7 @@ namespace OpenWifi {
struct QueryBlock {
uint64_t StartDate = 0 , EndDate = 0 , Offset = 0 , Limit = 0, LogType = 0 ;
std::string SerialNumber, Filter, Select;
bool Lifetime=false, LastOnly=false, Newest=false;
bool Lifetime=false, LastOnly=false, Newest=false, CountOnly=false;
};
typedef std::map<std::string, std::string> BindingMap;
@@ -142,6 +143,9 @@ namespace OpenWifi {
const std::string &GetBinding(const std::string &Name, const std::string &Default);
bool InitQueryBlock();
void ReturnCountOnly(Poco::Net::HTTPServerRequest &Request, uint64_t Count,
Poco::Net::HTTPServerResponse &Response);
[[nodiscard]] static uint64_t Get(const char *Parameter,const Poco::JSON::Object::Ptr &Obj, uint64_t Default=0);
[[nodiscard]] static std::string GetS(const char *Parameter,const Poco::JSON::Object::Ptr &Obj, const std::string & Default="");
[[nodiscard]] static bool GetB(const char *Parameter,const Poco::JSON::Object::Ptr &Obj, bool Default=false);
@@ -149,6 +153,16 @@ namespace OpenWifi {
bool HasParameter(const std::string &QueryParameter, std::string &Value);
bool HasParameter(const std::string &QueryParameter, uint64_t & Value);
bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, std::string &Value);
bool AssignIfPresent(const Poco::JSON::Object::Ptr &O, const std::string &Field, uint64_t &Value);
template<typename T> void ReturnObject( Poco::Net::HTTPServerRequest &Request, const char *Name, const std::vector<T> & Objects,
Poco::Net::HTTPServerResponse &Response) {
Poco::JSON::Object Answer;
RESTAPI_utils::field_to_json(Answer,Name,Objects);
ReturnObject(Request, Answer, Response);
}
protected:
BindingMap Bindings_;
Poco::URI::QueryParameters Parameters_;

View File

@@ -30,7 +30,7 @@ namespace OpenWifi {
class RESTAPI_server *RESTAPI_server::instance_ = nullptr;
RESTAPI_server::RESTAPI_server() noexcept: SubSystemServer("RESTAPIServer", "RESTAPIServer", "ucentral.restapi")
RESTAPI_server::RESTAPI_server() noexcept: SubSystemServer("RESTAPIServer", "RESTAPIServer", "openwifi.restapi")
{
}

View File

@@ -12,7 +12,7 @@
namespace OpenWifi {
class StateProcessor {
public:
StateProcessor(GWObjects::ConnectionState * Conn):
explicit StateProcessor(GWObjects::ConnectionState * Conn):
Conn_(Conn) {}
~StateProcessor() {

View File

@@ -347,7 +347,6 @@ namespace OpenWifi {
}
Conn_->VerifiedCertificate = CertValidation_;
std::string Compatible;
if (Daemon()->AutoProvisioning() && !Storage()->DeviceExists(SerialNumber_)) {
Storage()->CreateDefaultDevice(SerialNumber_, Capabilities, Firmware, Compatible_);
} else if (Storage()->DeviceExists(SerialNumber_)) {
@@ -547,9 +546,6 @@ namespace OpenWifi {
ParamsObj->has(uCentralProtocol::UUID) && ParamsObj->has(uCentralProtocol::REBOOT) &&
ParamsObj->has(uCentralProtocol::LOGLINES)) {
uint64_t UUID = ParamsObj->get(uCentralProtocol::UUID);
uint64_t Reboot = ParamsObj->get(uCentralProtocol::REBOOT);
auto Firmware = ParamsObj->get(uCentralProtocol::FIRMWARE).toString();
auto LogLines = ParamsObj->get(uCentralProtocol::LOGLINES);
std::string LogText;
if (LogLines.isArray()) {
@@ -624,13 +620,13 @@ namespace OpenWifi {
}
void WSConnection::ProcessIncomingFrame() {
int flags, Op;
int IncomingSize;
bool MustDisconnect=false;
Poco::Buffer<char> IncomingFrame(0);
try {
int Op,flags;
int IncomingSize;
IncomingSize = WS_->receiveFrame(IncomingFrame,flags);
Op = flags & Poco::Net::WebSocket::FRAME_OP_BITMASK;

View File

@@ -686,7 +686,7 @@ namespace OpenWifi {
Poco::Data::LOBOutputStream OL(L);
if (FileName.getSize() <
(1000 * Daemon()->ConfigGetInt("ucentral.fileuploader.maxsize", 10000))) {
(1000 * Daemon()->ConfigGetInt("openwifi.fileuploader.maxsize", 10000))) {
std::ifstream f(FileName.path(), std::ios::binary);
Poco::StreamCopier::copyStream(f, OL);

View File

@@ -20,11 +20,11 @@ then
exit 1
fi
if [[ "${UCENTRALSEC}" == "" ]]
if [[ "${OWSEC}" == "" ]]
then
echo "You must set the variable UCENTRALSEC in order to use this script. Something like"
echo "UCENTRALSEC=security.isp.com:16001"
exit 1
echo "You must set the variable OWSEC in order to use this script. Something like"
echo "OWSEC=security.isp.com:16001"
exit 1
fi
if [[ "${FLAGS}" == "" ]]
@@ -41,7 +41,7 @@ browser=""
login() {
payload="{ \"userId\" : \"$username\" , \"password\" : \"$password\" }"
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${UCENTRALSEC}/api/v1/oauth2" | jq -r '.access_token')
token=$(curl ${FLAGS} -X POST -H "Content-Type: application/json" -d "$payload" "https://${OWSEC}/api/v1/oauth2" | jq -r '.access_token')
if [[ "${token}" == "" ]]
then
@@ -73,14 +73,14 @@ findbrowser() {
}
setgateway() {
curl ${FLAGS} -X GET "https://${UCENTRALSEC}/api/v1/systemEndpoints" \
curl ${FLAGS} -X GET "https://${OWSEC}/api/v1/systemEndpoints" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
# jq < ${result_file}
for index in {0..10}
do
endpointlocation=".endpoints[${index}].uri"
endpointlocation=".endpoints[${index}].uri"
endpointlocationtype=".endpoints[${index}].type"
rawurl="$(cat ${result_file} | jq -r ${endpointlocation})"
svctype="$(cat ${result_file} | jq -r ${endpointlocationtype})"
@@ -93,7 +93,7 @@ setgateway() {
path="$(echo $url | grep / | cut -d/ -f2-)"
if [[ ${url} != "null" ]]
then
if [[ ${svctype} == "ucentralgw" ]]
if [[ ${svctype} == "owgw" ]]
then
# echo "url: $url"
# echo " proto: $proto"
@@ -101,97 +101,97 @@ setgateway() {
# echo " host: $host"
# echo " port: $port"
# echo " path: $path"
UCENTRALGW="${url}"
OGWG="${url}"
break
fi
fi
done
echo "Using ${UCENTRALGW}..."
echo "Using ${OGWG}..."
}
logout() {
curl ${FLAGS} -X DELETE -H "Content-Type: application/json" \
-H "Authorization: Bearer ${token}" \
"https://${UCENTRALSEC}/api/v1/oauth2/${token}"
"https://${OWSEC}/api/v1/oauth2/${token}"
rm -rf token.json
}
getdevice() {
curl ${FLAGS} -X GET --url "https://${UCENTRALGW}/api/v1/device/$1" \
curl ${FLAGS} -X GET --url "https://${OWGW}/api/v1/device/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
getcommand() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/command/$1" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/command/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deletecommand() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/command/$1" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/command/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
listcommands() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/commands?serialNumber=$1&limit=3000" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/commands?serialNumber=$1&limit=3000" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
newestcommands() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/commands?serialNumber=$1&newest=true&limit=50" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/commands?serialNumber=$1&newest=true&limit=50" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deletecommands() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/commands?serialNumber=$1" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/commands?serialNumber=$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
getcapabilities() {
curl -${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/capabilities" \
curl -${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/capabilities" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deletecapabilities() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/device/$1/capabilities" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1/capabilities" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
listdevices() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
ldevs() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices?offset=$1&limit=$2" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?offset=$1&limit=$2" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deletedevice() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/device/$1" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
createdevice() {
payload="{ \"serialNumber\": \"$1\", \"UUID\": 1234456, \"configuration\" : $(cat "$2") , \"deviceType\": \"AP\",\"location\": \"\", \"macAddress\": \"$3\", \"manufacturer\": \"Linksys EA8300 (Dallas)\", \"owner\": \"\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -200,7 +200,7 @@ createdevice() {
addnote() {
payload="{ \"serialNumber\": \"$1\", \"notes\" : [ {\"note\" : \"$2\"} ] }"
curl ${FLAGS} -X PUT "https://${UCENTRALGW}/api/v1/device/$1" \
curl ${FLAGS} -X PUT "https://${OWGW}/api/v1/device/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -209,7 +209,7 @@ addnote() {
reboot() {
payload="{ \"serialNumber\" : \"$1\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/reboot" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/reboot" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -218,7 +218,7 @@ reboot() {
setloglevel() {
payload="{ \"command\" : \"setloglevel\" , \"parameters\" : [ { \"tag\" : \"$1\" , \"value\" : \"$2\" } ] }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload"
@@ -226,7 +226,7 @@ setloglevel() {
getloglevels() {
payload="{ \"command\" : \"getloglevels\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload"
@@ -234,7 +234,7 @@ getloglevels() {
getloglevelnames() {
payload="{ \"command\" : \"getloglevelnames\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload"
@@ -242,14 +242,14 @@ getloglevelnames() {
getsubsystemnames() {
payload="{ \"command\" : \"getsubsystemnames\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/system" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/system" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload"
}
getdevicestatus() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/status" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/status" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -257,7 +257,7 @@ getdevicestatus() {
upgrade() {
payload="{ \"serialNumber\" : \"$1\" , \"uri\" : \"$2\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/upgrade" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/upgrade" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -266,7 +266,7 @@ upgrade() {
leds() {
payload="{ \"serialNumber\" : \"$1\" , \"duration\" : $3, \"pattern\" : \"$2\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/leds" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/leds" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -275,7 +275,7 @@ leds() {
factory() {
payload="{ \"serialNumber\" : \"$1\" , \"keepRedirector\" : $2 }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/factory" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/factory" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -284,7 +284,7 @@ factory() {
configure() {
payload="{ \"serialNumber\" : \"$1\", \"UUID\" : 123456 , \"configuration\" : $(cat "$2") }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/configure" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/configure" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -293,7 +293,7 @@ configure() {
request() {
payload="{ \"serialNumber\" : \"$1\" , \"message\" : \"$2\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/request" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/request" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -302,7 +302,7 @@ request() {
wifiscan() {
payload="{ \"serialNumber\" : \"$1\" , \"verbose\" : $2 }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/wifiscan" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/wifiscan" \
--max-time 20 \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -312,7 +312,7 @@ wifiscan() {
activescan() {
payload="{ \"serialNumber\" : \"$1\" , \"verbose\" : $2, \"activeScan\" : true}"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/wifiscan" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/wifiscan" \
--max-time 20 \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -322,7 +322,7 @@ activescan() {
trace() {
payload="{ \"serialNumber\" : \"$1\" , \"duration\" : $2, \"network\" : \"$3\" }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/trace" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/trace" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -330,27 +330,27 @@ trace() {
}
getstats() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/statistics" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
getlogs() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/logs" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/logs" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deletelogs() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/device/$1/logs" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/device/$1/logs" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
gethealthchecks() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/healthchecks" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -358,7 +358,7 @@ gethealthchecks() {
createdefaultconfig() {
payload="{ \"name\": \"$1\", \"modelIds\" : \"$2\", \"configuration\" : $(cat "$3")}"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/default_configuration/$1" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/default_configuration/$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload" > ${result_file}
@@ -366,7 +366,7 @@ createdefaultconfig() {
}
listdefaultconfigs() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/default_configurations" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/default_configurations" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -374,20 +374,20 @@ listdefaultconfigs() {
addblacklistdevice() {
payload="{ \"devices\" : [ {\"serialNumber\": \"$1\" , \"reason\" : \"$2\" } ] }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/blacklist" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/blacklist" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
-d "$payload"
}
deleteblacklistdevice() {
curl ${FLAGS} -X DELETE "https://${UCENTRALGW}/api/v1/blacklist?serialNumber=$1" \
curl ${FLAGS} -X DELETE "https://${OWGW}/api/v1/blacklist?serialNumber=$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}"
}
getblacklist() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/blacklist" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/blacklist" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -395,7 +395,7 @@ getblacklist() {
eventqueue() {
payload="{ \"serialNumber\" : \"$1\" , \"types\" : [ \"dhcp\", \"wifi\" ] }"
curl ${FLAGS} -X POST "https://${UCENTRALGW}/api/v1/device/$1/eventqueue" \
curl ${FLAGS} -X POST "https://${OWGW}/api/v1/device/$1/eventqueue" \
--max-time 20 \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" \
@@ -404,42 +404,42 @@ eventqueue() {
}
selectdevices() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices?select=$1" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?select=$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deviceserialnumbers() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices?serialOnly=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?serialOnly=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
deviceswithstatus() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices?deviceWithStatus=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?deviceWithStatus=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
devicecount() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/devices?countOnly=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/devices?countOnly=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
getfile() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/file/$2?serialNumber=$1" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/file/$2?serialNumber=$1" \
-H "accept: application/octet-stream" \
-H "Authorization: Bearer ${token}" \
-o "$2.pcap"
}
rtty() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/rtty" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/rtty" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -457,70 +457,70 @@ rtty() {
}
lifetimestats() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/statistics?lifetime=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?lifetime=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
laststats() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/statistics?lastOnly=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?lastOnly=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
lasthealthcheck() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/healthchecks?lastOnly=true" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks?lastOnly=true" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
neweststats() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/statistics?newest=true&limit=50" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/statistics?newest=true&limit=50" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
newestlogs() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/logs?newest=true&limit=50" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/logs?newest=true&limit=50" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
newesthealthchecks() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/device/$1/healthchecks?newest=true&limit=50" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/device/$1/healthchecks?newest=true&limit=50" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
ouilookup() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/ouis?macList=$1" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/ouis?macList=$1" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
dashboard() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/deviceDashboard" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/deviceDashboard" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
gwversion() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/system?command=version" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/system?command=version" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
}
gwtimes() {
curl ${FLAGS} -X GET "https://${UCENTRALGW}/api/v1/system?command=times" \
curl ${FLAGS} -X GET "https://${OWGW}/api/v1/system?command=times" \
-H "accept: application/json" \
-H "Authorization: Bearer ${token}" > ${result_file}
jq < ${result_file}
@@ -529,7 +529,7 @@ gwtimes() {
wstest() {
echo "Token:${token}"
wscat \
-c wss://${UCENTRALGW}/api/v1/ws
-c wss://${OWGW}/api/v1/ws
}
help() {

View File

@@ -1,195 +0,0 @@
#
# uCentral protocol server for devices. This is where you point
# all your devices. You can replace the * for address by the specific
# 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.address = *
ucentral.websocket.host.0.port = 15002
ucentral.websocket.host.0.security = strict
ucentral.websocket.host.0.key.password = mypassword
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
#
# 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
#
# 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.uri.private = https://localhost:17002
ucentral.system.uri.public = https://ucentral.dpaas.arilia.com:16002
ucentral.system.uri.ui = https://ucentral-ui.arilia.com
ucentral.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
oui.download.uri = https://linuxnet.ca/ieee/oui.txt
firmware.autoupdate.policy.default = auto
#
# rtty
#
rtty.enabled = true
rtty.server = rtty-tip.arilia.com
rtty.port = 5912
rtty.token = 96181c567b4d0d98c50f127230068fa8
rtty.timeout = 60
rtty.viewport = 5913
#############################
# Generic information for all micro services
#############################
#
# NLB Support
#
alb.enable = true
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
#
# 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
# death and might make your beer flat.
#
storage.type = sqlite
#storage.type = postgresql
#storage.type = mysql
#storage.type = odbc
storage.type.sqlite.db = devices.db
storage.type.sqlite.idletime = 120
storage.type.sqlite.maxsessions = 128
storage.type.postgresql.maxsessions = 64
storage.type.postgresql.idletime = 60
storage.type.postgresql.host = localhost
storage.type.postgresql.username = stephb
storage.type.postgresql.password = snoopy99
storage.type.postgresql.database = ucentral
storage.type.postgresql.port = 5432
storage.type.postgresql.connectiontimeout = 60
storage.type.mysql.maxsessions = 64
storage.type.mysql.idletime = 60
storage.type.mysql.host = localhost
storage.type.mysql.username = stephb
storage.type.mysql.password = snoopy99
storage.type.mysql.database = ucentral
storage.type.mysql.port = 3306
storage.type.mysql.connectiontimeout = 60
archiver.enabled = true
archiver.schedule = 03:00
archiver.db.0.name = healthchecks
archiver.db.0.keep = 7
archiver.db.1.name = statistics
archiver.db.1.keep = 7
archiver.db.2.name = devicelogs
archiver.db.2.keep = 7
archiver.db.3.name = commandlist
archiver.db.3.keep = 7
########################################################################
########################################################################
#
# Logging: please leave as is for now.
#
########################################################################
logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = %s: [%p] %t
logging.formatters.f1.times = UTC
logging.channels.c1.class = ConsoleChannel
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.formatter.class = PatternFormatter
logging.channels.c2.formatter.pattern = %Y-%m-%d %H:%M:%S %s: [%p] %t
logging.channels.c2.rotation = 20 M
logging.channels.c2.archive = timestamp
logging.channels.c2.purgeCount = 20
logging.channels.c3.class = ConsoleChannel
logging.channels.c3.pattern = %s: [%p] %t
# External Channel
logging.loggers.root.channel = c2
logging.loggers.root.level = debug
# Inline Channel with PatternFormatter
# logging.loggers.l1.name = logger1
# logging.loggers.l1.channel.class = ConsoleChannel
# logging.loggers.l1.channel.pattern = %s: [%p] %t
# logging.loggers.l1.level = information
# SplitterChannel
# logging.channels.splitter.class = SplitterChannel
# logging.channels.splitter.channels = l1,l2
# logging.loggers.l2.name = logger2
# logging.loggers.l2.channel = splitter