summaryrefslogtreecommitdiff
path: root/src/identd/identd_server.hpp
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2017-06-24 09:21:37 +0200
committerJonas Smedegaard <dr@jones.dk>2017-06-24 09:21:37 +0200
commit3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb (patch)
tree9a5684babcd16d302fbe59c56b6045660ad62488 /src/identd/identd_server.hpp
parentf9cee98aacd6aea8ccb7f5677b4ff1e1e234e4d1 (diff)
parentc21cbbf9667991d2b928562a9c199e625d3f9bba (diff)
downloadbiboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.gz
biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.bz2
biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.tar.xz
biboumi-3d39f109ba8ea7ae9778c58bd1665b9e8e0f45cb.zip
Updated version 5.0 from 'upstream/5.0'
with Debian dir 2ae31d03ffb1d79153a692af23c7b2b097cc4b2b
Diffstat (limited to 'src/identd/identd_server.hpp')
-rw-r--r--src/identd/identd_server.hpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/identd/identd_server.hpp b/src/identd/identd_server.hpp
new file mode 100644
index 0000000..b1c8ec8
--- /dev/null
+++ b/src/identd/identd_server.hpp
@@ -0,0 +1,39 @@
+#pragma once
+
+#include <network/tcp_server_socket.hpp>
+#include <identd/identd_socket.hpp>
+#include <algorithm>
+#include <unistd.h>
+
+class BiboumiComponent;
+
+class IdentdServer: public TcpSocketServer<IdentdSocket>
+{
+ public:
+ IdentdServer(const BiboumiComponent& biboumi_component, std::shared_ptr<Poller>& poller, const uint16_t port):
+ TcpSocketServer<IdentdSocket>(poller, port),
+ biboumi_component(biboumi_component)
+ {}
+
+ const BiboumiComponent& get_biboumi_component() const
+ {
+ return this->biboumi_component;
+ }
+ void shutdown()
+ {
+ if (this->poller->is_managing_socket(this->socket))
+ this->poller->remove_socket_handler(this->socket);
+ ::close(this->socket);
+ }
+ void clean()
+ {
+ this->sockets.erase(std::remove_if(this->sockets.begin(), this->sockets.end(),
+ [](const std::unique_ptr<IdentdSocket>& socket)
+ {
+ return socket->get_socket() == -1;
+ }),
+ this->sockets.end());
+ }
+ private:
+ const BiboumiComponent& biboumi_component;
+};