~singpolyma/biboumi

ref: 7b3e0e0cf3eddd3537455a3605b04a48ee663f47 biboumi/src/identd/identd_server.hpp -rw-r--r-- 1.1 KiB
7b3e0e0c — louiz’ Make botan’s policy configurable from a file 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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;
};