🔨」 fix: fixed port issue and main loop issue for reasons only gods or kanel knows

This commit is contained in:
2025-05-01 12:54:09 +02:00
parent ea3bf0c4a3
commit e54c5e8323
9 changed files with 107 additions and 92 deletions

View File

@ -6,13 +6,17 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 12:20:06 by adjoly #+# #+# */
/* Updated: 2025/04/22 15:25:39 by adjoly ### ########.fr */
/* Updated: 2025/05/01 12:48:12 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
#pragma once
#include "cppeleven.hpp"
#include <config/Server.hpp>
#include <netinet/in.h>
#include <stdexcept>
#include <sys/socket.h>
namespace webserv {
namespace config {
@ -25,7 +29,14 @@ class Config {
Logger *getLogger(void) { return _log; }
std::vector<Server *> getServers(void) { return _servers; }
Server *getServer(const std::string &);
Server *getServer(size_t i) {
try {
Server *srv = _servers.at(i);
return srv;
} catch (std::out_of_range &e) {
return not_nullptr;
}
}
private:
std::vector<Server *> _servers;

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/03/19 14:11:28 by adjoly #+# #+# */
/* Updated: 2025/04/22 15:25:58 by adjoly ### ########.fr */
/* Updated: 2025/04/30 17:10:53 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -61,6 +61,7 @@ class Server {
// @brief Can be used to check if a servername is present in this config
bool isServerName(const std::string &);
// @brief Can be used to get the route correcponding
Route *whatRoute(const URL &);
protected:

View File

@ -6,7 +6,7 @@
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/04/14 14:14:39 by adjoly #+# #+# */
/* Updated: 2025/04/30 14:51:39 by adjoly ### ########.fr */
/* Updated: 2025/05/01 12:51:51 by adjoly ### ########.fr */
/* */
/* ************************************************************************** */
@ -24,7 +24,7 @@ namespace server {
class Client {
public:
Client(struct pollfd *, sockaddr_in, config::Config *);
Client(struct pollfd *, config::Server *);
Client(const Client &cpy);
virtual ~Client(void);
@ -54,12 +54,10 @@ class Client {
}
struct pollfd *_pfd;
struct sockaddr_in _client_addr;
http::ARequest *_request;
// http::Response *_response;
config::Server *_conf;
config::Route *_route;
config::Config *_Gconf;
};
} // namespace server