From 2f995fe85660d6e10e36a0c010cac38bf1d4c19e Mon Sep 17 00:00:00 2001 From: aortigos Date: Sun, 10 May 2026 22:44:27 +0200 Subject: [PATCH 1/2] cmds folder created and first version of pass cmd --- cmds/pass.cpp | 32 ++++++++++++++++++++++++++++++++ tasks.md | 23 +++++++++++++---------- 2 files changed, 45 insertions(+), 10 deletions(-) create mode 100644 cmds/pass.cpp diff --git a/cmds/pass.cpp b/cmds/pass.cpp new file mode 100644 index 0000000..f0256a6 --- /dev/null +++ b/cmds/pass.cpp @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* pass.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: aortigos > args; + if (client.isAuthenticated()) + { + 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 { + std::string res = "Invalid password"; + send(client.getFd(), res.c_str(), res.size(), 0); + } +} \ No newline at end of file diff --git a/tasks.md b/tasks.md index c934488..4fb28d8 100644 --- a/tasks.md +++ b/tasks.md @@ -29,24 +29,27 @@ Represents a connected IRC client. ### First stage -- Server starts -- It accepts two params, ./ircserv -- 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 +- [✓] 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...* From 7f40babccce4cacf9b79ae7865b60ab6d85033ad Mon Sep 17 00:00:00 2001 From: aortigos Date: Sun, 10 May 2026 22:45:40 +0200 Subject: [PATCH 2/2] comments for pass.cpp --- cmds/pass.cpp | 4 +++- tasks.md | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cmds/pass.cpp b/cmds/pass.cpp index f0256a6..5d5362b 100644 --- a/cmds/pass.cpp +++ b/cmds/pass.cpp @@ -6,7 +6,7 @@ /* By: aortigos > 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 ; @@ -26,6 +27,7 @@ void Server::pass_cmd(User &client, std::istringstream &ss) 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); } diff --git a/tasks.md b/tasks.md index 4fb28d8..c77b939 100644 --- a/tasks.md +++ b/tasks.md @@ -48,7 +48,7 @@ Represents a connected IRC client. ### Fourth stage -- [ ]Client can create/connect to channels +- [ ] Client can create/connect to channels - [ ] JOIN command (user can create channel) - [ ] PRIVMSG command (send message to a channel)