Skip to content

adi7-x/ft_irc

ย 
ย 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

72 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ’ฌ ft_irc

An IRC server that actually works.

A fully functional Internet Relay Chat server written in C++98,
implementing the IRC protocol (RFC 2812) with authentication, channels,
operator privileges, and bonus features including a bot and file transfer.

๐Ÿ“Œ Note: This is a collaborative project. The original repository is Abdellatif404/Internet-Relay-Chat. This fork showcases my contributions while maintaining full attribution to the team.


๐Ÿ“‹ Table of Contents


๐Ÿ’ก About

ft_irc is a 42 School project that requires building an IRC server from scratch in C++98. The server must handle multiple simultaneous clients using non-blocking I/O and epoll() for event-driven networking.

What Is IRC?

Internet Relay Chat (IRC) is a real-time text messaging protocol from 1988 โ€” the grandfather of modern chat systems like Slack and Discord.

                     IRC ARCHITECTURE

   Client A โ”€โ”€โ”€โ”€โ”€โ”
                  โ”‚
   Client B โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ†’  IRC SERVER  โ†โ”€โ”€โ”€โ”€โ”€โ”€ Client D
                  โ”‚       (ircserv)
   Client C โ”€โ”€โ”€โ”€โ”€โ”˜         port 6667

๐Ÿ“ก The IRC Protocol

Our server implements RFC 2812 โ€” the IRC client protocol specification:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚            IRC MESSAGE FORMAT                 โ”‚
โ”‚                                              โ”‚
โ”‚  :<prefix> <command> <params> :<trailing>     โ”‚
โ”‚                                              โ”‚
โ”‚  Example:                                    โ”‚
โ”‚  :nick!user@host PRIVMSG #channel :Hello!    โ”‚
โ”‚                                              โ”‚
โ”‚  Max message length: 512 bytes (including    โ”‚
โ”‚  the CR-LF terminator)                       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

โœจ Features

  • โœ… Authentication โ€” password-protected server access
  • โœ… Nicknames & Users โ€” NICK/USER registration per RFC
  • โœ… Channels โ€” create, join, leave, and manage channels
  • โœ… Private Messages โ€” direct user-to-user messaging
  • โœ… Channel Modes โ€” invite-only, topic lock, key, user limit
  • โœ… Operator Privileges โ€” KICK, INVITE, TOPIC, MODE
  • โœ… Non-blocking I/O โ€” epoll() event-driven architecture
  • โœ… Multiple Clients โ€” concurrent connections without threads
  • โœ… Graceful Handling โ€” partial messages, disconnections, errors

๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              SERVER ARCHITECTURE              โ”‚
โ”‚                                              โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚  โ”‚  epoll() โ”‚ โ”€โ”€โ†’ โ”‚  Event Loop          โ”‚  โ”‚
โ”‚  โ”‚  wait    โ”‚     โ”‚  โ€ข Accept new clients โ”‚  โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”‚  โ€ข Read from sockets  โ”‚  โ”‚
โ”‚       โ†‘           โ”‚  โ€ข Parse commands     โ”‚  โ”‚
โ”‚       โ”‚           โ”‚  โ€ข Execute & respond  โ”‚  โ”‚
โ”‚  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”     โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ”‚  โ”‚  Socket  โ”‚              โ”‚                 โ”‚
โ”‚  โ”‚  fd pool โ”‚              โ–ผ                 โ”‚
โ”‚  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜     โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”  โ”‚
โ”‚                   โ”‚  Command Dispatcher   โ”‚  โ”‚
โ”‚                   โ”‚  NICK, JOIN, PRIVMSG  โ”‚  โ”‚
โ”‚                   โ”‚  KICK, MODE, TOPIC... โ”‚  โ”‚
โ”‚                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜  โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“œ Commands

Connection & Registration

Command Syntax Description
PASS PASS <password> Authenticate with server password
NICK NICK <nickname> Set or change nickname
USER USER <user> 0 * :<realname> Register username
QUIT QUIT [:<message>] Disconnect from server

Channel Operations

Command Syntax Description
JOIN JOIN <#channel> [key] Join a channel
PART PART <#channel> [:<message>] Leave a channel
TOPIC TOPIC <#channel> [:<topic>] View/set channel topic
NAMES NAMES <#channel> List users in channel

Messaging

Command Syntax Description
PRIVMSG PRIVMSG <target> :<message> Send message to user/channel
NOTICE NOTICE <target> :<message> Send notice (no auto-reply)

Operator Commands

Command Syntax Description
KICK KICK <#channel> <user> [:<reason>] Remove user from channel
INVITE INVITE <user> <#channel> Invite user to channel
MODE MODE <#channel> <+/-flags> [params] Set channel modes

Channel Modes

Mode Flag Description
Invite-only +i Only invited users can join
Topic lock +t Only operators can change topic
Channel key +k <key> Password-protected channel
User limit +l <count> Maximum number of users
Operator +o <nick> Grant/revoke operator status

๐Ÿš€ Getting Started

Compilation

make            # Build the server
make clean      # Remove object files
make fclean     # Full clean
make re         # Rebuild

Running the Server

./ircserv <port> <password>

# Example
./ircserv 6667 mypassword

๐ŸŽฎ Usage Examples

Connecting with irssi

irssi -c localhost -p 6667 -w mypassword

Connecting with netcat

nc -C 127.0.0.1 6667
PASS mypassword
NICK mynick
USER myuser 0 * :Real Name
JOIN #general
PRIVMSG #general :Hello everyone!

Connecting with HexChat

  1. Add new network โ†’ Server: localhost/6667
  2. Set server password: mypassword
  3. Connect and join channels

๐ŸŽ Bonus Features

IRC Bot

An automated bot that responds to commands and provides utility functions within channels.

DCC File Transfer

Direct Client-to-Client file transfer โ€” allows users to send files directly to each other through the IRC server.


๐Ÿ”ง Technical Details

Aspect Implementation
I/O Model Non-blocking with epoll()
Standard C++98 strict compliance
Concurrency Single-threaded, event-driven
Protocol RFC 2812 (IRC Client Protocol)
Max Message 512 bytes including CRLF
Compatible Clients irssi, HexChat, WeeChat, netcat

๐Ÿ‘ฅ Team & Contributions

This was a collaborative 42 project. Full attribution to all team members:

Member GitHub Contributions
Abdellatif @Abdellatif404 Server core, channel management
Adil Bourji @adi7-x Command parsing, operator privileges, testing

๐Ÿ”— Original repository: Abdellatif404/Internet-Relay-Chat


๐Ÿ‘ค Author

Adil Bourji โ€” @adi7-x

42 School ยท Common Core ยท Networking ยท C++

About

An IRC server in C++98 implementing RFC 2812 with authentication, channels, operators, and bonus features including a bot and DCC file transfer.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C++ 98.8%
  • Makefile 1.2%