Webdar 1.0.0
Web user interface to libdar
listener.hpp
1/*********************************************************************/
2// webdar - a web server and interface program to libdar
3// Copyright (C) 2013-2025 Denis Corbin
4//
5// This file is part of Webdar
6//
7// Webdar is free software: you can redistribute it and/or modify
8// it under the terms of the GNU General Public License as published by
9// the Free Software Foundation, either version 3 of the License, or
10// (at your option) any later version.
11//
12// Webdar is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with Webdar. If not, see <http://www.gnu.org/licenses/>
19//
20//----
21// to contact the author: dar.linux@free.fr
22/*********************************************************************/
23
24#ifndef LISTENER_HPP
25#define LISTENER_HPP
26
27#include "my_config.h"
28
29 // C++ system header files
30#include <libthreadar/libthreadar.hpp>
31#include <memory>
32
33 // webdar headers
34#include "central_report.hpp"
35#include "exceptions.hpp"
36#include "authentication.hpp"
37#include "ssl_context.hpp"
38#include "server_pool.hpp"
39
41
46
47
48class listener : public libthreadar::thread_signal
49{
50public:
51 listener(const std::shared_ptr<central_report> & log,
52 const std::shared_ptr<const authentication> & auth,
53 std::unique_ptr<ssl_context> & ciphering,
54 std::shared_ptr<server_pool> & pool,
55 unsigned int port
56 );
57 listener(const std::shared_ptr<central_report> & log,
58 const std::shared_ptr<const authentication> & auth,
59 std::unique_ptr<ssl_context> & ciphering,
60 std::shared_ptr<server_pool> & pool,
61 const std::string & ip,
62 unsigned int port
63 );
64 listener(const listener & ref) = delete;
65 listener(listener && ref) noexcept = delete;
66 listener & operator = (const listener & ref) = delete;
67 listener & operator = (listener && ref) noexcept = delete;
68 ~listener() { close(sockfd); cancel(); join(); };
69
70protected:
71 // inherited from libthreadar::thread;
72 virtual void inherited_run() override;
73
74 // no need to override thread::signaled_inherited_cancel()
75 // we rely on the cancellation_checkpoint() mechanism
76 // in inherited_run()
77
78private:
79 std::shared_ptr<central_report> rep;
80 std::shared_ptr<const authentication> src;
81 int sockfd;
82 int famille;
83 std::string l_ip;
84 std::string l_port;
85 std::unique_ptr<ssl_context> ssl_ctx;
86 std::shared_ptr<server_pool> srv;
87
88 void set_sockfd(int domain);
89 void init(const std::shared_ptr<central_report> & log,
90 const std::shared_ptr<const authentication> & auth,
91 std::unique_ptr<ssl_context> & ciphering,
92 std::shared_ptr<server_pool> & pool,
93 const std::string & ip,
94 unsigned int port);
95};
96
97
98#endif
class listener
Definition: listener.hpp:49
listener(const std::shared_ptr< central_report > &log, const std::shared_ptr< const authentication > &auth, std::unique_ptr< ssl_context > &ciphering, std::shared_ptr< server_pool > &pool, unsigned int port)
Definition: listener.cpp:86