summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/Client/CommandParser.h8
-rw-r--r--src/Client/InformationManager.cpp2
-rw-r--r--src/Client/InformationManager.h10
-rw-r--r--src/Client/Requests/DaemonCommandRequest.h2
-rw-r--r--src/Client/Requests/DaemonFSInfoRequest.h2
-rw-r--r--src/Client/Requests/DaemonListRequest.h2
-rw-r--r--src/Client/Requests/DaemonStatusRequest.h2
-rw-r--r--src/Common/ClientConnection.cpp66
-rw-r--r--src/Common/ClientConnection.h59
-rw-r--r--src/Common/Connection.cpp (renamed from src/Common/RequestHandler.cpp)15
-rw-r--r--src/Common/Connection.h82
-rw-r--r--src/Common/Makefile.am15
-rw-r--r--src/Common/Makefile.in27
-rw-r--r--src/Common/Request.h2
-rw-r--r--src/Common/RequestHandler.h17
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.cpp1
-rw-r--r--src/Common/RequestHandlers/DisconnectRequestHandler.h2
-rw-r--r--src/Common/RequestHandlers/FSInfoRequestHandler.h2
-rw-r--r--src/Common/RequestHandlers/StatusRequestHandler.h2
-rw-r--r--src/Common/RequestManager.cpp38
-rw-r--r--src/Common/RequestManager.h25
-rw-r--r--src/Common/Requests/DisconnectRequest.cpp1
-rw-r--r--src/Common/Requests/DisconnectRequest.h2
-rw-r--r--src/Common/Requests/FSInfoRequest.h2
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.cpp6
-rw-r--r--src/Common/Requests/GSSAPIAuthRequest.h2
-rw-r--r--src/Common/Requests/SimpleRequest.h2
-rw-r--r--src/Common/Requests/StatusRequest.h2
-rw-r--r--src/Common/Requests/UserListRequest.h2
-rw-r--r--src/Core/ConnectionManager.cpp149
-rw-r--r--src/Core/ConnectionManager.h56
-rw-r--r--src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp2
-rw-r--r--src/Core/RequestHandlers/DaemonCommandRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp2
-rw-r--r--src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/DaemonListRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp2
-rw-r--r--src/Core/RequestHandlers/DaemonStatusRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp6
-rw-r--r--src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/IdentifyRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/LogRequestHandler.h2
-rw-r--r--src/Core/RequestHandlers/UserListRequestHandler.h2
-rw-r--r--src/Core/Requests/CommandRequest.h2
-rw-r--r--src/Core/Requests/DaemonStateUpdateRequest.h2
-rw-r--r--src/Daemon/Backends/NetworkLogger.h5
-rw-r--r--src/Daemon/RequestHandlers/CommandRequestHandler.h2
-rw-r--r--src/Daemon/Requests/IdentifyRequest.h2
-rw-r--r--src/Daemon/Requests/LogRequest.h2
-rw-r--r--src/Net/ClientConnection.cpp2
-rw-r--r--src/Net/Connection.cpp4
-rw-r--r--src/Net/Connection.h13
-rw-r--r--src/mad.cpp5
-rw-r--r--src/madc.cpp5
54 files changed, 474 insertions, 203 deletions
diff --git a/src/Client/CommandParser.h b/src/Client/CommandParser.h
index 2827443..23330ca 100644
--- a/src/Client/CommandParser.h
+++ b/src/Client/CommandParser.h
@@ -29,7 +29,7 @@
namespace Mad {
-namespace Net {
+namespace Common {
class Connection;
}
@@ -50,7 +50,7 @@ class CommandParser {
static CommandParser commandParser;
- Net::Connection *connection;
+ Common::Connection *connection;
const Command* findCommand(const std::string& command);
void printUsage(const std::string& command);
@@ -73,11 +73,11 @@ class CommandParser {
return &commandParser;
}
- Net::Connection *getConnection() const {
+ Common::Connection *getConnection() const {
return connection;
}
- void setConnection(Net::Connection *con) {
+ void setConnection(Common::Connection *con) {
connection = con;
}
diff --git a/src/Client/InformationManager.cpp b/src/Client/InformationManager.cpp
index 4c9800b..d99791c 100644
--- a/src/Client/InformationManager.cpp
+++ b/src/Client/InformationManager.cpp
@@ -67,7 +67,7 @@ void InformationManager::doDeinit() {
Common::RequestManager::get()->unregisterPacketType("UpdateHostState");
}
-void InformationManager::updateDaemonList(Net::Connection *con) {
+void InformationManager::updateDaemonList(Common::Connection *con) {
if(updating)
return;
diff --git a/src/Client/InformationManager.h b/src/Client/InformationManager.h
index 369eefd..fff26b3 100644
--- a/src/Client/InformationManager.h
+++ b/src/Client/InformationManager.h
@@ -28,12 +28,6 @@
#include <Common/Request.h>
namespace Mad {
-
-namespace Net {
-class Connection;
-
-}
-
namespace Client {
class InformationManager : public Common::Initializable {
@@ -43,7 +37,7 @@ class InformationManager : public Common::Initializable {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- DaemonStateUpdateRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DaemonStateUpdateRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
@@ -70,7 +64,7 @@ class InformationManager : public Common::Initializable {
return &informationManager;
}
- void updateDaemonList(Net::Connection *con);
+ void updateDaemonList(Common::Connection *con);
bool isUpdating() const {
return updating;
diff --git a/src/Client/Requests/DaemonCommandRequest.h b/src/Client/Requests/DaemonCommandRequest.h
index 4e9e2d1..2e421e8 100644
--- a/src/Client/Requests/DaemonCommandRequest.h
+++ b/src/Client/Requests/DaemonCommandRequest.h
@@ -36,7 +36,7 @@ class DaemonCommandRequest : public Common::Request {
virtual void sendRequest();
public:
- DaemonCommandRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0, bool reboot0)
+ DaemonCommandRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0, bool reboot0)
: Common::Request(connection, requestId, slot), daemon(daemon0), reboot(reboot0) {}
};
diff --git a/src/Client/Requests/DaemonFSInfoRequest.h b/src/Client/Requests/DaemonFSInfoRequest.h
index 2e6a68f..17d2aa0 100644
--- a/src/Client/Requests/DaemonFSInfoRequest.h
+++ b/src/Client/Requests/DaemonFSInfoRequest.h
@@ -36,7 +36,7 @@ class DaemonFSInfoRequest : public Common::Request {
virtual void sendRequest();
public:
- DaemonFSInfoRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0)
+ DaemonFSInfoRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0)
: Common::Request(connection, requestId, slot), daemon(daemon0) {}
};
diff --git a/src/Client/Requests/DaemonListRequest.h b/src/Client/Requests/DaemonListRequest.h
index 017d355..27a025f 100644
--- a/src/Client/Requests/DaemonListRequest.h
+++ b/src/Client/Requests/DaemonListRequest.h
@@ -28,7 +28,7 @@ namespace Requests {
class DaemonListRequest : public Common::Requests::SimpleRequest {
public:
- DaemonListRequest(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ DaemonListRequest(Common::Connection *connection, uint16_t requestId, slot_type slot)
: SimpleRequest(connection, requestId, slot, "ListHosts") {}
};
diff --git a/src/Client/Requests/DaemonStatusRequest.h b/src/Client/Requests/DaemonStatusRequest.h
index 83cba67..936692f 100644
--- a/src/Client/Requests/DaemonStatusRequest.h
+++ b/src/Client/Requests/DaemonStatusRequest.h
@@ -36,7 +36,7 @@ class DaemonStatusRequest : public Common::Request {
virtual void sendRequest();
public:
- DaemonStatusRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0)
+ DaemonStatusRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &daemon0)
: Common::Request(connection, requestId, slot), daemon(daemon0) {}
};
diff --git a/src/Common/ClientConnection.cpp b/src/Common/ClientConnection.cpp
new file mode 100644
index 0000000..e030bfc
--- /dev/null
+++ b/src/Common/ClientConnection.cpp
@@ -0,0 +1,66 @@
+/*
+ * SimpleConnection.cpp
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "ClientConnection.h"
+#include <Net/ClientConnection.h>
+
+namespace Mad {
+namespace Common {
+
+ClientConnection::ClientConnection() : connection(new Net::ClientConnection) {
+ connection->signalReceive().connect(sigc::mem_fun(this, &ClientConnection::receive));
+}
+
+bool ClientConnection::send(const Net::Packet &packet) {
+ return connection->send(packet);
+}
+
+void ClientConnection::connect(const Net::IPAddress &address, bool daemon) throw(Common::Exception) {
+ connection->connect(address, daemon);
+}
+
+bool ClientConnection::isConnecting() const {
+ return connection->isConnecting();
+}
+
+bool ClientConnection::isConnected() const {
+ return connection->isConnected();
+}
+
+bool ClientConnection::disconnect() {
+ connection->disconnect();
+ return true;
+}
+
+void* ClientConnection::getCertificate(size_t *size) const {
+ const gnutls_datum_t *cert = connection->getCertificate();
+
+ *size = cert->size;
+ return cert->data;
+}
+
+void* ClientConnection::getPeerCertificate(size_t *size) const {
+ const gnutls_datum_t *cert = connection->getPeerCertificate();
+
+ *size = cert->size;
+ return cert->data;
+}
+
+}
+}
diff --git a/src/Common/ClientConnection.h b/src/Common/ClientConnection.h
new file mode 100644
index 0000000..7e422b0
--- /dev/null
+++ b/src/Common/ClientConnection.h
@@ -0,0 +1,59 @@
+/*
+ * ClientConnection.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_COMMON_CLIENTCONNECTION_H_
+#define MAD_COMMON_CLIENTCONNECTION_H_
+
+#include "Connection.h"
+#include "Exception.h"
+
+namespace Mad {
+
+namespace Net {
+class ClientConnection;
+class IPAddress;
+}
+
+namespace Common {
+
+class ClientConnection : public Connection {
+ private:
+ Net::ClientConnection *connection;
+
+ protected:
+ virtual bool send(const Net::Packet &packet);
+
+ public:
+ ClientConnection();
+ virtual ~ClientConnection() {}
+
+ void connect(const Net::IPAddress &address, bool daemon = false) throw(Common::Exception);
+
+ bool isConnecting() const;
+ bool isConnected() const;
+
+ virtual bool disconnect();
+ virtual void* getCertificate(size_t *size) const;
+ virtual void* getPeerCertificate(size_t *size) const;
+};
+
+}
+}
+
+#endif /* MAD_COMMON_CLIENTCONNECTION_H_ */
diff --git a/src/Common/RequestHandler.cpp b/src/Common/Connection.cpp
index 3e0eabc..b4e5db4 100644
--- a/src/Common/RequestHandler.cpp
+++ b/src/Common/Connection.cpp
@@ -1,5 +1,5 @@
/*
- * RequestHandler.cpp
+ * Connection.cpp
*
* Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
*
@@ -17,14 +17,19 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "RequestHandler.h"
-#include <Net/Connection.h>
+#include "Connection.h"
+#include "XmlPacket.h"
+
namespace Mad {
namespace Common {
-bool RequestHandler::sendPacket(const XmlPacket &packet) {
- return connection->send(packet.encode(requestId));
+void Connection::receive(const Net::Packet &packet) {
+ signal(XmlPacket(packet), packet.getRequestId());
+}
+
+bool Connection::sendPacket(const XmlPacket &packet, uint16_t requestId) {
+ return send(packet.encode(requestId));
}
}
diff --git a/src/Common/Connection.h b/src/Common/Connection.h
new file mode 100644
index 0000000..860c044
--- /dev/null
+++ b/src/Common/Connection.h
@@ -0,0 +1,82 @@
+/*
+ * Connection.h
+ *
+ * Copyright (C) 2009 Matthias Schiffer <matthias@gamezock.de>
+ *
+ * This program is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef MAD_COMMON_CONNECTION_H_
+#define MAD_COMMON_CONNECTION_H_
+
+#include <stdint.h>
+#include <sys/types.h>
+
+#include <sigc++/signal.h>
+
+namespace Mad {
+
+namespace Net {
+class Packet;
+}
+
+namespace Common {
+
+class XmlPacket;
+
+class Connection {
+ private:
+ bool authenticated;
+
+ sigc::signal<void, const XmlPacket&, uint16_t> signal;
+
+ // Prevent shallow copy
+ Connection(const Connection &o);
+ Connection& operator=(const Connection &o);
+
+ protected:
+ Connection() : authenticated(0) {}
+
+ void receive(const Net::Packet &packet);
+
+ virtual bool send(const Net::Packet &packet) = 0;
+
+ public:
+ virtual ~Connection() {}
+
+ bool sendPacket(const XmlPacket &packet, uint16_t requestId);
+
+ sigc::signal<void, const XmlPacket&, uint16_t> signalReceive() const {
+ return signal;
+ }
+
+ virtual bool disconnect() = 0;
+ virtual void* getCertificate(size_t *size) const = 0;
+ virtual void* getPeerCertificate(size_t *size) const = 0;
+
+ virtual
+
+ void setAuthenticated() {
+ authenticated = true;
+ }
+
+ bool isAuthenticated() const {
+ return authenticated;
+ }
+};
+
+}
+}
+
+#endif /* MAD_COMMON_CONNECTION_H_ */
diff --git a/src/Common/Makefile.am b/src/Common/Makefile.am
index 9f31371..51593d7 100644
--- a/src/Common/Makefile.am
+++ b/src/Common/Makefile.am
@@ -1,12 +1,13 @@
SUBDIRS = Requests RequestHandlers
noinst_LTLIBRARIES = libcommon.la
-libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Exception.cpp Initializable.cpp \
- Logger.cpp LogManager.cpp ModuleManager.cpp Request.cpp RequestHandler.cpp \
- RequestManager.cpp SystemBackend.cpp Tokenizer.cpp XmlPacket.cpp
+libcommon_la_SOURCES = ActionManager.cpp ClientConnection.cpp ConfigEntry.cpp ConfigManager.cpp \
+ Connection.cpp Exception.cpp Initializable.cpp Logger.cpp LogManager.cpp \
+ ModuleManager.cpp Request.cpp RequestManager.cpp SystemBackend.cpp \
+ Tokenizer.cpp XmlPacket.cpp
libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la ../../lib/libgnu.la
-noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h \
- Exception.h HostInfo.h Initializable.h Logger.h LoggerBase.h LogManager.h \
- ModuleManager.h RemoteLogger.h Request.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h
+noinst_HEADERS = ActionManager.h ClientConnection.h ConfigEntry.h ConfigManager.h \
+ Configurable.h Connection.h Exception.h HostInfo.h Initializable.h Logger.h \
+ LoggerBase.h LogManager.h ModuleManager.h RemoteLogger.h Request.h \
+ RequestHandler.h RequestManager.h SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h
diff --git a/src/Common/Makefile.in b/src/Common/Makefile.in
index 6f2595f..45fc07f 100644
--- a/src/Common/Makefile.in
+++ b/src/Common/Makefile.in
@@ -53,10 +53,11 @@ CONFIG_CLEAN_FILES =
LTLIBRARIES = $(noinst_LTLIBRARIES)
libcommon_la_DEPENDENCIES = Requests/librequests.la \
RequestHandlers/librequesthandlers.la ../../lib/libgnu.la
-am_libcommon_la_OBJECTS = ActionManager.lo ConfigEntry.lo \
- ConfigManager.lo Exception.lo Initializable.lo Logger.lo \
- LogManager.lo ModuleManager.lo Request.lo RequestHandler.lo \
- RequestManager.lo SystemBackend.lo Tokenizer.lo XmlPacket.lo
+am_libcommon_la_OBJECTS = ActionManager.lo ClientConnection.lo \
+ ConfigEntry.lo ConfigManager.lo Connection.lo Exception.lo \
+ Initializable.lo Logger.lo LogManager.lo ModuleManager.lo \
+ Request.lo RequestManager.lo SystemBackend.lo Tokenizer.lo \
+ XmlPacket.lo
libcommon_la_OBJECTS = $(am_libcommon_la_OBJECTS)
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
@@ -238,15 +239,16 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
SUBDIRS = Requests RequestHandlers
noinst_LTLIBRARIES = libcommon.la
-libcommon_la_SOURCES = ActionManager.cpp ConfigEntry.cpp ConfigManager.cpp Exception.cpp Initializable.cpp \
- Logger.cpp LogManager.cpp ModuleManager.cpp Request.cpp RequestHandler.cpp \
- RequestManager.cpp SystemBackend.cpp Tokenizer.cpp XmlPacket.cpp
+libcommon_la_SOURCES = ActionManager.cpp ClientConnection.cpp ConfigEntry.cpp ConfigManager.cpp \
+ Connection.cpp Exception.cpp Initializable.cpp Logger.cpp LogManager.cpp \
+ ModuleManager.cpp Request.cpp RequestManager.cpp SystemBackend.cpp \
+ Tokenizer.cpp XmlPacket.cpp
libcommon_la_LIBADD = Requests/librequests.la RequestHandlers/librequesthandlers.la ../../lib/libgnu.la
-noinst_HEADERS = ActionManager.h ConfigEntry.h ConfigManager.h Configurable.h \
- Exception.h HostInfo.h Initializable.h Logger.h LoggerBase.h LogManager.h \
- ModuleManager.h RemoteLogger.h Request.h RequestHandler.h RequestManager.h \
- SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h
+noinst_HEADERS = ActionManager.h ClientConnection.h ConfigEntry.h ConfigManager.h \
+ Configurable.h Connection.h Exception.h HostInfo.h Initializable.h Logger.h \
+ LoggerBase.h LogManager.h ModuleManager.h RemoteLogger.h Request.h \
+ RequestHandler.h RequestManager.h SystemBackend.h Tokenizer.h UserInfo.h XmlPacket.h
all: all-recursive
@@ -300,15 +302,16 @@ distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ActionManager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ClientConnection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigEntry.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigManager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Connection.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exception.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Initializable.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LogManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ModuleManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Request.Plo@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestHandler.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RequestManager.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SystemBackend.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Tokenizer.Plo@am__quote@
diff --git a/src/Common/Request.h b/src/Common/Request.h
index 2c6c8d4..7048a4e 100644
--- a/src/Common/Request.h
+++ b/src/Common/Request.h
@@ -42,7 +42,7 @@ class Request : public RequestHandler {
typedef sigc::slot<void,const Request&> slot_type;
protected:
- Request(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ Request(Connection *connection, uint16_t requestId, slot_type slot)
: RequestHandler(connection, requestId), exp(Exception::NOT_FINISHED) {
finished.connect(slot);
finished.connect(sigc::hide(signalFinished().make_slot()));
diff --git a/src/Common/RequestHandler.h b/src/Common/RequestHandler.h
index f36aae5..a0922a7 100644
--- a/src/Common/RequestHandler.h
+++ b/src/Common/RequestHandler.h
@@ -20,26 +20,23 @@
#ifndef MAD_COMMON_XMLREQUESTHANDLER_H_
#define MAD_COMMON_XMLREQUESTHANDLER_H_
+#include "Connection.h"
#include "XmlPacket.h"
#include <sigc++/signal.h>
#include <stdint.h>
namespace Mad {
-
-namespace Net {
-class Connection;
-}
-
namespace Common {
+class Connection;
class RequestManager;
class RequestHandler {
private:
sigc::signal<void> finished;
- Net::Connection *connection;
+ Connection *connection;
uint16_t requestId;
// Prevent shallow copy
@@ -47,11 +44,11 @@ class RequestHandler {
RequestHandler& operator=(const RequestHandler &o);
protected:
- RequestHandler(Net::Connection *connection0, uint16_t requestId0) : connection(connection0), requestId(requestId0) {}
+ RequestHandler(Connection *connection0, uint16_t requestId0) : connection(connection0), requestId(requestId0) {}
sigc::signal<void> signalFinished() {return finished;}
- Net::Connection* getConnection() const {
+ Connection* getConnection() const {
return connection;
}
@@ -59,7 +56,9 @@ class RequestHandler {
return requestId;
}
- bool sendPacket(const XmlPacket &packet);
+ bool sendPacket(const XmlPacket &packet) {
+ return connection->sendPacket(packet, requestId);
+ }
virtual void handlePacket(const XmlPacket &packet) = 0;
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
index 031853a..9204f43 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.cpp
@@ -20,7 +20,6 @@
#include "DisconnectRequestHandler.h"
#include "../Exception.h"
#include "../Logger.h"
-#include <Net/Connection.h>
namespace Mad {
namespace Common {
diff --git a/src/Common/RequestHandlers/DisconnectRequestHandler.h b/src/Common/RequestHandlers/DisconnectRequestHandler.h
index b90c96e..05b9c50 100644
--- a/src/Common/RequestHandlers/DisconnectRequestHandler.h
+++ b/src/Common/RequestHandlers/DisconnectRequestHandler.h
@@ -31,7 +31,7 @@ class DisconnectRequestHandler : public RequestHandler {
virtual void handlePacket(const XmlPacket &packet);
public:
- DisconnectRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DisconnectRequestHandler(Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Common/RequestHandlers/FSInfoRequestHandler.h b/src/Common/RequestHandlers/FSInfoRequestHandler.h
index 6fcf524..0eda797 100644
--- a/src/Common/RequestHandlers/FSInfoRequestHandler.h
+++ b/src/Common/RequestHandlers/FSInfoRequestHandler.h
@@ -37,7 +37,7 @@ class FSInfoRequestHandler : public RequestHandler {
virtual void handlePacket(const XmlPacket &packet);
public:
- FSInfoRequestHandler(Net::Connection *connection, uint16_t requestId)
+ FSInfoRequestHandler(Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Common/RequestHandlers/StatusRequestHandler.h b/src/Common/RequestHandlers/StatusRequestHandler.h
index ddaaae4..8c7d124 100644
--- a/src/Common/RequestHandlers/StatusRequestHandler.h
+++ b/src/Common/RequestHandlers/StatusRequestHandler.h
@@ -60,7 +60,7 @@ class StatusRequestHandler : public RequestHandler {
virtual void handlePacket(const XmlPacket &packet);
public:
- StatusRequestHandler(Net::Connection *connection, uint16_t requestId)
+ StatusRequestHandler(Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId),
needUptime(true), needMemory(true), needLoad(true), sent(false),
uptime(0), idleTime(0), totalMem(0), freeMem(0), totalSwap(0), freeSwap(0),
diff --git a/src/Common/RequestManager.cpp b/src/Common/RequestManager.cpp
index 9d50865..23f620f 100644
--- a/src/Common/RequestManager.cpp
+++ b/src/Common/RequestManager.cpp
@@ -21,8 +21,6 @@
#include "RequestHandlers/DisconnectRequestHandler.h"
#include "Logger.h"
-#include <Net/Connection.h>
-
#include <sigc++/bind.h>
#include <sigc++/retype_return.h>
@@ -66,10 +64,8 @@ bool RequestManager::RequestMap::deleteRequest(uint16_t id) {
}
-void RequestManager::receiveHandler(Net::Connection *connection, const Net::Packet &packet) {
- XmlPacket xmlPacket(packet);
-
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
+void RequestManager::receiveHandler(Connection *connection, const XmlPacket &packet, uint16_t requestId) {
+ std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
if(it == requestMaps.end()) {
// TODO: Error
Logger::log(Logger::ERROR, "Received a packet from an unregistered connection.");
@@ -78,34 +74,34 @@ void RequestManager::receiveHandler(Net::Connection *connection, const Net::Pack
}
RequestMap *requestMap = it->second;
- RequestHandler *request = requestMap->findRequest(packet.getRequestId());
+ RequestHandler *request = requestMap->findRequest(requestId);
if(request) {
- request->handlePacket(xmlPacket);
+ request->handlePacket(packet);
return;
}
- std::map<std::string,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(xmlPacket.getType());
+ std::map<std::string,RequestHandlerFactory*>::iterator factoryIt = requestHandlerFactories.find(packet.getType());
if(factoryIt != requestHandlerFactories.end()) {
- request = factoryIt->second->createRequestHandler(connection, packet.getRequestId());
+ request = factoryIt->second->createRequestHandler(connection, requestId);
- requestMap->addRequest(packet.getRequestId(), request);
- request->handlePacket(xmlPacket);
+ requestMap->addRequest(requestId, request);
+ request->handlePacket(packet);
return;
}
- Logger::logf(Logger::ERROR, "Received an unexpected packet with type '%s'.", xmlPacket.getType().c_str());
+ Logger::logf(Logger::ERROR, "Received an unexpected packet with type '%s'.", packet.getType().c_str());
XmlPacket ret;
ret.setType("Error");
ret.add("ErrorCode", Exception::UNEXPECTED_PACKET);
- connection->send(ret.encode(packet.getRequestId()));
+ connection->sendPacket(ret, requestId);
}
-RequestManager::RequestMap* RequestManager::getUnusedRequestId(Net::Connection *connection, uint16_t *requestId) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
+RequestManager::RequestMap* RequestManager::getUnusedRequestId(Connection *connection, uint16_t *requestId) {
+ std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
if(it == requestMaps.end()) {
Logger::log(Logger::CRITICAL, "Trying to send a request over an unregistered connecion.");
@@ -121,14 +117,14 @@ RequestManager::RequestMap* RequestManager::getUnusedRequestId(Net::Connection *
return requestMap;
}
-void RequestManager::registerConnection(Net::Connection *connection) {
+void RequestManager::registerConnection(Connection *connection) {
requestMaps.insert(std::make_pair(connection, new RequestMap()));
- connection->signalReceive().connect(sigc::mem_fun(this, &RequestManager::receiveHandler));
+ connection->signalReceive().connect(sigc::bind<0>(sigc::mem_fun(this, &RequestManager::receiveHandler), connection));
}
-void RequestManager::unregisterConnection(Net::Connection *connection) {
- std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
+void RequestManager::unregisterConnection(Connection *connection) {
+ std::map<Connection*,RequestMap*>::iterator it = requestMaps.find(connection);
if(it != requestMaps.end()) {
delete it->second;
@@ -154,7 +150,7 @@ RequestManager::RequestManager() : core(false), lastRequestId(-1) {
RequestManager::~RequestManager() {
unregisterPacketType("Disconnect");
- for(std::map<Net::Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
+ for(std::map<Connection*,RequestMap*>::iterator it = requestMaps.begin(); it != requestMaps.end(); ++it)
delete it->second;
for(std::map<std::string,RequestHandlerFactory*>::iterator it = requestHandlerFactories.begin(); it != requestHandlerFactories.end(); ++it)
diff --git a/src/Common/RequestManager.h b/src/Common/RequestManager.h
index c38435b..82a00f6 100644
--- a/src/Common/RequestManager.h
+++ b/src/Common/RequestManager.h
@@ -31,7 +31,6 @@
namespace Mad {
namespace Net {
-class Connection;
class Packet;
}
@@ -59,20 +58,20 @@ class RequestManager {
RequestHandlerFactory() {}
public:
- virtual RequestHandler* createRequestHandler(Net::Connection *connection, int16_t requestId) = 0;
+ virtual RequestHandler* createRequestHandler(Connection *connection, int16_t requestId) = 0;
virtual ~RequestHandlerFactory() {}
};
template<class T> class SpecificRequestHandlerFactory : public RequestHandlerFactory {
public:
- virtual RequestHandler* createRequestHandler(Net::Connection *connection, int16_t requestId) {
+ virtual RequestHandler* createRequestHandler(Connection *connection, int16_t requestId) {
return new T(connection, requestId);
}
};
static RequestManager requestManager;
- std::map<Net::Connection*,RequestMap*> requestMaps;
+ std::map<Connection*,RequestMap*> requestMaps;
bool core;
uint16_t lastRequestId;
@@ -86,9 +85,9 @@ class RequestManager {
RequestManager(const RequestManager &o);
RequestManager& operator=(const RequestManager &o);
- void receiveHandler(Net::Connection *connection, const Net::Packet &packet);
+ void receiveHandler(Connection *connection, const XmlPacket &packet, uint16_t requestId);
- RequestMap* getUnusedRequestId(Net::Connection *connection, uint16_t *requestId);
+ RequestMap* getUnusedRequestId(Connection *connection, uint16_t *requestId);
bool send(Request *request);
@@ -109,8 +108,8 @@ class RequestManager {
lastRequestId |= 0x01;
}
- void registerConnection(Net::Connection *connection);
- void unregisterConnection(Net::Connection *connection);
+ void registerConnection(Connection *connection);
+ void unregisterConnection(Connection *connection);
template <class T> void registerPacketType(const std::string &type) {
requestHandlerFactories.insert(std::make_pair(type, new SpecificRequestHandlerFactory<T>()));
@@ -119,7 +118,7 @@ class RequestManager {
void unregisterPacketType(const std::string &type);
template <class T>
- bool sendRequest(Net::Connection *connection, Request::slot_type slot) {
+ bool sendRequest(Connection *connection, Request::slot_type slot) {
RequestMap *requestMap;
uint16_t requestId;
@@ -136,7 +135,7 @@ class RequestManager {
}
template <class T, typename T1>
- bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1) {
+ bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1) {
RequestMap *requestMap;
uint16_t requestId;
@@ -153,7 +152,7 @@ class RequestManager {
}
template <class T, typename T1, typename T2>
- bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2) {
+ bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2) {
RequestMap *requestMap;
uint16_t requestId;
@@ -170,7 +169,7 @@ class RequestManager {
}
template <class T, typename T1, typename T2, typename T3>
- bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3) {
+ bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3) {
RequestMap *requestMap;
uint16_t requestId;
@@ -187,7 +186,7 @@ class RequestManager {
}
template <class T, typename T1, typename T2, typename T3, typename T4>
- bool sendRequest(Net::Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3, T4 t4) {
+ bool sendRequest(Connection *connection, Request::slot_type slot, T1 t1, T2 t2, T3 t3, T4 t4) {
RequestMap *requestMap;
uint16_t requestId;
diff --git a/src/Common/Requests/DisconnectRequest.cpp b/src/Common/Requests/DisconnectRequest.cpp
index ec8719d..248f8b1 100644
--- a/src/Common/Requests/DisconnectRequest.cpp
+++ b/src/Common/Requests/DisconnectRequest.cpp
@@ -18,7 +18,6 @@
*/
#include "DisconnectRequest.h"
-#include <Net/Connection.h>
namespace Mad {
namespace Common {
diff --git a/src/Common/Requests/DisconnectRequest.h b/src/Common/Requests/DisconnectRequest.h
index 22ff16b..b4fd4db 100644
--- a/src/Common/Requests/DisconnectRequest.h
+++ b/src/Common/Requests/DisconnectRequest.h
@@ -32,7 +32,7 @@ class DisconnectRequest : public Request {
virtual void handlePacket(const XmlPacket &packet);
public:
- DisconnectRequest(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ DisconnectRequest(Connection *connection, uint16_t requestId, slot_type slot)
: Request(connection, requestId, slot) {}
};
diff --git a/src/Common/Requests/FSInfoRequest.h b/src/Common/Requests/FSInfoRequest.h
index 285f662..1db7753 100644
--- a/src/Common/Requests/FSInfoRequest.h
+++ b/src/Common/Requests/FSInfoRequest.h
@@ -28,7 +28,7 @@ namespace Requests {
class FSInfoRequest : public SimpleRequest {
public:
- FSInfoRequest(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ FSInfoRequest(Connection *connection, uint16_t requestId, slot_type slot)
: SimpleRequest(connection, requestId, slot, "FSInfo") {}
};
diff --git a/src/Common/Requests/GSSAPIAuthRequest.cpp b/src/Common/Requests/GSSAPIAuthRequest.cpp
index 07e516f..f10bf9b 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.cpp
+++ b/src/Common/Requests/GSSAPIAuthRequest.cpp
@@ -19,7 +19,6 @@
#include "GSSAPIAuthRequest.h"
#include "../Logger.h"
-#include <Net/Connection.h>
#include <cstring>
@@ -127,10 +126,11 @@ void GSSAPIAuthRequest::handlePacket(const XmlPacket &packet) {
recvBuffer.value = std::malloc(recvBuffer.length);
std::memcpy(recvBuffer.value, pkgData, recvBuffer.length);
- const gnutls_datum_t *cert = getConnection()->getPeerCertificate();
+ /*const gnutls_datum_t *cert = getConnection()->getPeerCertificate();
sendBuffer.length = cert->size;
- sendBuffer.value = cert->data;
+ sendBuffer.value = cert->data;*/
+ sendBuffer.value = getConnection()->getPeerCertificate(&sendBuffer.length);
majStat = gss_verify_mic(&minStat, gssContext, &sendBuffer, &recvBuffer, 0);
diff --git a/src/Common/Requests/GSSAPIAuthRequest.h b/src/Common/Requests/GSSAPIAuthRequest.h
index 104af0c..a4f8c43 100644
--- a/src/Common/Requests/GSSAPIAuthRequest.h
+++ b/src/Common/Requests/GSSAPIAuthRequest.h
@@ -42,7 +42,7 @@ class GSSAPIAuthRequest : public Request {
virtual void handlePacket(const XmlPacket &packet);
public:
- GSSAPIAuthRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &serviceName0)
+ GSSAPIAuthRequest(Connection *connection, uint16_t requestId, slot_type slot, const std::string &serviceName0)
: Request(connection, requestId, slot), serviceName(serviceName0), gssServiceName(GSS_C_NO_NAME), gssContext(GSS_C_NO_CONTEXT), gssContinue(true) {}
virtual ~GSSAPIAuthRequest();
};
diff --git a/src/Common/Requests/SimpleRequest.h b/src/Common/Requests/SimpleRequest.h
index ca95eca..2c3070a 100644
--- a/src/Common/Requests/SimpleRequest.h
+++ b/src/Common/Requests/SimpleRequest.h
@@ -34,7 +34,7 @@ class SimpleRequest : public Request {
virtual void sendRequest();
- SimpleRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &type0)
+ SimpleRequest(Connection *connection, uint16_t requestId, slot_type slot, const std::string &type0)
: Request(connection, requestId, slot), type(type0) {}
};
diff --git a/src/Common/Requests/StatusRequest.h b/src/Common/Requests/StatusRequest.h
index ad89ec4..0663fc4 100644
--- a/src/Common/Requests/StatusRequest.h
+++ b/src/Common/Requests/StatusRequest.h
@@ -28,7 +28,7 @@ namespace Requests {
class StatusRequest : public SimpleRequest {
public:
- StatusRequest(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ StatusRequest(Connection *connection, uint16_t requestId, slot_type slot)
: SimpleRequest(connection, requestId, slot, "GetStatus") {}
};
diff --git a/src/Common/Requests/UserListRequest.h b/src/Common/Requests/UserListRequest.h
index 69b0f05..7ab3ec7 100644
--- a/src/Common/Requests/UserListRequest.h
+++ b/src/Common/Requests/UserListRequest.h
@@ -28,7 +28,7 @@ namespace Requests {
class UserListRequest : public SimpleRequest {
public:
- UserListRequest(Net::Connection *connection, uint16_t requestId, slot_type slot)
+ UserListRequest(Connection *connection, uint16_t requestId, slot_type slot)
: SimpleRequest(connection, requestId, slot, "ListUsers") {}
};
diff --git a/src/Core/ConnectionManager.cpp b/src/Core/ConnectionManager.cpp
index 3ce52fc..3d252c2 100644
--- a/src/Core/ConnectionManager.cpp
+++ b/src/Core/ConnectionManager.cpp
@@ -45,12 +45,49 @@ namespace Core {
ConnectionManager ConnectionManager::connectionManager;
+bool ConnectionManager::Connection::send(const Net::Packet &packet) {
+ return connection->send(packet);
+}
+
+ConnectionManager::Connection::Connection(Net::ServerConnection *connection0, ConnectionType type0)
+: connection(connection0), type(type0), hostInfo(0) {
+ connection->signalReceive().connect(sigc::mem_fun(this, &Connection::receive));
+}
+
+ConnectionManager::Connection::~Connection() {
+ delete connection;
+}
+
+bool ConnectionManager::Connection::isConnected() const {
+ return connection->isConnected();
+}
+
+bool ConnectionManager::Connection::disconnect() {
+ connection->disconnect();
+
+ return true;
+}
+
+void* ConnectionManager::Connection::getCertificate(size_t *size) const {
+ const gnutls_datum_t *cert = connection->getCertificate();
+
+ *size = cert->size;
+ return cert->data;
+}
+
+void* ConnectionManager::Connection::getPeerCertificate(size_t *size) const {
+ const gnutls_datum_t *cert = connection->getPeerCertificate();
+
+ *size = cert->size;
+ return cert->data;
+}
-void ConnectionManager::updateState(const std::string &name, Common::HostInfo::State state) {
- daemonInfo[name].setState(state);
+void ConnectionManager::updateState(Common::HostInfo *hostInfo, Common::HostInfo::State state) {
+ hostInfo->setState(state);
- for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con) {
- Common::RequestManager::get()->sendRequest<Requests::DaemonStateUpdateRequest>(*con, Common::Request::slot_type(), name, state);
+ for(std::list<Connection*>::iterator con = connections.begin(); con != connections.end(); ++con) {
+ if((*con)->getConnectionType() == Connection::CLIENT)
+ Common::RequestManager::get()->sendRequest<Requests::DaemonStateUpdateRequest>(*con, Common::Request::slot_type(), hostInfo->getName(), state);
}
}
@@ -92,7 +129,6 @@ bool ConnectionManager::handleConfigEntry(const Common::ConfigEntry &entry, bool
if(entry[0].getSize() == 1) {
if(entry[1].empty()) {
daemonInfo.insert(std::make_pair(entry[0][0], Common::HostInfo(entry[0][0])));
- identifiedDaemonConnections.insert(std::make_pair<std::string,Net::ServerConnection*>(entry[0][0], 0));
return true;
}
@@ -146,11 +182,9 @@ void ConnectionManager::doInit() {
}
void ConnectionManager::doDeinit() {
- for(std::list<Net::ServerConnection*>::iterator con = daemonConnections.begin(); con != daemonConnections.end(); ++con)
+ for(std::list<Connection*>::iterator con = connections.begin(); con != connections.end(); ++con)
delete *con;
- for(std::list<Net::ServerConnection*>::iterator con = clientConnections.begin(); con != clientConnections.end(); ++con)
- delete *con;
Common::RequestManager::get()->unregisterPacketType("AuthGSSAPI");
Common::RequestManager::get()->unregisterPacketType("DaemonCommand");
@@ -166,19 +200,15 @@ void ConnectionManager::doDeinit() {
Net::Connection::deinit();
}
-void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& connections) {
- for(std::list<Net::ServerConnection*>::iterator con = connections.begin(); con != connections.end();) {
+void ConnectionManager::run() {
+ // TODO Logging
+
+ Net::FdManager::get()->run();
+
+ for(std::list<Connection*>::iterator con = connections.begin(); con != connections.end();) {
if(!(*con)->isConnected()) {
- if((*con)->isIdentified()) {
- for(std::map<std::string,Net::ServerConnection*>::iterator idCon = identifiedDaemonConnections.begin(); idCon != identifiedDaemonConnections.end(); ++idCon) {
- if(idCon->second == *con) {
- idCon->second = 0;
-
- updateState(idCon->first, Common::HostInfo::INACTIVE);
- break;
- }
- }
- }
+ if((*con)->isIdentified())
+ updateState((*con)->getHostInfo(), Common::HostInfo::INACTIVE);
Common::RequestManager::get()->unregisterConnection(*con);
delete *con;
@@ -187,69 +217,78 @@ void ConnectionManager::handleConnections(std::list<Net::ServerConnection*>& con
else
++con;
}
-}
-
-void ConnectionManager::run() {
- // TODO Logging
-
- Net::FdManager::get()->run();
-
- handleConnections(daemonConnections);
- handleConnections(clientConnections);
for(std::list<Net::Listener*>::iterator listener = listeners.begin(); listener != listeners.end(); ++listener) {
Net::ServerConnection *con;
while((con = (*listener)->getConnection()) != 0) {
- (con->isDaemonConnection() ? daemonConnections : clientConnections).push_back(con);
- Common::RequestManager::get()->registerConnection(con);
+ Connection *connection = new Connection(con,
+ con->isDaemonConnection() ? Connection::DAEMON : Connection::CLIENT);
+ connections.push_back(connection);
+ Common::RequestManager::get()->registerConnection(connection);
}
}
}
-Net::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Common::Exception&) {
- std::map<std::string,Net::ServerConnection*>::const_iterator daemon = identifiedDaemonConnections.find(name);
- if(daemon == identifiedDaemonConnections.end())
+Common::Connection* ConnectionManager::getDaemonConnection(const std::string &name) const throw (Common::Exception&) {
+ const Common::HostInfo *hostInfo;
+
+ try {
+ hostInfo = &daemonInfo.at(name);
+ }
+ catch(std::out_of_range&) {
throw Common::Exception(Common::Exception::UNKNOWN_DAEMON);
+ }
- if(!daemon->second)
- throw Common::Exception(Common::Exception::NOT_AVAILABLE);
+ if(hostInfo->getState() != Common::HostInfo::INACTIVE) {
+ for(std::list<Connection*>::const_iterator it = connections.begin(); it != connections.end(); ++it) {
+ if((*it)->getHostInfo() == hostInfo) {
+ return *it;
+ }
+ }
+ }
- return daemon->second;
+ throw(Common::Exception::NOT_AVAILABLE);
}
-std::string ConnectionManager::getDaemonName(const Net::Connection *con) const throw (Common::Exception&) {
- for(std::map<std::string,Net::ServerConnection*>::const_iterator daemon = identifiedDaemonConnections.begin(); daemon != identifiedDaemonConnections.end(); ++daemon) {
- if(daemon->second == con)
- return daemon->first;
+std::string ConnectionManager::getDaemonName(const Common::Connection *con) const throw (Common::Exception&) {
+ const Connection *connection = dynamic_cast<const Connection*>(con);
+
+ if(connection) {
+ if(connection->isIdentified()) {
+ return connection->getHostInfo()->getName();
+ }
}
throw Common::Exception(Common::Exception::UNKNOWN_DAEMON);
}
-void ConnectionManager::identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&) {
+void ConnectionManager::identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Common::Exception&) {
// TODO Logging
- if(connection->isIdentified())
- throw Common::Exception(Common::Exception::ALREADY_IDENTIFIED);
+ Connection *connection = dynamic_cast<Connection*>(con);
- std::list<Net::ServerConnection*>::iterator con = std::find(daemonConnections.begin(), daemonConnections.end(), connection);
- if(con == daemonConnections.end())
+ if(!connection || (connection->getConnectionType() != Connection::DAEMON))
throw Common::Exception(Common::Exception::INVALID_ACTION);
- std::map<std::string,Net::ServerConnection*>::iterator idCon = identifiedDaemonConnections.find(name);
- if(idCon == identifiedDaemonConnections.end()) {
+ if(connection->isIdentified())
+ throw Common::Exception(Common::Exception::ALREADY_IDENTIFIED);
+
+ if(daemonInfo.count(name) == 0)
throw Common::Exception(Common::Exception::UNKNOWN_DAEMON);
- }
- if(idCon->second) {
- idCon->second->disconnect();
- Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection.");
+ Common::HostInfo *hostInfo = &daemonInfo[name];
+
+ if(hostInfo->getState() != Common::HostInfo::INACTIVE) {
+ try {
+ getDaemonConnection(name)->disconnect();
+ Common::Logger::log(Common::Logger::WARNING, "Disconnecting old connection.");
+ }
+ catch(Common::Exception&) {}
}
- idCon->second = *con;
- updateState(idCon->first, Common::HostInfo::RUNNING);
- connection->setIdentified();
+ connection->identify(hostInfo);
+ updateState(hostInfo, Common::HostInfo::RUNNING);
Common::Logger::logf("Identified as '%s'.", name.c_str());
}
diff --git a/src/Core/ConnectionManager.h b/src/Core/ConnectionManager.h
index 4623ab6..75395ad 100644
--- a/src/Core/ConnectionManager.h
+++ b/src/Core/ConnectionManager.h
@@ -36,7 +36,6 @@ namespace Mad {
namespace Net {
class Listener;
-class Connection;
class ServerConnection;
class Packet;
}
@@ -45,6 +44,47 @@ namespace Core {
class ConnectionManager : public Common::Configurable, public Common::Initializable {
private:
+ class Connection : public Common::Connection {
+ public:
+ enum ConnectionType {
+ DAEMON, CLIENT
+ };
+
+ private:
+ Net::ServerConnection *connection;
+ ConnectionType type;
+ Common::HostInfo *hostInfo;
+
+ protected:
+ virtual bool send(const Net::Packet &packet);
+
+ public:
+ Connection(Net::ServerConnection *connection0, ConnectionType type0);
+ virtual ~Connection();
+
+ bool isConnected() const;
+
+ virtual bool disconnect();
+ virtual void* getCertificate(size_t *size) const;
+ virtual void* getPeerCertificate(size_t *size) const;
+
+ ConnectionType getConnectionType() const {
+ return type;
+ }
+
+ Common::HostInfo *getHostInfo() const {
+ return hostInfo;
+ }
+
+ bool isIdentified() const {
+ return hostInfo;
+ }
+
+ void identify(Common::HostInfo *info) {
+ hostInfo = info;
+ }
+ };
+
static ConnectionManager connectionManager;
std::string x509TrustFile, x509CrlFile, x509CertFile, x509KeyFile;
@@ -52,19 +92,15 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa
std::vector<Net::IPAddress> listenerAddresses;
std::list<Net::Listener*> listeners;
- std::list<Net::ServerConnection*> daemonConnections;
- std::list<Net::ServerConnection*> clientConnections;
+ std::list<Connection*> connections;
std::map<std::string,Common::HostInfo> daemonInfo;
- std::map<std::string,Net::ServerConnection*> identifiedDaemonConnections;
// Prevent shallow copy
ConnectionManager(const ConnectionManager &o);
ConnectionManager& operator=(const ConnectionManager &o);
- void handleConnections(std::list<Net::ServerConnection*> &connections);
-
- void updateState(const std::string &name, Common::HostInfo::State state);
+ void updateState(Common::HostInfo *hostInfo, Common::HostInfo::State state);
ConnectionManager() {}
@@ -82,10 +118,10 @@ class ConnectionManager : public Common::Configurable, public Common::Initializa
void run();
- Net::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&);
- std::string getDaemonName(const Net::Connection *con) const throw (Common::Exception&);
+ Common::Connection* getDaemonConnection(const std::string &name) const throw (Common::Exception&);
+ std::string getDaemonName(const Common::Connection *con) const throw (Common::Exception&);
- void identifyDaemonConnection(Net::Connection *connection, const std::string &name) throw (Common::Exception&);
+ void identifyDaemonConnection(Common::Connection *con, const std::string &name) throw (Common::Exception&);
std::vector<Common::HostInfo> getDaemonList() const;
};
diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp
index c9a4530..0e316bc 100644
--- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.cpp
@@ -45,7 +45,7 @@ void DaemonCommandRequestHandler::handlePacket(const Common::XmlPacket &packet)
std::string command = packet["command"];
try {
- Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]);
+ Common::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]);
Common::RequestManager::get()->sendRequest<Requests::CommandRequest>(daemonCon,
sigc::mem_fun(this, &DaemonCommandRequestHandler::requestFinished), command == "reboot");
}
diff --git a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h
index 9e089e3..aab9539 100644
--- a/src/Core/RequestHandlers/DaemonCommandRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonCommandRequestHandler.h
@@ -36,7 +36,7 @@ class DaemonCommandRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- DaemonCommandRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DaemonCommandRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp
index ae12a8e..547611c 100644
--- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.cpp
@@ -44,7 +44,7 @@ void DaemonFSInfoRequestHandler::handlePacket(const Common::XmlPacket &packet) {
// TODO Require authentication
try {
- Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]);
+ Common::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(packet["daemon"]);
Common::RequestManager::get()->sendRequest<Common::Requests::FSInfoRequest>(daemonCon,
sigc::mem_fun(this, &DaemonFSInfoRequestHandler::requestFinished));
}
diff --git a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h
index 6a70c5e..66800d8 100644
--- a/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonFSInfoRequestHandler.h
@@ -36,7 +36,7 @@ class DaemonFSInfoRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- DaemonFSInfoRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DaemonFSInfoRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/DaemonListRequestHandler.h b/src/Core/RequestHandlers/DaemonListRequestHandler.h
index 07badae..a469603 100644
--- a/src/Core/RequestHandlers/DaemonListRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonListRequestHandler.h
@@ -31,7 +31,7 @@ class DaemonListRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- DaemonListRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DaemonListRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
index 66c3aa1..a84307b 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.cpp
@@ -46,7 +46,7 @@ void DaemonStatusRequestHandler::handlePacket(const Common::XmlPacket &packet) {
std::string daemonName = packet["daemonName"];
try {
- Net::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName);
+ Common::Connection *daemonCon = ConnectionManager::get()->getDaemonConnection(daemonName);
Common::RequestManager::get()->sendRequest<Common::Requests::StatusRequest>(daemonCon,
sigc::mem_fun(this, &DaemonStatusRequestHandler::requestFinished));
}
diff --git a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
index f232649..5ef6089 100644
--- a/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
+++ b/src/Core/RequestHandlers/DaemonStatusRequestHandler.h
@@ -36,7 +36,7 @@ class DaemonStatusRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- DaemonStatusRequestHandler(Net::Connection *connection, uint16_t requestId)
+ DaemonStatusRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
index ad0a293..7c2b482 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.cpp
@@ -84,10 +84,12 @@ void GSSAPIAuthRequestHandler::handlePacket(const Common::XmlPacket &packet) {
if(!packet["binary"].isEmpty())
return;
- const gnutls_datum_t *cert = getConnection()->getCertificate();
+ /*const gnutls_datum_t *cert = getConnection()->getCertificate();
recvBuffer.length = cert->size;
- recvBuffer.value = cert->data;
+ recvBuffer.value = cert->data;*/
+
+ recvBuffer.value = getConnection()->getCertificate(&recvBuffer.length);
majStat = gss_get_mic(&minStat, gssContext, GSS_C_QOP_DEFAULT, &recvBuffer, &sendBuffer);
diff --git a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
index 06c1886..dd4d564 100644
--- a/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
+++ b/src/Core/RequestHandlers/GSSAPIAuthRequestHandler.h
@@ -37,7 +37,7 @@ class GSSAPIAuthRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- GSSAPIAuthRequestHandler(Net::Connection *connection, uint16_t requestId)
+ GSSAPIAuthRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId), gssContext(GSS_C_NO_CONTEXT), gssContinue(true), sentSignature(false) {}
};
diff --git a/src/Core/RequestHandlers/IdentifyRequestHandler.h b/src/Core/RequestHandlers/IdentifyRequestHandler.h
index 37aa74b..016f777 100644
--- a/src/Core/RequestHandlers/IdentifyRequestHandler.h
+++ b/src/Core/RequestHandlers/IdentifyRequestHandler.h
@@ -31,7 +31,7 @@ class IdentifyRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- IdentifyRequestHandler(Net::Connection *connection, uint16_t requestId)
+ IdentifyRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/LogRequestHandler.h b/src/Core/RequestHandlers/LogRequestHandler.h
index 9cf63ec..c391346 100644
--- a/src/Core/RequestHandlers/LogRequestHandler.h
+++ b/src/Core/RequestHandlers/LogRequestHandler.h
@@ -31,7 +31,7 @@ class LogRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- LogRequestHandler(Net::Connection *connection, uint16_t requestId)
+ LogRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/RequestHandlers/UserListRequestHandler.h b/src/Core/RequestHandlers/UserListRequestHandler.h
index 8eae11e..a80c451 100644
--- a/src/Core/RequestHandlers/UserListRequestHandler.h
+++ b/src/Core/RequestHandlers/UserListRequestHandler.h
@@ -38,7 +38,7 @@ class UserListRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- UserListRequestHandler(Net::Connection *connection, uint16_t requestId)
+ UserListRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Core/Requests/CommandRequest.h b/src/Core/Requests/CommandRequest.h
index 2214a29..2e4d1de 100644
--- a/src/Core/Requests/CommandRequest.h
+++ b/src/Core/Requests/CommandRequest.h
@@ -34,7 +34,7 @@ class CommandRequest : public Common::Request {
virtual void sendRequest();
public:
- CommandRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, bool reboot0)
+ CommandRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, bool reboot0)
: Common::Request(connection, requestId, slot), reboot(reboot0) {}
};
diff --git a/src/Core/Requests/DaemonStateUpdateRequest.h b/src/Core/Requests/DaemonStateUpdateRequest.h
index f310119..a1a8bb3 100644
--- a/src/Core/Requests/DaemonStateUpdateRequest.h
+++ b/src/Core/Requests/DaemonStateUpdateRequest.h
@@ -36,7 +36,7 @@ class DaemonStateUpdateRequest : public Common::Request {
virtual void sendRequest();
public:
- DaemonStateUpdateRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &name0, Common::HostInfo::State state0)
+ DaemonStateUpdateRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &name0, Common::HostInfo::State state0)
: Common::Request(connection, requestId, slot), name(name0), state(state0) {}
};
diff --git a/src/Daemon/Backends/NetworkLogger.h b/src/Daemon/Backends/NetworkLogger.h
index 8dc34b9..492fd87 100644
--- a/src/Daemon/Backends/NetworkLogger.h
+++ b/src/Daemon/Backends/NetworkLogger.h
@@ -23,7 +23,6 @@
#include <Common/Logger.h>
#include <Common/RequestManager.h>
#include <Daemon/Requests/LogRequest.h>
-#include <ctime>
namespace Mad {
namespace Daemon {
@@ -31,7 +30,7 @@ namespace Backends {
class NetworkLogger : public Common::Logger {
private:
- Net::Connection *connection;
+ Common::Connection *connection;
protected:
virtual void logMessage(Common::Logger::MessageCategory category, Common::Logger::MessageLevel level, time_t messageTimestamp, const std::string &message) {
@@ -40,7 +39,7 @@ class NetworkLogger : public Common::Logger {
}
public:
- NetworkLogger(Net::Connection *connection0) : connection(connection0) {}
+ NetworkLogger(Common::Connection *connection0) : connection(connection0) {}
};
}
diff --git a/src/Daemon/RequestHandlers/CommandRequestHandler.h b/src/Daemon/RequestHandlers/CommandRequestHandler.h
index 230a8f5..73aced0 100644
--- a/src/Daemon/RequestHandlers/CommandRequestHandler.h
+++ b/src/Daemon/RequestHandlers/CommandRequestHandler.h
@@ -35,7 +35,7 @@ class CommandRequestHandler : public Common::RequestHandler {
virtual void handlePacket(const Common::XmlPacket &packet);
public:
- CommandRequestHandler(Net::Connection *connection, uint16_t requestId)
+ CommandRequestHandler(Common::Connection *connection, uint16_t requestId)
: RequestHandler(connection, requestId) {}
};
diff --git a/src/Daemon/Requests/IdentifyRequest.h b/src/Daemon/Requests/IdentifyRequest.h
index 75ecd6e..51a30e3 100644
--- a/src/Daemon/Requests/IdentifyRequest.h
+++ b/src/Daemon/Requests/IdentifyRequest.h
@@ -35,7 +35,7 @@ class IdentifyRequest : public Common::Request {
virtual void sendRequest();
public:
- IdentifyRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, const std::string &hostname0)
+ IdentifyRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, const std::string &hostname0)
: Common::Request(connection, requestId, slot), hostname(hostname0) {}
};
diff --git a/src/Daemon/Requests/LogRequest.h b/src/Daemon/Requests/LogRequest.h
index 9e22b64..cb8a111 100644
--- a/src/Daemon/Requests/LogRequest.h
+++ b/src/Daemon/Requests/LogRequest.h
@@ -39,7 +39,7 @@ class LogRequest : public Common::Request {
virtual void sendRequest();
public:
- LogRequest(Net::Connection *connection, uint16_t requestId, slot_type slot, Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
+ LogRequest(Common::Connection *connection, uint16_t requestId, slot_type slot, Common::Logger::MessageCategory category0, Common::Logger::MessageLevel level0, time_t messageTimestamp0, const std::string &message0)
: Common::Request(connection, requestId, slot), category(category0), level(level0), messageTimestamp(messageTimestamp0), message(message0) {}
};
diff --git a/src/Net/ClientConnection.cpp b/src/Net/ClientConnection.cpp
index 75a9ad6..31c1a08 100644
--- a/src/Net/ClientConnection.cpp
+++ b/src/Net/ClientConnection.cpp
@@ -68,8 +68,6 @@ void ClientConnection::connect(const IPAddress &address, bool daemon0) throw(Com
if(peer)
delete peer;
peer = new IPAddress(address);
- authenticated = false;
- identified = false;
if(::connect(sock, peer->getSockAddr(), peer->getSockAddrLength()) < 0) {
close(sock);
diff --git a/src/Net/Connection.cpp b/src/Net/Connection.cpp
index 9b6b87b..0984f0a 100644
--- a/src/Net/Connection.cpp
+++ b/src/Net/Connection.cpp
@@ -124,7 +124,7 @@ void Connection::packetHeaderReceiveHandler(const void *data, unsigned long leng
header = *(const Packet::Data*)data;
if(header.length == 0) {
- signal(this, Packet(ntohs(header.requestId)));
+ signal(Packet(ntohs(header.requestId)));
enterReceiveLoop();
}
@@ -144,7 +144,7 @@ void Connection::packetDataReceiveHandler(const void *data, unsigned long length
return;
}
- signal(this, Packet(ntohs(header.requestId), data, length));
+ signal(Packet(ntohs(header.requestId), data, length));
enterReceiveLoop();
}
diff --git a/src/Net/Connection.h b/src/Net/Connection.h
index 0d7e6cf..695fbb8 100644
--- a/src/Net/Connection.h
+++ b/src/Net/Connection.h
@@ -54,7 +54,7 @@ class Connection {
Packet::Data header;
- sigc::signal<void,Connection*,const Packet&> signal;
+ sigc::signal<void,const Packet&> signal;
void doHandshake();
@@ -98,7 +98,6 @@ class Connection {
gnutls_certificate_credentials_t x509_cred;
IPAddress *peer;
- bool authenticated, identified;
void handshake();
@@ -110,7 +109,7 @@ class Connection {
bool enterReceiveLoop();
public:
- Connection() : state(DISCONNECTED), peer(0), authenticated(false), identified(false) {
+ Connection() : state(DISCONNECTED), peer(0) {
transR.length = transR.transmitted = 0;
transR.data = 0;
@@ -128,12 +127,6 @@ class Connection {
return (state == DISCONNECT || state == BYE);
}
- bool isAuthenticated() const {return authenticated;}
- void setAuthenticated() {authenticated = true;}
-
- bool isIdentified() const {return identified;}
- void setIdentified() {identified = true;}
-
const gnutls_datum_t* getCertificate() {
return gnutls_certificate_get_ours(session);
}
@@ -154,7 +147,7 @@ class Connection {
bool sendQueueEmpty() const {return transS.empty();}
- sigc::signal<void,Connection*,const Packet&> signalReceive() const {return signal;}
+ sigc::signal<void,const Packet&> signalReceive() const {return signal;}
static void init() {
gnutls_global_init();
diff --git a/src/mad.cpp b/src/mad.cpp
index eba4125..f0dcdf2 100644
--- a/src/mad.cpp
+++ b/src/mad.cpp
@@ -17,7 +17,7 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Net/ClientConnection.h"
+#include "Net/Connection.h"
#include "Net/FdManager.h"
#include "Net/IPAddress.h"
#include "Common/ConfigManager.h"
@@ -25,6 +25,7 @@
#include "Common/Logger.h"
#include "Common/ModuleManager.h"
#include "Common/RequestManager.h"
+#include "Common/ClientConnection.h"
#include "Common/RequestHandlers/FSInfoRequestHandler.h"
#include "Common/RequestHandlers/StatusRequestHandler.h"
#include "Daemon/Backends/NetworkLogger.h"
@@ -53,7 +54,7 @@ int main() {
Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::FSInfoRequestHandler>("FSInfo");
Common::RequestManager::get()->registerPacketType<Common::RequestHandlers::StatusRequestHandler>("GetStatus");
- Net::ClientConnection *connection = new Net::ClientConnection;
+ Common::ClientConnection *connection = new Common::ClientConnection;
try {
connection->connect(Net::IPAddress("127.0.0.1"), true);
diff --git a/src/madc.cpp b/src/madc.cpp
index ac3b3a3..51259b3 100644
--- a/src/madc.cpp
+++ b/src/madc.cpp
@@ -17,9 +17,10 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Net/ClientConnection.h"
+#include "Net/Connection.h"
#include "Net/FdManager.h"
#include "Net/IPAddress.h"
+#include "Common/ClientConnection.h"
#include "Common/ConfigManager.h"
#include "Common/LogManager.h"
#include "Common/Logger.h"
@@ -83,7 +84,7 @@ int main(int argc, char *argv[]) {
Common::ConfigManager::get()->finish();
- Net::ClientConnection *connection = new Net::ClientConnection;
+ Common::ClientConnection *connection = new Common::ClientConnection;
try {
connection->connect(Net::IPAddress(argv[1]));