Server

namespace HTTPServer
class Server

Public Functions

explicit Server()
explicit Server(const std::string &config_path)
Server(const Server&) = delete
Server &operator=(const Server&) = delete
const Port &port() const
void start()
void installSignalHandlers()
void stop()

Private Types

using UniqueSSL_CTX = std::unique_ptr<SSL_CTX, decltype(&SSL_CTX_free)>

Private Functions

template<typename Address, typename Handler>
void accept_loop(int listen_fd, std::atomic<bool> &running, Handler handler)
bool init_ssl_context()
void cleanup_ssl_context()
void dispatch_client(int client_fd)
void handle_client(SSL *ssl, const std::string &client_ip)
void handle_client(int client_fd, const std::string &client_ip)
void start_http_redirect(const Port &redirection_port)

Private Members

UniqueFd server_fd
UniqueFd redirection_server_fd
std::atomic<bool> d_running = {false}
std::unique_ptr<ThreadPool> d_thread_pool
UniqueSSL_CTX ssl_ctx = {nullptr, SSL_CTX_free}
std::unique_ptr<PerioidIdleIpCleanup> d_periodic_idle_ip_cleanup