Skip to content
This repository was archived by the owner on Jul 11, 2026. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

FT_IRC

Description

The goal -> create an IRC(Internet Relay Chat) server in C++ 98.

What is IRC? IRC is a chat protocol, allowing communication between IRC clients on Internet.

Core components
SERVER CLIENT CHANNEL

  • Server - manages a communication: connection and validation of commands applied.
  • Client - represents a connected user.

Note

Clients never communicate directly-> handled by server, either by routing(deciding where message is send) or through channels.

  • Channel - communication group, distinguishing the role of each client.

Structure

  • Server.cpp
    Socket creation, connections, main event loop 'poll()'.
    Accepting new clients and sending off a received data.

  • Client.cpp
    Connected user. Stores connection state (socket), registartion information(nickname, username).

  • Channel.cpp
    Channel state, namely: members. operators, topic, invite list, channel modes.

  • CommandParser.cpp
    Parses our input received from clients into structured chat commands.

  • Commands.cpp
    Logic of IRC commands, namely PASS, NICK, USER(as for registration block.
    JOIN, PRIVMSG(to join channel and chat within), KICK, JOIN, INVITE, TOPIC, MODE(reserved only for operator users).

Bonus

  • Bot.cpp
    Automated behavior and responses(tell a joke, throw a dice).

How does it basically works?
Communication base-sockets-enabling connection either on the same machine or across a network. In our implementation, communication done via TCP/IP v4 -> _serverSocket = socket(AF_INET, SOCK_STREAM, 0);
Server socket->listens for new connections;
Client socket->used for actual exchange of IRC commands and replies.

Instructions

How to compile?
Use Makefile to compile a project
make
c++ -std=c++ 98 used for the compilation with the -Wall -Wextra -Werror flags

How to run?
In different terminal tabs:
SERVER-> ./ircserv <port> <password>

CLIENT->nc -С localhost <port> OR irssi -c localhost -p <portnumber> -w <password>

Important

Once connection established->register your client(user) FIRST. look into registaration details in the next chapter. IRSSI: we pass to the connection -> /connect localhost (if needed);

How to interact within IRC? How to test?

Main scheme of server interaction:
registartion->join->messaging->regular users/operators->modes/reserved commands

Warning

IRSSI: for this type of reference use all keywords (commands) with / JOIN #lol -> /join lol1 otherwise considered as a plain text

Commands implemented2

Registartration

  • PASS <password>
    ! of registration= from server launching!
  • NICK <username>
  • USER <username> 0 * :<nameofyourchoice>

Note

ft_IRC 001 <yourusername> :Welcome to the ft_IRC server! = registration success

Join and chat/messaging 3

  • JOIN #<channelname>
  • PRIVMSG <channel/username> :<message>

Tip

Make sure to open multiple tabs to connect at least 2 users in order to enlarge test options

Regular users/operators In the IRC world, operators are like the sheriffs of their channels. They have special privileges that regular users don’t.

  • MODE #channel +o <target> - will allow to pass to the operator mode, thus access to all of the following commands:
  • KICK #channel <target>: <message> - to eject a from the channel;
  • INVITE <target> #channel- to invite a to a channel;
  • TOPIC #channel :<new topic> - to change a channel topic;
  • MODE #channel +/-<modes> [params] - to change channel's mode4;
  • i: Set/remove Invite-only channel;
    no params, only invited users can join when +i is set
  • t: Set/remove the restrictions of the TOPIC command to channel operators;
    no params, only operators can change topic when +t is set
  • k: Set/remove the channel key (password);
    +k [password]/ -k -add and remove key, when joining a channel
  • o: Give/take channel operator privilege;

Important

Remember that exactly this command can give you a permission to use all reserved commands
MODE #channel +o / MODE #channel -o - gives/removes operator status

  • l: Set/remove the user limit to channel
    +l [number]/ -l -adds user's limit to join a channel/ removes limit

Resources

Footnotes

  1. IRSSI commands doc

  2. Commands to connect to IRC Network

  3. IRC communication example

  4. Channel mode syntax

About

An IRC server using the C++ 98 standard.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages