From 86e5f80837ad55932f2469d79d9e6b6bb07cf5ed Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Mon, 28 Sep 2009 19:09:22 +0200 Subject: Implemented new ConfigManager --- src/Server/ConnectionManager.cpp | 32 ++++++++++++++++++++++++++++++-- src/Server/ConnectionManager.h | 4 +--- src/Server/UserListManager.cpp | 2 +- src/Server/UserListManager.h | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-) (limited to 'src/Server') diff --git a/src/Server/ConnectionManager.cpp b/src/Server/ConnectionManager.cpp index 25e088a..a278ee5 100644 --- a/src/Server/ConnectionManager.cpp +++ b/src/Server/ConnectionManager.cpp @@ -114,7 +114,35 @@ void ConnectionManager::updateState(Common::HostInfo *hostInfo, Common::HostInfo } } -bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { +void ConnectionManager::configure() { + x509TrustFile = application->getConfigManager()->get("X509TrustFile"); + x509CrlFile = application->getConfigManager()->get("X509CrlFile"); + x509CertFile = application->getConfigManager()->get("X509CertFile"); + x509KeyFile = application->getConfigManager()->get("X509KeyFile"); + + std::vector listenEntries = application->getConfigManager()->getEntries("Listen"); + if(!listenEntries.empty()) { + for(std::vector::iterator listenEntry = listenEntries.begin(); listenEntry != listenEntries.end(); ++listenEntry) { + try { + boost::shared_ptr listener(new Net::Listener(application, x509CertFile, x509KeyFile, + parseAddress((*listenEntry)->getValue().toString()))); + listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1)); + listeners.push_back(listener); + } + catch(Core::Exception &e) { + application->logf(Core::Logger::LOG_WARNING, "ConnectionManager: Invalid listen address '%s'", (*listenEntry)->getValue().toLocale().c_str()); + } + } + } + else { + boost::shared_ptr listener(new Net::Listener(application, x509CertFile, x509KeyFile, + boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v6(), DEFAULT_PORT))); + listener->connectSignalNewConnection(boost::bind(&ConnectionManager::handleNewConnection, this, _1)); + listeners.push_back(listener); + } +} + +/*bool ConnectionManager::handleConfigEntry(const Core::ConfigEntry &entry, bool handled) { if(handled) return false; @@ -179,7 +207,7 @@ void ConnectionManager::configFinished() { // TODO Log error } } -} +}*/ void ConnectionManager::handleNewConnection(boost::shared_ptr con) { boost::shared_ptr connection(new ServerConnection(application, con)); diff --git a/src/Server/ConnectionManager.h b/src/Server/ConnectionManager.h index 7e9dab0..28ddada 100644 --- a/src/Server/ConnectionManager.h +++ b/src/Server/ConnectionManager.h @@ -109,7 +109,6 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b Core::String x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile; - std::vector listenerAddresses; std::list > listeners; std::set > connections; @@ -131,8 +130,7 @@ class MAD_SERVER_EXPORT ConnectionManager : public Core::Configurable, private b ~ConnectionManager(); protected: - virtual bool handleConfigEntry(const Core::ConfigEntry &entry, bool handled); - virtual void configFinished(); + virtual void configure(); public: boost::shared_ptr getDaemonConnection(const Core::String &name) const throw (Core::Exception); diff --git a/src/Server/UserListManager.cpp b/src/Server/UserListManager.cpp index a8794fe..04ba7d2 100644 --- a/src/Server/UserListManager.cpp +++ b/src/Server/UserListManager.cpp @@ -45,7 +45,7 @@ UserListManager::~UserListManager() { } -void UserListManager::configFinished() { +void UserListManager::configure() { userLists = application->getStorageManager()->list("UserList"); userListDiffs = application->getStorageManager()->list("UserListDiff"); diff --git a/src/Server/UserListManager.h b/src/Server/UserListManager.h index 65e8fdf..bb5b4e3 100644 --- a/src/Server/UserListManager.h +++ b/src/Server/UserListManager.h @@ -57,7 +57,7 @@ class MAD_SERVER_EXPORT UserListManager : private Core::Configurable, private bo std::set userListDiffs; protected: - virtual void configFinished(); + virtual void configure(); public: virtual int getPriority() const {return -1;} -- cgit v1.2.3