summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/ConfigManager.cpp14
-rw-r--r--src/Common/ConfigManager.h2
-rw-r--r--src/Common/Configurable.h2
-rw-r--r--src/Core/ConnectionManager.cpp86
-rw-r--r--src/Core/ConnectionManager.h2
5 files changed, 53 insertions, 53 deletions
diff --git a/src/Common/ConfigManager.cpp b/src/Common/ConfigManager.cpp
index fbd73ea..20a6110 100644
--- a/src/Common/ConfigManager.cpp
+++ b/src/Common/ConfigManager.cpp
@@ -31,16 +31,16 @@ namespace Common {
ConfigManager ConfigManager::configManager;
-void ConfigManager::handleConfigEntry(const std::vector<std::string> &entry, const std::vector<std::vector<std::string> > &section) {
+void ConfigManager::handleConfigEntry(const std::vector<std::vector<std::string> > &entry) {
bool handled = false;
for(std::set<Configurable*>::iterator c = configurables.begin(); c != configurables.end(); ++c) {
- if((*c)->handleConfigEntry(entry, section))
+ if((*c)->handleConfigEntry(entry))
handled = true;
}
if(!handled)
- Logger::logf(Logger::WARNING, "Unknown config option '%s'.", entry.front().c_str());
+ Logger::logf(Logger::WARNING, "Invalid config option '%s'.", entry.back().front().c_str());
}
bool ConfigManager::loadFile(const std::string &filename, bool finish) {
@@ -87,15 +87,15 @@ bool ConfigManager::loadFile(const std::string &filename, bool finish) {
if(pos == std::string::npos) {
entry.push_back(line);
-
- handleConfigEntry(entry, section);
}
else {
entry.push_back(line.substr(0, pos));
entry.push_back(Util::trim(line.substr(pos)));
-
- handleConfigEntry(entry, section);
}
+
+ section.push_back(entry);
+ handleConfigEntry(section);
+ section.pop_back();
}
switch(bracket) {
diff --git a/src/Common/ConfigManager.h b/src/Common/ConfigManager.h
index 7fa781e..ccf5d13 100644
--- a/src/Common/ConfigManager.h
+++ b/src/Common/ConfigManager.h
@@ -38,7 +38,7 @@ class ConfigManager {
ConfigManager() : finished(false) {}
- void handleConfigEntry(const std::vector<std::string>&, const std::vector<std::vector<std::string> >&);
+ void handleConfigEntry(const std::vector<std::vector<std::string> > &entry);
public:
bool loadFile(const std::string &filename, bool finish = true);
diff --git a/src/Common/Configurable.h b/src/Common/Configurable.h
index 350b444..0c471c7 100644
--- a/src/Common/Configurable.h
+++ b/src/Common/Configurable.h
@@ -32,7 +32,7 @@ class Configurable {
protected:
friend class ConfigManager;
- virtual bool handleConfigEntry(const std::vector<std::string>&, const std::vector<std::vector<std::string> >&) {return false;}
+ virtual bool handleConfigEntry(const std::vector<std::vector<std::string> >&) {return false;}
virtual void configFinished() {}
};
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 5eed936..c135d06 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -55,64 +55,64 @@ void ConnectionManager::updateState(const std::string &name, Common::HostInfo::S
}
}
-bool ConnectionManager::handleConfigEntry(const std::vector<std::string> &entry, const std::vector<std::vector<std::string> > &section) {
- if(section.empty()) {
- if(Common::Util::tolower(entry.front()) == "listen") {
- if(entry.size() == 2) {
- try {
- listenerAddresses.push_back(Net::IPAddress(entry.back()));
- }
- catch(Common::Exception &e) {
- // TODO Log error
- }
-
- return true;
+bool ConnectionManager::handleConfigEntry(const std::vector<std::vector<std::string> > &entry) {
+ if(Common::Util::tolower(entry.front().front()) == "listen" && entry.size() == 1) {
+ if(entry.front().size() == 2) {
+ try {
+ listenerAddresses.push_back(Net::IPAddress(entry.front().back()));
}
- }
- else if(Common::Util::tolower(entry.front()) == "x509trustfile") {
- if(entry.size() == 2) {
- x509TrustFile = entry.back();
-
- return true;
+ catch(Common::Exception &e) {
+ // TODO Log error
}
+
+ return true;
}
- else if(Common::Util::tolower(entry.front()) == "x509crlfile") {
- if(entry.size() == 2) {
- x509CrlFile = entry.back();
+ }
+ else if(Common::Util::tolower(entry.front().front()) == "x509trustfile" && entry.size() == 1) {
+ if(entry.front().size() == 2) {
+ x509TrustFile = entry.front().back();
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front()) == "x509certfile") {
- if(entry.size() == 2) {
- x509CertFile = entry.back();
+ }
+ else if(Common::Util::tolower(entry.front().front()) == "x509crlfile" && entry.size() == 1) {
+ if(entry.front().size() == 2) {
+ x509CrlFile = entry.front().back();
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front()) == "x509keyfile") {
- if(entry.size() == 2) {
- x509KeyFile = entry.back();
+ }
+ else if(Common::Util::tolower(entry.front().front()) == "x509certfile" && entry.size() == 1) {
+ if(entry.front().size() == 2) {
+ x509CertFile = entry.front().back();
- return true;
- }
+ return true;
}
- else if(Common::Util::tolower(entry.front()) == "daemon") {
- if(entry.size() == 2) {
- daemonInfo.insert(std::make_pair(entry.back(), Common::HostInfo(entry.back())));
- identifiedDaemonConnections.insert(std::make_pair<std::string,Net::ServerConnection*>(entry.back(), 0));
+ }
+ else if(Common::Util::tolower(entry.front().front()) == "x509keyfile" && entry.size() == 1) {
+ if(entry.front().size() == 2) {
+ x509KeyFile = entry.front().back();
- return true;
- }
+ return true;
}
}
- else if(Common::Util::tolower(section.front().front()) == "daemon" && section.front().size() == 2 && section.size() == 1) {
- if(Common::Util::tolower(entry.front()) == "ipaddress") {
- if(entry.size() == 2) {
- daemonInfo[section.front().back()].setIP(entry.back());
+ else if(Common::Util::tolower(entry.front().front()) == "daemon") {
+ if(entry.front().size() == 2) {
+ if(entry.size() == 1) {
+ daemonInfo.insert(std::make_pair(entry.front().back(), Common::HostInfo(entry.front().back())));
+ identifiedDaemonConnections.insert(std::make_pair<std::string,Net::ServerConnection*>(entry.front().back(), 0));
return true;
}
+ else if(entry.size() == 2) {
+ if(Common::Util::tolower(entry.back().front()) == "ipaddress") {
+ if(entry.back().size() == 2) {
+ daemonInfo[entry.front().back()].setIP(entry.back().back());
+
+ return true;
+ }
+ }
+ }
}
}
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index ad5a57e..a069478 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -67,7 +67,7 @@ class ConnectionManager : private Common::Configurable {
void updateState(const std::string &name, Common::HostInfo::State state);
protected:
- virtual bool handleConfigEntry(const std::vector<std::string> &entry, const std::vector<std::vector<std::string> > &section);
+ virtual bool handleConfigEntry(const std::vector<std::vector<std::string> > &entry);
virtual void configFinished();
public: