// Copyright (C) 2024 Simon Quigley // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . #ifndef WEB_SERVER_H #define WEB_SERVER_H #include "ci_database_objs.h" #include "task_queue.h" #include #include #include #include #include #include #include #include class WebServer : public QObject { Q_OBJECT public: explicit WebServer(QObject *parent = nullptr); bool start_server(quint16 port); private: [[nodiscard]] std::map parse_query_parameters(const QString &query); [[nodiscard]] bool validate_token(const QString& token); [[nodiscard]] QHttpServerResponse verify_session_token(const QHttpServerRequest &request, const QHttpHeaders &headers); void load_tokens(QSqlDatabase& p_db); QHttpServer http_server_; QSslServer ssl_server_; std::unique_ptr task_queue; std::jthread expire_tokens_thread_; std::jthread process_sources_thread_; std::jthread process_binaries_thread_; QMap _in_progress_tokens; QMap _active_tokens; QMap _token_person; }; #endif // WEB_SERVER_H