Merge pull request 'pass-command' (#16) from pass-command into main
Reviewed-on: http://gitea.hadi.es/aortigos/ft_irc/pulls/16
This commit is contained in:
34
cmds/pass.cpp
Normal file
34
cmds/pass.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* pass.cpp :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2026/05/10 22:06:22 by aortigos #+# #+# */
|
||||
/* Updated: 2026/05/10 22:45:31 by aortigos ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "../Server/Server.hpp"
|
||||
|
||||
void Server::pass_cmd(User &client, std::istringstream &ss)
|
||||
{
|
||||
std::string args;
|
||||
|
||||
ss >> args;
|
||||
if (client.isAuthenticated())
|
||||
{
|
||||
// Still need to find what server should reply to different errors
|
||||
std::string res = "You are already authenticated";
|
||||
send(client.getFd(), res.c_str(), res.size(), 0);
|
||||
return ;
|
||||
}
|
||||
if (this->password_ == args)
|
||||
client->authenticated = true;
|
||||
else {
|
||||
// Still need to find what server should reply to different errors
|
||||
std::string res = "Invalid password";
|
||||
send(client.getFd(), res.c_str(), res.size(), 0);
|
||||
}
|
||||
}
|
||||
23
tasks.md
23
tasks.md
@@ -29,24 +29,27 @@ Represents a connected IRC client.
|
||||
|
||||
### First stage
|
||||
|
||||
- Server starts
|
||||
- It accepts two params, ./ircserv <port> <password>
|
||||
- The server accepts one user, user can send messages and we can see from server
|
||||
- Only 1 poll()
|
||||
- [✓] Server starts
|
||||
- [✓] It accepts two params, ./ircserv <port> <password>
|
||||
- [✓] The server accepts one user, user can send messages and we can see from server
|
||||
- [✓] Only 1 poll()
|
||||
|
||||
### Second stage
|
||||
|
||||
- Server can handle multiple clients simultaneously
|
||||
- [✓] Server can handle multiple clients simultaneously
|
||||
- [ ] Manage SO_REUSEADDR (restarting server fails to bind same port)
|
||||
|
||||
### Third stage
|
||||
|
||||
- Client has nickname and username
|
||||
- Client needs password for authenticate
|
||||
- Client can be regular user or operator (admin)
|
||||
- [ ] Client has nickname and username
|
||||
- [ ] Implement generic parser (extract command and pass args to command function)
|
||||
- [ ] Dispatcher (select function for each command)
|
||||
- [ ] PASS command for authenticate
|
||||
|
||||
### Fourth stage
|
||||
|
||||
- Client can create/connect to channels
|
||||
- Client can send message inside channel (only people inside this channel can read)
|
||||
- [ ] Client can create/connect to channels
|
||||
- [ ] JOIN command (user can create channel)
|
||||
- [ ] PRIVMSG command (send message to a channel)
|
||||
|
||||
*It will continue...*
|
||||
|
||||
Reference in New Issue
Block a user