2023-12-10 23:23:15 +00:00
|
|
|
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <string>
|
|
|
|
#include <sstream>
|
|
|
|
#include <optional>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <fcgiapp.h>
|
|
|
|
#include <fcgio.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2023-12-20 22:42:13 +00:00
|
|
|
#include <argon2.h>
|
2023-11-23 19:57:32 +00:00
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
#include "request/request.h"
|
|
|
|
#include "response/response.h"
|
2023-11-23 19:57:32 +00:00
|
|
|
#include "router.h"
|
2023-12-07 20:32:43 +00:00
|
|
|
#include "database/dbinterface.h"
|
2023-12-11 23:29:55 +00:00
|
|
|
#include "utils/helpers.h"
|
|
|
|
#include "config.h"
|
2023-11-21 22:19:08 +00:00
|
|
|
|
|
|
|
class Server {
|
|
|
|
public:
|
|
|
|
Server();
|
|
|
|
~Server();
|
|
|
|
|
|
|
|
void run(int socketDescriptor);
|
|
|
|
|
2023-12-20 22:42:13 +00:00
|
|
|
unsigned int registerAccount(const std::string& login, const std::string& password);
|
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
private:
|
|
|
|
void handleRequest(std::unique_ptr<Request> request);
|
2023-12-20 22:42:13 +00:00
|
|
|
static std::string generateRandomString(std::size_t length);
|
2023-11-23 19:57:32 +00:00
|
|
|
|
2023-11-21 22:19:08 +00:00
|
|
|
private:
|
|
|
|
bool terminating;
|
|
|
|
uint64_t requestCount;
|
|
|
|
std::optional<std::string> serverName;
|
2023-11-23 19:57:32 +00:00
|
|
|
Router router;
|
2023-12-07 20:32:43 +00:00
|
|
|
std::unique_ptr<DBInterface> db;
|
2023-11-21 22:19:08 +00:00
|
|
|
};
|