Building an IRC Server 4

2021-04-28
2 min read

by Eudald

[mode, ban, whoX]

We are getting to it

Hello! Again Eudald here! So, I’ll expose you our new features implemented during our 4th week of work. Let’s hop into it.

This week we constinued the commands KICK, MODE, and OPER. For this last one, I used the same method as for our PASS command described in the second post. What KICK does is to kick a client from a Channel, obviously, you MUST be operator to use it. That’s why we’ve done OPER at almost the same time, it just gives operator privilegies to a client using:

OPER <name> <password>

We also did TOPIC command, which sets a topic for the current Channel. Which also has to be notified to all users in it.

For a better usage of MODE and Channels, we added some attributes to the Channel class, representing a “list” of operator, banned, voice, etc. users. We store the users as pointers to them for better manipulation and faster operations. This is a good and simple way to handle users having a specific role or similar in a Channel and have quick access to them. Take a quick look:

std::vector<Client*>		_operator;
std::vector<Client*>		_users;
std::vector<Client*>		_invite;
std::vector<t_ban>			_ban;
std::vector<Client*>		_voice;

Here we used Vector, but later on it changed to Deque, as for memory issues it’s better than Vector. t_ban is a structure representing a banned user.

t_ban is a structure representing a banned user, which contains its nickname,username, hostname and ban_date. We don’t store a pointer or such to a user as a non existing (or known by the Channel) users can be banned.

We implemented the respectives modes for each “list” above, MODE +o,+i,+b,+v.

A little thing we noticed is that some clients (such as irssi) send a

MODE <channel> <b>/<+b]

query to the server just after joining an already existing channel. It doesn’t have much use, despite “completing” a registration to the Channel and get an additional Sync message.

Finally, we added more MODEs, and we continued the implementation of WHO, which is pretty useful later on for WHO_IS and WHO_WAS.

And that’s all for this week! Thanks for reading, and see you later
Eudald