An Internet Relay Chat (IRC) server implementation project developed as part of the 42 school curriculum. This project aims to create a functional IRC server that follows the IRC protocol, enhancing understanding of network programming, socket communication, and server-client architecture.
- Installation
- Usage
- Features
- IRC Commands
- Program Flow
- Module Division and TODO List
- Contributing
- License
git clone https://github.com/Panesico/ft_irc.git
cd ft_irc
makeTo run the IRC server:
./ircserv <port> <password>Where:
<port>is the port number on which your IRC server will listen for incoming connections<password>is the connection password
- TCP socket programming
- Client-server communication
- Multiple client handling
- Channel management
- User authentication
- Message routing between clients and channels
- Implementation of IRC commands
Bonus features (if implemented):
- File transfer
- Bot integration
- NICK: Set or change nickname
- USER: Set username, hostname, and realname
- JOIN: Join a channel
- MSG: Send a private message to a user or channel
- QUIT: Disconnect from the server
- KICK: Eject a client from the channel
- INVITE: Invite a client to a channel
- TOPIC: Change or view the channel topic
- MODE: Change the channel’s mode
- i: Set/remove Invite-only channel
- t: Set/remove the restrictions of the TOPIC command to channel operators
- k: Set/remove the channel key (password)
- o: Give/take channel operator privilege
- l: Set/remove the user limit to the channel
Usage examples:
/NICK newNickname
/JOIN #channel
/MSG #channel :Hello, everyone!
/PART #channel
/QUIT :Goodbye!
Here's a high-level overview of how the program should flow:
-
Server Initialization
- Create and bind socket
- Set socket to non-blocking mode
- Start listening for connections
-
Main Event Loop
- Use select() or poll() for non-blocking I/O
- Accept new client connections
- Receive data from existing clients
- Parse received messages
- Route messages to appropriate command handlers
- Send responses back to clients
-
Command Handling
- Process specific IRC commands
- Update server state (e.g., user information, channel memberships)
- Generate and send appropriate responses
-
Client Disconnection
- Handle client disconnections (voluntary or due to errors)
- Clean up resources associated with disconnected clients
-
Server Shutdown
- Close all client connections
- Free allocated resources
- Close server socket
The project is divided into three main modules, each with its own set of tasks:
-
Socket Management and Initialization
- Implement socket creation and binding
- Set up listening for incoming connections
- Set up non-blocking I/O using select() or poll()
- Implement basic error handling and logging for network operations
-
Client Management
- Implement client data structure
- Handle client connections (accept new clients)
- Manage client connections and disconnections
- Handle multiple clients concurrently
- Implement the main event loop
-
Message Parsing
- Implement IRC protocol message parser
- Route messages to appropriate handlers
-
Command Handling
- Implement NICK command
- Implement USER command
- Implement JOIN command
- Implement PART command
- Implement MSG command
- Implement QUIT command
- Implement KICK command
- Implement INVITE command
- Implement TOPIC command
- Implement MODE command
- Implement -i flag
- Implement -t flag
- Implement -k flag
- Implement -o flag
- Implement -l flag
- Generate and format server responses
- Implement error handling for invalid commands or parameters
-
Channel Management
- Implement channel data structure
- Handle channel creation and deletion
- Manage channel user lists
-
Server State Management
- Implement server-wide state management (users, channels, etc.)
- Handle client authentication
- Manage client nickname and username changes
- Integrate networking module for sending responses
- Integrate command handling module for executing commands
- Implement final error handling and logging system
- Coordinate overall program flow
- Implement server shutdown procedure
- Implement file transfer functionality
- Create a bot interface
This project is part of the 42 school curriculum. While contributions are not expected, feel free to fork the project for your own learning and experimentation.
This project is licensed under the GNU Affero General Public License v3.0 (AGPLv3) - see the LICENSE file for details.