Webdar 1.0.0
Web user interface to libdar
server.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 SERVER_HPP
25#define SERVER_HPP
26
27#include "my_config.h"
28
29 // C++ system header files
30#include <list>
31#include <libthreadar/libthreadar.hpp>
32
33 // webdar headers
34#include "parser.hpp"
35#include "central_report.hpp"
36#include "session.hpp"
37#include "authentication.hpp"
38#include "choose.hpp"
39#include "reference.hpp"
40
42
46
52
53class server: public libthreadar::thread_signal,
54 public reference // this inheritance is used to notify server_pool objects
55{
56public:
57 server(const std::shared_ptr<central_report> & creport,
58 const std::shared_ptr<const authentication> & auth,
59 std::unique_ptr<proto_connexion> & source);
60 server(const server & ref) = delete;
61 server(server && ref) noexcept = delete;
62 server & operator = (const server & ref) = delete;
63 server & operator = (server && ref) noexcept = delete;
64 ~server() { cancel(); join(); };
65
67 void release_session() { can_keep_session = false; }; // no need of mutex here, several concurrent call will lead to the same result.
68
69
71 static void force_disconnection_at_end_of_session(bool val) { default_basic_auth = ! val; };
72
73
74protected:
75
77 virtual void inherited_run() override;
78
79 // no need to override thread::signaled_inherited_cancel();
80
81private:
82
83 enum auth_consideration
84 {
85 ignore_auth_redir,
86 ignore_auth_steady,
87 no_ignore
88 };
89
90 parser src;
91 std::shared_ptr<central_report> rep;
92 std::shared_ptr<const authentication> authsrc;
93 bool can_keep_session;
94 session* locked_session;
95 auth_consideration ignore_auth;
96
97 void end_all_peers();
98
99 static bool default_basic_auth;
100
101};
102
103#endif
parser class is given a connection object and format the incoming byte flow in structured request obj...
Definition: parser.hpp:42
class reference gives a mean to link objects by a peering method
Definition: reference.hpp:47
class server for TCP session management
Definition: server.hpp:55
static void force_disconnection_at_end_of_session(bool val)
wether to emulate user logout while using basic authentication (see also class html_disconnect)
Definition: server.hpp:71
virtual void inherited_run() override
inherited from libthreadar::thread
Definition: server.cpp:79
void release_session()
used by another server to ask this object to release the session it uses
Definition: server.hpp:67
class session - holds information about a current user session
Definition: session.hpp:51