Commit 8e7a5588 authored by Micha Mueller's avatar Micha Mueller
Browse files

Refactor global.conf: put restAPI related stuff into own struct

parent a43edfcf
global {
restAddr localhost:8000
mqttBroker localhost:1883
mqttprefix /00112233445566778899AABB0000
threads 24
......@@ -9,6 +8,22 @@ global {
cacheInterval 120
}
restAPI {
address localhost:8000
; certificate ../deps/openssl-1.0.2l/certs/demo/ca-cert.pem
; privateKey ../deps/openssl-1.0.2l/certs/demo/ca-cert.pem
; dhFile ../deps/openssl-1.0.2l/crypto/dh/dh2048.pem
;
; authkey qwertz {
; PUT
; GET
; }
;
; authkey yxcvbn {
; GET
; }
}
plugins {
plugin sysfs {
......
......@@ -66,16 +66,9 @@ bool Configuration::readGlobal() {
return false;
}
//read global variables
//read global struct
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("global")) {
if (boost::iequals(global.first, "restAddr")) {
_global.restAPISettings.restHost = global.second.data();
size_t pos = _global.restAPISettings.restHost.find(":");
if (pos != string::npos) {
_global.restAPISettings.restPort = _global.restAPISettings.restHost.substr(pos+1);
_global.restAPISettings.restHost.erase(pos);
}
} else if (boost::iequals(global.first, "mqttBroker")) {
if (boost::iequals(global.first, "mqttBroker")) {
_global.brokerHost = global.second.data();
size_t pos = _global.brokerHost.find(":");
if (pos != string::npos) {
......@@ -108,6 +101,20 @@ bool Configuration::readGlobal() {
}
}
//read restAPI struct
BOOST_FOREACH(boost::property_tree::iptree::value_type &global, cfg.get_child("restAPI")) {
if (boost::iequals(global.first, "address")) {
_global.restAPISettings.restHost = global.second.data();
size_t pos = _global.restAPISettings.restHost.find(":");
if (pos != string::npos) {
_global.restAPISettings.restPort = _global.restAPISettings.restHost.substr(pos+1);
_global.restAPISettings.restHost.erase(pos);
}
} else {
LOG(warning) << " Value \"" << global.first << "\" not recognized. Omitting";
}
}
return true;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment