IRC Server 42 Group Project - SUBJECT
This project involves developing an IRC server in C++ 98, designed to handle multiple clients simultaneously while respecting the IRC protocol standards. The goal is to implement a lightweight, efficient, and modular server with robust error handling and non-blocking operations.
- Develop an IRC server running on TCP/IP.
- Support multiple simultaneous clients without blocking.
- Provide essential IRC functionalities, such as authentication, private messaging, and channel management.
- Ensure compliance with a reference IRC client (
irssihere)
Execution :
./ircserv <port> <password>port: Port number for incoming connections.password: Password required for user authentication.
- C++ 98 standard only (no C++11 or later features).
- Non-blocking I/O operations.
- Only one call to
poll()or equivalent (select()here). - No forking or multi-threading.
socket,close,setsockopt,bind,connect,listen,accept...- Full list here.
- Client Authentication using a password.
- Handling Multiple Clients concurrently.
- Message Parsing and Routing compliant with the IRC protocol.
- Proper Error Handling to avoid crashes and connection failures.
- Connection Commands:
PASS,NICK,USER - Messaging:
PRIVMSG - Channel Management:
JOIN,PART,TOPIC,MODE,INVITE,KICK - Operator Commands: Assigning and managing user privileges.
+i(Invite-only channels)+t(Only operators can change the topic)+k(Password-protected channels)+o(Grant/revoke operator status)+l(User limit in a channel)
- Efficient message broadcasting using a select-based non-blocking event loop.
- Packet fragmentation handling to support broken or delayed messages.
βββ assets
β βββ quotes.txt
βββ incs
β βββ bot
β β βββ Bot.hpp
β βββ config
β β βββ bot_config.hpp
β β βββ colors.hpp
β β βββ commands.hpp
β β βββ irc_config.hpp
β β βββ irc_replies.hpp
β β βββ server_libs.hpp
β β βββ server_messages.hpp
β βββ server
β β βββ Channel.hpp
β β βββ Client.hpp
β β βββ Command.hpp
β β βββ FileData.hpp
β β βββ Server.hpp
β βββ utils
β βββ IrcHelper.hpp
β βββ MessageBuilder.hpp
β βββ Utils.hpp
βββ srcs
β βββ bot
β β βββ Bot_Command.cpp
β β βββ Bot_Message.cpp
β β βββ Bot_Parser.cpp
β β βββ Bot_Register.cpp
β β βββ Bot.cpp
β β βββ BotMain.cpp
β βββ server
β β βββ channels
β β β βββ Channel_Actions.cpp
β β β βββ Channel_Attributes.cpp
β β β βββ Channel.cpp
β β βββ clients
β β β βββ Client_Actions.cpp
β β β βββ Client_Attributes.cpp
β β β βββ Client.cpp
β β βββ commands
β β β βββ Command_Channel.cpp
β β β βββ Command_File.cpp
β β β βββ Command_Log.cpp
β β β βββ Command_Message.cpp
β β β βββ Command_Mode.cpp
β β β βββ Command_Register.cpp
β β β βββ Command.cpp
β β βββ core
β β β βββ Server_Clients.cpp
β β β βββ Server_Infos.cpp
β β β βββ Server_Loop.cpp
β β β βββ Server.cpp
β β βββ ServerMain.cpp
β βββ utils
β βββ IrcHelper.cpp
β βββ MessageBuilder.cpp
β βββ Utils.cpp
βββ Makefile
βββ README.md
1. Object-Oriented Design πΌ
ServerClass: Manages network connections and client sessions.ClientClass: Represents an IRC user with its state and actions.ChannelClass: Handles channel-specific logic and member management.CommandClass: Parses and executes IRC commands.BotClass (Bonus): Implements additional interactive features.
2. Non-Blocking Event Handling π
- File descriptor management using
select()for handling multiple clients concurrently. - Setting sockets to non-blocking mode with
fcntl():
fcntl(fd, F_SETFL, O_NONBLOCK);3. Error Handling & Debugging
- Try-catch blocks to prevent crashes.
Bot execution :
./ircbotThe bot operates independently from the server and is treated like a standard IRC client. Upon execution, it automatically connects to the server by retrieving necessary information from the .env file, such as the server password. This ensures that the bot connects seamlessly to the server without needing manual configuration each time.
Interactive commands available both in channels and private messages with the bot:
!funfact: Returns a random tech-related fun fact.!age <YYYY-MM-DD>: Calculates and displays the user's exact age in years, months, and days.!time: Displays the current time.
- Direct peer-to-peer file sharing between users is implemented correctly for
irssi, as required by the assignment, using the DCC SEND protocol. - For
Netcat, we opted for a local file transfer approach using environment variables instead of a full DCC implementation. This allows basic file transmission but does not strictly follow the DCC protocol as defined for IRC clients.
- Detailed event logs for debugging and server management.
- Real-time monitoring of connections and messages.
To compile both ircserv and ircbot, simply run:
make- The compilation process first builds the shared library containing common utilities before linking it to each executable.
You can also compile the server and bot separately using:
make server
make bot To speed up compilation on multi-core systems, you can use:
make -jFor debugging purposes, use:
make debug- This compiles the project with
-g3 -DDEBUGflags for enhanced debugging capabilities.
make clean # Removes object files
make fclean # Removes binaries and object files
make re # Cleans and recompiles everythingIf you have any issues, refer to irc.connect.help.md
./ircserv 6667 "my_password"nc 127.0.0.1 6667- Authentication commands π:
PASS pass_serverNICK test_userUSER test_user 0 * :Real Name- Packet framentation test with
CTRL+D:
com^Dman^Ddirssi -c 127.0.0.1 -p 6667 -w "my_password"- Test commands like:
/join #channel/msg user Hello!/msg #channel Hello!/kick user