Skip to content

Latest commit

 

History

153 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

What is this all about?


The ft_irc project is an implementation of an IRC (Internet Relay Chat) server designed to simulate the basic functionality of an IRC server used for real-time communication between users in channels. Built with C++98, this project aims to create a simple yet functional IRC server that supports essential commands such as JOIN, PART, NICK, USER, and more.

The project is split into two versions:

  1. Base Version: The basic IRC server, where you can connect clients, join channels, send messages, and manage nicknames.
  2. Bonus Version: An extended version that includes a bot, adding additional functionality and interactivity to the server, allowing users to engage with automated responses or other features.

The goal of this project is not only to provide a working chat system but also to enhance the understanding of network programming, client-server interactions, and socket management in C++. It allows users to create channels, join them, send private messages, and manage their own nicknames, all while interacting with other clients on the server.

By building this project, you will learn about handling multiple client connections, managing real-time communication in a server-client model, and dealing with the intricacies of networking protocols.

Whether you're new to networking, C++, or just want to build something practical, this project gives you a hands-on experience with the IRC protocol and lays the foundation for more complex server-client applications.



Note

This repository is open and you are encouraged to contribute.
If you have something to add or a tip to give, feel free to do so.

How can I test it?

I'm glad you asked! The process is very simple.


1º Step - Download the files:

git clone https://github.com/brennm2/IRCServer.git | cd IRCServer

2º Step - Compiling the program

make

I recommend using bonus version, so:

make bonus

3º Step - Running the server!

Now you need to put in the following inputs:

  • ft_irc version (irc_serv or irc_servbonus)
  • Port (ex 6667)
  • Password (ex 1234)
./ircserv_bonus 6667 1234

4º Step - Join the Server!

By Netcat:

nc -C localhost 6667
pass 1234
user bde-souz
nick brendon 0 * :Brendon Vianna


or Hexchat:

Considerations and Explanations

--------- Commands ---------

Command Description
/join <#channel1,#chennel2...> <password> or /join 0 Joins the specified channel or leaves all channels
/part <#channel1,#channel2...> [reason] Leaves the specified channel.
/nick <nickname> Changes your nickname to the specified one.
/privmsg <user1,user2...> [message] Sends a private message to the specified user.
/topic <#channel> or <#channel> [topic] Displays or sets the topic for a channel.
/quit [reason] Quits the IRC server with an optional message.
/invite <nickname> <#channel> Invite a user to a channel.
/kick <#channel> <nickname1,nickname2...> [reason] Kick a user from the channel.
/invite <nickname> <#channel> Invite a user to a channel.
/mode <#channel> <mode> <target or option> Set a mode to a channel.
/motd Tells the message of the day.
/BOT [HELP] Shows commands for the bot (ONLY IN BONUS)

--------- The Modes ---------

Modes Description
/mode <#channel> +o or -o <target> Gives or remove operator to a user.
/mode <#channel> +i or -i Change or remove the channel to Invite Only.
/mode <#channel> +k or -k <option> Put or remove a password to a channel.
/mode <#channel> +t or -t Lock or unlock the topic of channel.
/mode <#channel> +l or -l <option> Set or unset a limit of user to a channel.

--------- Important Notes! ---------

Warning

Be careful with the letters!.

Yes, this is VERY important, if you enter a nick like bde-souz and then other an user joins with BDE-SOUZ, it can steal the identity of the first user, and that is a VERY big problem! Same with the channel, that can leave to pretty bad problems!

Here are some examples:

Example Description
bde-souz and BDE-SOUZ It should give a 433 error (Nickname is already in use).
#channel and #CHANNEL It should JOIN in the first version that was created! Ex: #channel.
join and JOIN Commands should be interpreted as the same. Ex: JOIN and join



- SIGPIPES

Important

No one likes broken pipes!.

This can happen if you send a message to a closed Fd, you can easly do this with a scipt in shell that closes multiple clients at once (ex Ctrl + C)

Here are some quick solutions:
Solutions Description
signal(SIGPIPE, SIG_IGN) Use signal to ignore the SIGPIPE throw.
send(clientFd, message, message.size, MSG_NOSIGNAL) Enable the MSG_NOSIGNAL flag to disable throws of send().
do not send Well... find a way to not send the message to that FD ¯\_(ツ)_/¯



- Arguments and Texts

Tip

Dots, dots and dots....

Be careful, text are represented with :, so what happens if you don't put it? It should be considered an argument! So... with should only consider the first word

Here are some examples:
Example Output
privmsg #channel :Hello World :D bde-souz: Hello World :D
privmsg #channel Hello World :D bde-souz: Hello
kick #channel bde-souz :You behaved bad! bde-souz has been kicked from #teste (You behaved bad!)
kick #channel bde-souz You behaved bad! bde-souz has been kicked from #teste (You)
etc You got the idea :)


- HexChat and Netcat

Tip

Hexchat autocompletes things and Netcat accepts everything!.

You need to be careful with Hexchat and Netcat!

In the case of the Hexchat, it usually autocompletes the commands, for example, if you send /privmsg Hello World in the Hexchat, it will autocomplete the command, as in netcat, it will accept any reply, even if the syntax is wrong, use the hexchat to check it!

You can see that you need to use both of them to verify if everything is good

Input Model Output in the Server
/mode +o #bde-souz Hexchat mode #general +o #bde-souz
hello world (in channel) Hexchat PRIVMSG #teste :hello world
/part (in channel) Hexchat PART #teste :Leaving
/nick brendon Netcat :brendon!~Brendon@localhost NICK :brendon (WRONG SYNTAX)
/nick bde-souz Netcat : 433 bde-souz :Nickname is already in use (WRONG SYNTAX)

--------- 42 Rules ---------


In every project we must follow certain rules, here are the rules for this project:

- The project must not have memory leaks
- The project must use the flags -Wall -Wextra -Werror and use C++98


--------- Credits ---------

About

No description, website, or topics provided.

Resources

Stars

3 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages