{"id":15047247,"url":"https://github.com/marineks/ft_irc","last_synced_at":"2025-04-10T00:50:52.222Z","repository":{"id":64964475,"uuid":"565934267","full_name":"marineks/Ft_irc","owner":"marineks","description":"Prompt: Recode your own IRC server in C++","archived":false,"fork":false,"pushed_at":"2023-03-07T15:17:41.000Z","size":745,"stargazers_count":42,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T02:37:05.698Z","etag":null,"topics":["42born2code","42cursus","42projects","42school","cpp","cpp98","irc","irc-server","network-programming","socket-programming","tuto","tutorial"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marineks.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-14T16:22:39.000Z","updated_at":"2025-03-16T01:33:21.000Z","dependencies_parsed_at":"2024-09-28T23:50:32.971Z","dependency_job_id":null,"html_url":"https://github.com/marineks/Ft_irc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marineks%2FFt_irc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marineks%2FFt_irc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marineks%2FFt_irc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marineks%2FFt_irc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marineks","download_url":"https://codeload.github.com/marineks/Ft_irc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248137999,"owners_count":21053775,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42born2code","42cursus","42projects","42school","cpp","cpp98","irc","irc-server","network-programming","socket-programming","tuto","tutorial"],"created_at":"2024-09-24T20:55:43.374Z","updated_at":"2025-04-10T00:50:52.203Z","avatar_url":"https://github.com/marineks.png","language":"C++","readme":"# :zap: FT_IRC :zap:\n\n\u003cp align=\"center\"\u003e  \u003cimg src=\"assets/welcome.png\" width=\"55%\"\u003e \u003c/p\u003e\n\n\n##### *Proudly coded by [@tmanolis](https://github.com/tmanolis), [@QnYosa](https://github.com/QnYosa) and @marineks :heart:*\n\n___\n\n## :dizzy: Summary\n\n1. [About the project](https://github.com/marineks/Ft_irc#school_satchel-about-this-project)\n* [Definition](https://github.com/marineks/Ft_irc#_-crystal_ball-definition)\n* [Subject requirements](https://github.com/marineks/Ft_irc#_-floppy_disk-subject-requirements)\n* [Commands that we implemented](https://github.com/marineks/Ft_irc#high_brightness-commands-that-we-implemented-)\n2. [Some tips, graphs and other ressources](https://github.com/marineks/Ft_irc#gift-some-tips-graphs-and-other-ressources)\n* [Helpful links](https://github.com/marineks/Ft_irc#_-books-helpful-links)\n* [Tips](https://github.com/marineks/Ft_irc#_-books-helpful-links)\n___\n## :school_satchel: About this project\n\n\nThe objective of this project is to reproduce the functioning of an IRC server.\n\n###  _ :crystal_ball: Definition\n\n\n\u003e \"IRC (Internet Relay Chat) is a **protocol for real-time text messaging between internet-connected computers created in 1988**. It is mainly used for group discussion in chat rooms called “channels” although it supports private messages between two users, data transfer, and various server-side and client-side commands. As of April 2011, the top 100 IRC networks served over 500,000 users at a time on hundreds of thousands of channels.\" ([source](https://www.radware.com/security/ddos-knowledge-center/ddospedia/irc-internet-relay-chat/))\n\n\u003cimg src=\"assets/irc-shema.png\"\u003e\n\n### _ :floppy_disk: Subject requirements\n\n\n**1.** Code the IRC server in C++98\n**2.** Your binary should look like this : `./ircserv \u003cport\u003e \u003cpassword\u003e`\n**3.** You should use `poll()` and only **once**.\n**4.** The client/server communication will be TCP/IP (v4 or v6)\n**5.** The following features are mandatory :\n\u003e **i)** You should be able to register, i.e to define a nickname, a username\n\n\u003e **ii)** You should be able to join a channel, send or receive private messages\n\n\u003e **iii)** Every message sent by a client in a channel must be received by all of the clients who have joined this channel\n\n\u003e **iv)** You should have normal users and operators, and implement the operators' specific commands\n**6.** No leaks (even still reachables) and handle the signals (partial messages with `CTRL+D`, suspended process with `CTRL+Z`, and obviously SIGINT (`CTRL+C`))\n**7.** (bonuses) implement a bot + file transfer.\n\n\n___\n### :high_brightness: Commands that we implemented :\n\n\n\n| Command | Description |\n| :-----------: | :----------- |\n| Invite | The `INVITE` command is used to invite a user to a channel. |\n| Join | The `JOIN` command indicates that the client wants to join the given channel(s), each channel using the given key for it. |\n| Kick | The `KICK` command can be used to request the forced removal of a user from a channel. |\n| Kill | The `KILL` command is used to close the connection between a given client and the server they are connected to. `KILL` is a privileged command and is available only to IRC Operators. |\n| List | The `LIST` command is used to get a list of channels along with some information about each channel. |\n| Mode | The `MODE` command is used to set or remove options (or modes) from a given target. Our user modes : i, o. Our channels modes: b,k,m,o,p,s,t,v |\n| Motd | The `MOTD` command is used to get the “Message of the Day” of the given server. |\n| Names | The `NAMES` command is used to view the nicknames joined to a channel and their channel membership prefixes. |\n| Nick | The `NICK` command is used to give the client a nickname or change the previous one. |\n| Notice | The `NOTICE` command is used to send notices between users, as well as to send notices to channels. The difference between `NOTICE` and `PRIVMSG` is that automatic replies must never be sent in response to a `NOTICE` message.  |\n| Oper | The `OPER` command is used by a normal user to obtain IRC operator privileges.  |\n| Part | The `PART` command removes the client from the given channel(s). |\n| Pass | The `PASS` command is used to set a ‘connection password’. If set, the password must be set before any attempt to register the connection is made. |\n| Ping | The `PING` command is sent by either clients or servers to check the other side of the connection is still connected and/or to check for connection latency, at the application layer. |\n| Privmsg | The `PRIVMSG` command is used to send private messages between users, as well as to send messages to channels. |\n| Quit | The `QUIT` command is used to terminate a client’s connection to the server. The server acknowledges this by replying with an `ERROR` message and closing the connection to the client. |\n| Topic | The `TOPIC` command is used to change or view the topic of the given channel. |\n| User | The `USER` command is used at the beginning of a connection to specify the username and realname of a new user. |\n\n## :gift: Some tips, graphs and other ressources\n\n\n### _ :books: Helpful links\n\n\n- **To understand what exactly is an IRC and begin the project** : [Chirc](http://chi.cs.uchicago.edu/chirc/irc.html) (An irc subject from a Chicago uni) and the next pages too.\n\n\n- **Regarding the client/server connection** : [Beej's Guide to network programming](https://beej.us/guide/bgnet/pdf/bgnet_a4_c_1.pdf). This is super super helpful to better understand what is a socket, what the `poll()` function entails, which system calls we should use or in which order, and so on.\n\n\n\u003cp align=\"center\"\u003e \u003cimg src=\"assets/network.png\"\u003e \u003c/p\u003e\n\n- **A link to the IRC Client Protocol with a good formatting** : [Modern IRC Client Protocol](https://modern.ircdocs.horse/). You will find there a description of all the commands with correct syntax, expected Numerical Replies,...\n\n\n### _ :mailbox: Tips\n\n\n- **A suggestion of project roadmap :** \n  1- Begin by establishing a working client/server socket connection, \n  2- Then build on that : add the signals handling (`CTRL+C`, `CTRL+D`, `CTRL+Z`);\n   3- ***Only*** then begin the client registration system (`NICK`, `USER`, `PASS`), \n   4- The server commands (`PING`, `OPER`, `KILL`...) and \n   5- The channel operations commands (`JOIN`, `PART`, `INVITE`, `KICK`, `PRIVMSG`, `NOTICE`...).\n\n\n\t___\n\n- **Help, my code works perfectly with irssi but not with nc!** If you have this kind of issue, this is because, like us, you made the mistake of coding with irssi first and not nc :grimacing: Keep in mind that nc is very \"minimalist\" compared to irssi. That means that irssi will send you everything at once : the command, and the CRLF ending (`\\r\\n`). It will also append the `:` in some cases (for instance `TOPIC #channel :message`).\n\n\n  *This is not the case with nc* : you will have to concatenate the messages sent by the Client until you find the proper \"end\" (the CRLF). **That means that you should have a (read) buffer ==for each client== connected to your server**. Bonus: this will take care of he `CTRL+D` signal too! :smirk:\n\n\n  So now, if you follow us, you should guess that, for each client, **you will need a (send) buffer as well**! This will be very efficient in taking care of the `CTRL+Z` signal :innocent: . Don't forget to also check the `POLLIN and POLLOUT revents` in your server loop...\n\n\t___\n\n- **How to know how to correctly format a RPL to be understood by your IRC client of reference** (for instance, irssi) ?\n  .\n  \n  Join an existing server (try `/connect DALNET`), then enter the command `/RAWLOG OPEN debug.log` [(more doc)](https://irssi.org/documentation/help/rawlog/), and try the commands you're having some troubles with. This will open a log file in your workspace containing the all the exact client/server interactions for these commands, such as :\n\t```c\n\t// [...]\n\t\u003c\u003c JOIN #help // from the client\n\t\u003e\u003e :nickname!username@host JOIN :#help // reply from the server\n\t// [...]\n\t```\n  Voilà ! Now you know you forgot the `:` before the channel name! ;)\n\n\t___\n- **Okay, now you have a good format but the code is not clean at all?** Try to use dynamic macros in this way (*we guarantee this is a life changer/saver!*) :\n  ```cpp\n\t#define user_id(nickname, username) (\":\" + nickname + \"!\" + username + \"@localhost\")\n\t#define RPL_INVITE(user_id, invited, channel) (user_id + \" INVITE \" + invited + \" #\" + channel + \"\\r\\n\")\n\t// [...]\n\t#define ERR_INVALIDMODEPARAM(client, channel, mode, password) (\"696 \" + client + \" #\" + channel + \" \" + mode + \" \" + password + \" : password must only contained alphabetic character\\r\\n\")\n  ```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarineks%2Fft_irc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarineks%2Fft_irc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarineks%2Fft_irc/lists"}