41 #include "../Helper/DateTime.hpp" 42 #include "../Helper/Portability/compiler.h" 43 #include "../Helper/Portability/getch.h" 44 #include "../Helper/Versions.hpp" 45 #include "../Struct/DatabaseSettings.hpp" 46 #include "../Struct/NetworkSettings.hpp" 47 #include "../Struct/ServerSettings.hpp" 55 #include <string_view> 61 using std::string_view_literals::operator
""sv;
74 inline constexpr
auto pwPrompt1{
"Enter password for "sv};
86 inline constexpr
auto doneMsg{
"[DONE]"sv};
102 inline constexpr
auto year{__DATE__ + 7};
105 inline constexpr
auto descName{
"crawlserv++ Command-and-Control Server"sv};
118 "This program is free software: you can redistribute it and/or modify\n" 119 "it under the terms of the GNU General Public License as published by\n" 120 "the Free Software Foundation, either version 3 of the License, or\n" 121 "(at your option) any later version.\n\n" 122 "This program is distributed in the hope that it will be useful,\n" 123 "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" 124 "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" 125 "GNU General Public License for more details.\n\n" 126 "You should have received a copy of the GNU General Public License\n" 127 "along with this program. If not, see <https://www.gnu.org/licenses/>."sv
134 inline constexpr
auto descUsage{
"USAGE: crawlserv <config_file> or crawlserv -v"};
161 explicit App(
const std::vector<std::string>& args) noexcept;
192 std::atomic<bool> running{
true};
193 std::unique_ptr<Server> server;
194 bool showVersionsOnly{
false};
197 void shutdown(std::sig_atomic_t
signal);
200 bool getPassword(DatabaseSettings& dbSettings);
201 bool inputLoop(DatabaseSettings& dbSettings,
bool& isCancelTo);
204 static void outputHeader(
bool showLibraryVersions);
205 static void checkArgumentNumber(
int args);
206 static void loadConfig(
207 const std::string& fileName,
209 DatabaseSettings& dbSettings,
constexpr auto descVer
The beginning of the version string.
Definition: App.hpp:108
constexpr auto year
The current year.
Definition: App.hpp:102
constexpr auto descName
The name of the application.
Definition: App.hpp:105
App(const std::vector< std::string > &args) noexcept
Constructor.
Definition: App.cpp:54
constexpr auto descUsing
The string before the used libraries.
Definition: App.hpp:131
constexpr auto argsRequired
Number of arguments required by the application.
Definition: App.hpp:71
Network settings containing the default proxy as well as host, port, and password of the TOR control ...
Definition: NetworkSettings.hpp:49
constexpr auto pwPrompt3
Third part of the password prompt.
Definition: App.hpp:80
constexpr auto pwPrompt4
Fourth part of the password prompt.
Definition: App.hpp:83
static void signal(int signalNumber)
Static signal handler.
Definition: SignalHandler.cpp:75
constexpr auto descCopyrightHead
The beginning of the copyright string.
Definition: App.hpp:111
constexpr auto pwPrompt1
First part of the password prompt.
Definition: App.hpp:74
Server settings containing its port, as well as allowed clients, origins, and actions.
Definition: ServerSettings.hpp:51
int run() noexcept
Runs the application.
Definition: App.cpp:150
constexpr auto descCopyrightTail
The actual copyrigt.
Definition: App.hpp:114
App & operator=(App &)=delete
Deleted copy assignment operator.
constexpr auto inputEsc
Code for the Escape key.
Definition: App.hpp:98
constexpr auto doneMsg
Message when done with the password input.
Definition: App.hpp:86
Database settings containing its host, port, user, password, schema, and compression.
Definition: DatabaseSettings.hpp:48
virtual ~App()
Destructor waiting for active threads before cleaning up the application.
Definition: App.cpp:104
constexpr auto descUsage
The usage string for the command line.
Definition: App.hpp:134
constexpr auto pwPrompt2
Second part of the password prompt.
Definition: App.hpp:77
Main application.
Definition: App.hpp:151
constexpr auto descLicense
The text of the license.
Definition: App.hpp:117
Definition: SignalHandler.hpp:38
Namespace for the main classes of the program.
Definition: App.cpp:34
constexpr auto inputEof
Code for the CTRL+C keys or the end of the file.
Definition: App.hpp:92
constexpr auto inputBackspace
Code for the backspace key.
Definition: App.hpp:89
constexpr auto inputEtx
Code for the CTRL+C keys or the end of the text.
Definition: App.hpp:95