Skip to content

Latest commit

 

History

228 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Internet Relay Chat

Contributors:

This project is an implementation of an IRC (Internet Relay Chat) server in C++98. The server handles multiple clients simultaneously, supports channel creation and management, and implements core IRC commands following the RFC 2119 protocol specification.

The server is capable of:

  • Handling multiple client connections using non-blocking I/O and poll()
  • Processing IRC commands including NICK, USER, JOIN, PRIVMSG, MODE, TOPIC, INVITE, KICK, PART, and PASS
  • Managing channels with various modes (invite-only, topic restrictions, key-protected, user limits)
  • Maintaining user authentication and registration
  • Broadcasting messages to channels and users

Features

Core Features

  • Client Authentication: PASS command for password verification
  • User Registration: NICK and USER commands for client identification
  • Channel Management:
    • JOIN command with channel creation
    • Channel modes: i (invite-only), t (topic restricted), k (key protected), l (user limit), o (operator)
  • Messaging:
    • PRIVMSG for direct messages and channel broadcasts
    • TOPIC for channel topic management
  • User Management:
    • INVITE to invite users to invite-only channels
    • KICK to remove users from channels (operator only)
    • PART to leave channels

Technical Features

  • Non-blocking I/O using poll()
  • Signal handling for graceful shutdown (SIGINT, SIGQUIT)
  • Dynamic memory management for clients and channels
  • Thread-safe design with no global state

Instructions

Compilation

The project includes a Makefile for compilation:

make

This will generate the ircserv executable.

Execution

Run the server with:

./ircserv <port> <password>

Parameters:

  • <port>: The port number on which the server will listen (e.g., 6667)
  • <password>: The connection password required by clients

Example:

./ircserv 6667 secretpass

Connecting with an IRC Client

You can connect to the server using any IRC client (like irssi, HexChat, or netcat):

Using netcat for testing:

nc localhost 6667

Then enter IRC commands manually:

PASS secretpass
NICK your_nickname
USER username 0 * :Real Name

Using a full IRC client:

/server localhost 6667 -pass secretpass

Available Commands

Command Description
PASS <password> Authenticate with the server
NICK <nickname> Set or change your nickname
USER <username> 0 * :<realname> Register your user information
JOIN <#channel> Join or create a channel
PART <#channel> Leave a channel
PRIVMSG <target> :<message> Send a message to a user or channel
TOPIC <#channel> [<topic>] View or set a channel's topic
MODE <#channel> [<modes> [<params>]] Change channel modes
INVITE <nickname> <#channel> Invite a user to an invite-only channel
KICK <#channel> <nickname> [:<reason>] Remove a user from a channel (operator only)

Channel Modes

Mode Description Parameters
i Invite-only None
t Topic restricted (operators only) None
k Key/password required <key>
l User limit <limit>
o Operator status <nickname>

Examples:

  • MODE #channel +i - Make channel invite-only
  • MODE #channel +k secretkey - Set channel password
  • MODE #channel +l 10 - Limit channel to 10 users
  • MODE #channel +o username - Grant operator status

BOT Usage (The Nim Game)

The IRC server includes a built-in bot that allows users to play a game called Nim.

Game Rules

  • The game contains 9 piles of objects, with each pile initially containing 9 objects.

  • On your turn, you must choose exactly one pile.

  • You must remove one or more objects from that chosen pile.

  • You cannot remove objects from multiple piles in a single turn.

  • The player who removes the very last object from the board wins the game.

How to Play for the First Time

  • All interactions with the bot are done using the PRIVMSG command, using the syntax: PRIVMSG Bot : <amount>.

  • Starting the game: To initiate your first game, send a message to the bot (e.g., PRIVMSG Bot : 1). Because it is your first interaction, the bot will reply with a welcome message, a list of the rules, and a visual display of the starting piles.

  • Step 1 (Select a Pile): The bot will prompt you with, "Your turn, Choose pile index from 1 to 9". Send a PRIVMSG to the bot with your chosen pile number.

  • Step 2 (Remove Stones): After selecting a valid pile, the bot will ask you how many stones you want to remove (from 1 up to the current total in that pile). Send another PRIVMSG with the amount you wish to remove.

  • Bot's Turn: After your turn, the bot will automatically calculate its move, remove stones, and display the updated board state.

  • Winning/Losing: You will alternate turns until all stones are gone. The bot will then announce if you beat it or if it won, and the game will reset for a new match.

Resources

IRC Protocol Documentation

https://modern.ircdocs.horse/

Additional Resources

How AI Was Used

AI was used as a learning and documentation assistant throughout the project. It helped explain networking concepts, the IRC protocol, socket programming, and C++98 features, as well as assisted with debugging, code reviews, and improving the project's documentation. All implementation decisions, design, and final code were developed and validated by the project authors.

About

IRC server written in C++98. Features support for multiple clients and channels, non-blocking socket I/O, nickname and channel management, operator commands, and an extensible architecture inspired by the IRC protocol standards, designed for scalability and real-time communication.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages