mirror of
https://github.com/Ladebeze66/ft_irc.git
synced 2026-11-09 13:17:13 +01:00
test
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 18:09:05 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/11 13:30:49 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:39:51 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -34,6 +34,7 @@ class Server;
|
||||
class Client;
|
||||
class Channel;
|
||||
class BotFilter;
|
||||
class KickHandler;
|
||||
class AdditionalCommands
|
||||
{
|
||||
private:
|
||||
@@ -41,6 +42,7 @@ class AdditionalCommands
|
||||
|
||||
public:
|
||||
AdditionalCommands(Server *server);
|
||||
~AdditionalCommands();
|
||||
void processCommand(Client *client, const std::string &command);
|
||||
void broadcastChannelList(Client *client, Server *server);
|
||||
void handlePartCommand(Server *server, Client *client, const std::string &command);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/06 11:44:44 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/10 14:46:42 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:02:00 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -32,6 +32,7 @@ class BotFilter
|
||||
{
|
||||
public:
|
||||
BotFilter(Server* server);
|
||||
~BotFilter();
|
||||
void loadBadWords(const std::string& fileName);
|
||||
bool checkMessage(Client* client, Channel* channel, const std::string& message);
|
||||
void warnClient(Client* client, Channel* channel);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:41:35 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 21:03:34 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:02:31 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -29,54 +29,54 @@ class Client;
|
||||
class Channel
|
||||
{
|
||||
public:
|
||||
Channel(const std::string &name);
|
||||
~Channel();
|
||||
Channel(const std::string &name);
|
||||
~Channel();
|
||||
|
||||
const std::string &getName() const;
|
||||
void addClient(Client *client);
|
||||
void removeClient(Client *client);
|
||||
bool isEmpty() const;
|
||||
const std::vector<Client *> &getClients() const;
|
||||
void addOperator(Client *client);
|
||||
bool isOperator(Client *client) const;
|
||||
void removeOperator(Client *client);
|
||||
bool hasClient(Client *client) const;
|
||||
void broadcast(const std::string &message, Client *_client, Server *_server);
|
||||
bool isBanned(Client *client) const;
|
||||
void banClient(Client *client, Channel *channel);
|
||||
bool isFull() const;
|
||||
bool isInviteOnly() const;
|
||||
bool isInvited(Client *client) const;
|
||||
bool checkKey(const std::string &key) const;
|
||||
const std::string &getTopic() const;
|
||||
const std::string &getTopicSetter() const;
|
||||
time_t getTopicTime() const;
|
||||
void setTopic(const std::string &topic, const std::string &setter);
|
||||
std::string getKey();
|
||||
const std::string &getName() const;
|
||||
void addClient(Client *client);
|
||||
void removeClient(Client *client);
|
||||
bool isEmpty() const;
|
||||
const std::vector<Client *> &getClients() const;
|
||||
void addOperator(Client *client);
|
||||
bool isOperator(Client *client) const;
|
||||
void removeOperator(Client *client);
|
||||
bool hasClient(Client *client) const;
|
||||
void broadcast(const std::string &message, Client *_client, Server *_server);
|
||||
bool isBanned(Client *client) const;
|
||||
void banClient(Client *client, Channel *channel);
|
||||
bool isFull() const;
|
||||
bool isInviteOnly() const;
|
||||
bool isInvited(Client *client) const;
|
||||
bool checkKey(const std::string &key) const;
|
||||
const std::string &getTopic() const;
|
||||
const std::string &getTopicSetter() const;
|
||||
time_t getTopicTime() const;
|
||||
void setTopic(const std::string &topic, const std::string &setter);
|
||||
std::string getKey();
|
||||
|
||||
void setClientLimit(size_t limit);
|
||||
size_t getClientLimit() const;
|
||||
void setInviteOnly(bool inviteOnly);
|
||||
void setKey(const std::string &key);
|
||||
void setTopicProtection(bool protection);
|
||||
std::string getModes() const;
|
||||
bool getTopicProtection() const;
|
||||
void addInvitedClient(Client* client);
|
||||
void setClientLimit(size_t limit);
|
||||
size_t getClientLimit() const;
|
||||
void setInviteOnly(bool inviteOnly);
|
||||
void setKey(const std::string &key);
|
||||
void setTopicProtection(bool protection);
|
||||
std::string getModes() const;
|
||||
bool getTopicProtection() const;
|
||||
void addInvitedClient(Client* client);
|
||||
|
||||
private:
|
||||
Server *_server;
|
||||
std::string _name;
|
||||
std::vector<Client *> _clients;
|
||||
std::vector<Client *> _operators;
|
||||
std::set<int> _bannedClients;
|
||||
std::set<Client *> _invitedClients;
|
||||
std::string _key;
|
||||
std::string _topic;
|
||||
std::string _topicSetter;
|
||||
time_t _topicTime;
|
||||
size_t _clientLimit;
|
||||
bool _inviteOnly;
|
||||
bool _topicProtection;
|
||||
std::string _name;
|
||||
std::vector<Client *> _clients;
|
||||
std::vector<Client *> _operators;
|
||||
std::set<int> _bannedClients;
|
||||
std::set<Client *> _invitedClients;
|
||||
std::string _key;
|
||||
std::string _topic;
|
||||
std::string _topicSetter;
|
||||
time_t _topicTime;
|
||||
size_t _clientLimit;
|
||||
bool _inviteOnly;
|
||||
bool _topicProtection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 19:59:39 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 12:58:08 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -15,11 +15,13 @@
|
||||
|
||||
#include <string>
|
||||
#include <set>
|
||||
#include <cstring>
|
||||
|
||||
class Client
|
||||
{
|
||||
public:
|
||||
Client(int fd, const std::string &nickname, const std::string &user, const std::string &host, const std::string &password, const std::string &realname);
|
||||
~Client();
|
||||
|
||||
int getFd() const;
|
||||
const std::string &getNickname() const;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:30:07 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/06 13:01:05 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:03:49 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -43,6 +43,7 @@ class ClientManager
|
||||
{
|
||||
public:
|
||||
ClientManager(Server *server);
|
||||
~ClientManager();
|
||||
void acceptClient();
|
||||
void handleClientNext(int client_fd, char * buffer, int bytes_received);
|
||||
void handleClient(int client_fd);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 18:14:12 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 18:47:51 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:38:19 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "Join.hpp"
|
||||
#include "Welcome.hpp"
|
||||
#include "ModeHandler.hpp"
|
||||
#include "Join.hpp"
|
||||
#include "Welcome.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
@@ -34,6 +36,8 @@ class Channel;
|
||||
class WhoHandler;
|
||||
class AdditionalCommands;
|
||||
class ModeHandler;
|
||||
class JoinHandler;
|
||||
class WelcomeHandler;
|
||||
|
||||
class CommandHandler
|
||||
{
|
||||
@@ -41,10 +45,12 @@ private:
|
||||
Server *_server;
|
||||
AdditionalCommands *_additionalCommands;
|
||||
ModeHandler *_modeHandler;
|
||||
|
||||
JoinHandler *_joinHandler;
|
||||
WelcomeHandler *_welcomeHandler;
|
||||
|
||||
public:
|
||||
CommandHandler(Server *server);
|
||||
~CommandHandler();
|
||||
bool isValidNickname(const std::string& nickname);
|
||||
bool isNicknameInUse(const std::string& nickname);
|
||||
void handleNick(Client* client, const std::vector<std::string>& tokens);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/30 13:01:50 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 18:51:00 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:05:09 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -31,6 +31,7 @@ class InviteHandler
|
||||
{
|
||||
public:
|
||||
InviteHandler(Server* server);
|
||||
~InviteHandler();
|
||||
void handleInviteCommand(Client* client, const std::string& command);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:51:08 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/11 13:50:53 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:31:09 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "Channel.hpp"
|
||||
#include "RPL.hpp"
|
||||
#include "Utils.hpp"
|
||||
#include "Server.hpp"
|
||||
#include "Channel.hpp"
|
||||
#include "Client.hpp"
|
||||
#include "AdditionalCommands.hpp"
|
||||
@@ -32,9 +31,14 @@
|
||||
class JoinHandler
|
||||
{
|
||||
public:
|
||||
JoinHandler(Server *server);
|
||||
~JoinHandler();
|
||||
void handleJoinCommand(Client *client, const std::string &channelName, Server *server);
|
||||
void sendJoinSuccess(Client *client, Channel *channel, Server *server);
|
||||
std::string getUsersList(Channel *channel);
|
||||
|
||||
private:
|
||||
Server *_server;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/06/01 16:59:42 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 18:51:26 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:10:14 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -26,6 +26,7 @@ class KickHandler
|
||||
{
|
||||
public:
|
||||
KickHandler(Server* server);
|
||||
~KickHandler();
|
||||
void handleKickCommand(Client* client, const std::string& command);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/30 11:12:57 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/08 18:53:15 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:10:55 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -33,6 +33,7 @@ class ModeHandler
|
||||
{
|
||||
public:
|
||||
ModeHandler(Server* server);
|
||||
~ModeHandler();
|
||||
void handleModeCommand(Client* client, const std::string& command);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/15 12:15:13 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/11 13:33:28 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 12:58:02 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -23,6 +23,8 @@
|
||||
#include "ModeHandler.hpp"
|
||||
#include "TopicHandler.hpp"
|
||||
#include "BotFilter.hpp"
|
||||
#include "Join.hpp"
|
||||
#include "Welcome.hpp"
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
@@ -36,6 +38,8 @@
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <poll.h>
|
||||
#include <csignal>
|
||||
|
||||
|
||||
class Client;
|
||||
class Channel;
|
||||
@@ -45,6 +49,8 @@ class AdditionalCommands;
|
||||
class ModeHandler;
|
||||
class TopicHandler;
|
||||
class BotFilter;
|
||||
class JoinHandler;
|
||||
class WelcomeHandler;
|
||||
|
||||
class Server
|
||||
{
|
||||
@@ -79,6 +85,10 @@ class Server
|
||||
TopicHandler *_topicHandler;
|
||||
BotFilter *_botFilter;
|
||||
AdditionalCommands *_additionalCommands;
|
||||
JoinHandler *_joinHandler;
|
||||
WelcomeHandler *_welcomeHandler;
|
||||
static Server *instance;
|
||||
static void signalHandler(int signum);
|
||||
|
||||
friend class ClientManager;
|
||||
friend class CommandHandler;
|
||||
@@ -88,6 +98,7 @@ class Server
|
||||
private:
|
||||
void initServer();
|
||||
void handleServerCommands();
|
||||
bool bool_exit;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/30 17:04:33 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 19:02:10 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:11:49 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -26,6 +26,7 @@ class TopicHandler
|
||||
{
|
||||
public:
|
||||
TopicHandler(Server* server);
|
||||
~TopicHandler();
|
||||
void handleTopicCommand(Client* client, const std::string& command);
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/21 19:53:17 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 19:02:40 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:13:27 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -22,8 +22,13 @@
|
||||
class WelcomeHandler
|
||||
{
|
||||
public:
|
||||
WelcomeHandler(Server *server);
|
||||
~WelcomeHandler();
|
||||
void sendWelcomeMessages(Client *client, Server *server);
|
||||
void sendMotd(Client *client, Server *server);
|
||||
|
||||
private:
|
||||
Server *_server;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/* By: fgras-ca <fgras-ca@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/05/17 16:08:48 by fgras-ca #+# #+# */
|
||||
/* Updated: 2024/06/01 19:03:06 by fgras-ca ### ########.fr */
|
||||
/* Updated: 2024/06/12 11:14:47 by fgras-ca ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
@@ -27,6 +27,7 @@ class WhoHandler
|
||||
{
|
||||
public:
|
||||
WhoHandler(Server *server);
|
||||
~WhoHandler();
|
||||
void handleWhoCommand(Client *client, const std::string &command);
|
||||
void handleWhoisCommand(Client *client, const std::string &command);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user