diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..79e2403 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,18 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**", + "/home/barant/Development/ServerCore", + "/home/barant/Development/CoreUtils" + ], + "defines": [], + "compilerPath": "/usr/bin/gcc", + "cStandard": "gnu17", + "cppStandard": "gnu++14", + "intelliSenseMode": "linux-gcc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..82cfcc9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "cmake.configureOnOpen": false +} \ No newline at end of file diff --git a/SMTPCommand.cpp b/SMTPCommand.cpp deleted file mode 100644 index 811bd02..0000000 --- a/SMTPCommand.cpp +++ /dev/null @@ -1,15 +0,0 @@ -# include "Command.h" -# include "SMTPSession.h" -# include "SMTPServer.h" -# include "Log.h" - -namespace mail { - - int SMTPCommand::processCommand(std::string request, core::TCPSession *session, std::stringstream &data) { - coreutils::PString parser(request); - parser.split(" "); - return processCommand(parser, (SMTPSession &)*session, (SMTPServer &)session->server, data); - } - -} - diff --git a/SMTPCommand.h b/SMTPCommand.h deleted file mode 100644 index 238c55b..0000000 --- a/SMTPCommand.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef __SMTPCommand_h__ -# define __SMTPCommand_h__ - -# include "Command.h" -# include "SMTPSession.h" - -namespace mail { - - class SMTPServer; - - class SMTPCommand : public core::Command { - - public: - virtual int processCommand(std::string request, core::TCPSession *session, std::stringstream &data) override; - virtual int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - return 0; - } - - }; - -} - -#endif diff --git a/SMTPServer.h b/SMTPServer.h index e6d9f78..bde4dea 100644 --- a/SMTPServer.h +++ b/SMTPServer.h @@ -45,25 +45,25 @@ namespace mail { std::string mailPath; SMTPSession * getSocketAccept(core::EPoll &ePoll) override { - return new SMTPSession(ePoll, *this); + return new SMTPSession(ePoll, *this); } void sessionErrorHandler(std::string errorString, std::stringstream &out) { - out << "252 " << errorString << CRLF; + out << "252 " << errorString << CRLF; } protected: void inCreate(std::string name) { - int pos = name.find(".") + 10; - std::string mail = name.substr(0, pos); - std::string recipient = name.substr(pos); - if(recipient != "") { - std::string fileName = mailPath + "/.queue/" + name; - std::string path = mailFileSystem.getMailBoxPath(recipient) + "/Inbox/" + mail; - int rc = link(fileName.c_str(), path.c_str()); - rc = unlink(fileName.c_str()); - coreutils::Log(coreutils::LOG_INFO) << "Message " << mail << " delivered to " << recipient << "."; - } + int pos = name.find(".") + 10; + std::string mail = name.substr(0, pos); + std::string recipient = name.substr(pos); + if(recipient != "") { + std::string fileName = mailPath + "/.queue/" + name; + std::string path = mailFileSystem.getMailBoxPath(recipient) + "/Inbox/" + mail; + int rc = link(fileName.c_str(), path.c_str()); + rc = unlink(fileName.c_str()); + coreutils::Log(coreutils::LOG_INFO) << "Message " << mail << " delivered to " << recipient << "."; + } } private: diff --git a/SMTPSession.h b/SMTPSession.h index eb0d25b..3d3147d 100644 --- a/SMTPSession.h +++ b/SMTPSession.h @@ -16,10 +16,10 @@ namespace mail { public: SMTPSession(core::EPoll &ePoll, core::TCPServer &server) - : TCPSession(ePoll, server, "SMTP Client Session") {} + : TCPSession(ePoll, server, "SMTP Client Session") {} void onConnected() override { - out << "220 localhost BMAMail" << CRLF; + out << "220 localhost BMAMail" << CRLF; } std::string clientDomainName; diff --git a/__SMTP_AUTH.cpp b/__SMTP_AUTH.cpp index 6595872..1565c2f 100644 --- a/__SMTP_AUTH.cpp +++ b/__SMTP_AUTH.cpp @@ -4,63 +4,52 @@ namespace mail { - int __SMTP_AUTH::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - - switch(session.authState) { + int __SMTP_AUTH::processCommand(coreutils::ZString &request, core::TCPSession &session) { + + SMTPSession &s = dynamic_cast(session); + SMTPServer &server = session.server; + + switch((SMTPSession &)session.authState) { case USER_UNKNOWN: - if(request[1].str() == "LOGIN") { - - data << "334 VXNlcm5hbWU6" << CRLF; - - // setTimer(10.0f); - - session.authState = USER_QUERY; - session.server.commands.grabInput(&session, *this); - } - else { - data << "504 AUTH method not supported." << CRLF; - } - return 1; + if(request[1].equals("LOGIN") { + data << "334 VXNlcm5hbWU6" << CRLF; + // setTimer(10.0f); + s.authState = USER_QUERY; + server.commands.grabInput(&session, *this); + } + else { + s.out << "504 AUTH method not supported." << CRLF; + } + return 1; case USER_QUERY: - - session.userName = request[0].str(); - - // setTimer(0.0f); - - data << "334 UGFzc3dvcmQ6" << CRLF; - - // setTimer(10.0f); - session.authState = USER_SECRET_QUERY; - return 1; + s.userName = request[0].str(); + // setTimer(0.0f); + s.out << "334 UGFzc3dvcmQ6" << CRLF; + // setTimer(10.0f); + s.authState = USER_SECRET_QUERY; + return 1; case USER_SECRET_QUERY: - - session.password = request[0].str(); - - // setTimer(0.0f); - - coreutils::Base64 base64; - - if(authLogin(session.userName, session.password, server)) { - data << "235 2.7.0 Authentication successful" << CRLF; - session.relay = true; - session.authState = USER_KNOWN; - session.server.commands.clearGrab(&session); - } - - else { - data << "530 Login was unsuccessful." << CRLF; - } - return 1; - } - + s.password = request[0].str(); + // setTimer(0.0f); + coreutils::Base64 base64; + if(authLogin(s.userName, s.password, server)) { + s.out << "235 2.7.0 Authentication successful" << CRLF; + s.relay = true; + s.authState = USER_KNOWN; + server.commands.clearGrab(&session); + } + else { + s.out << "530 Login was unsuccessful." << CRLF; + } + return 1; + } return 0; } - bool __SMTP_AUTH::authLogin(std::string userName, std::string password, SMTPServer &server) { - + bool __SMTP_AUTH::authLogin(coreutils::ZString userName, coreutils::ZString password, SMTPServer &server) { std::string secretPath = server.mailFileSystem.getMailBoxPath(userName) + "/.password"; coreutils::File secret(secretPath); secret.read(); diff --git a/__SMTP_AUTH.h b/__SMTP_AUTH.h index 5c8e1be..642f355 100644 --- a/__SMTP_AUTH.h +++ b/__SMTP_AUTH.h @@ -1,22 +1,20 @@ #ifndef ____SMTP_AUTH_h__ # define ____SMTP_AUTH_h__ -# include "SMTPCommand.h" -# include "SMTPSession.h" +# include "Command.h" namespace mail { - - class SMTPServer; - - class __SMTP_AUTH : public SMTPCommand { - + + class SMTPServer; + + class __SMTP_AUTH : public core::Command { + public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - - bool authLogin(std::string userName, std::string password, SMTPServer &server); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; + bool authLogin(coreutils::ZString userName, coreutils::ZString password, SMTPServer &server); + }; - + } #endif diff --git a/__SMTP_DATA.cpp b/__SMTP_DATA.cpp index 056e0af..fc966b0 100644 --- a/__SMTP_DATA.cpp +++ b/__SMTP_DATA.cpp @@ -1,65 +1,71 @@ #include "__SMTP_DATA.h" +#include "SMTPSession.h" #include "SMTPServer.h" #include "Log.h" #include #include +#define CRLF "\r\n" + namespace mail { - int __SMTP_DATA::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - - switch(session.mode) { + int __SMTP_DATA::processCommand(coreutils::ZString &request, core::TCPSession &session) { + + SMTPSession &s = dynamic_cast(session); + SMTPServer &server = session.server; + + switch(session.mode) { - case WAIT_FOR_DATA: + case WAIT_FOR_DATA: - switch(session.state) { + switch(session.state) { - case RCPT: - data << "354 Enter the mail message terminated by ." << CRLF; - session.mailData.str(""); - session.mode = RECEIVE_DATA; - session.server.commands.grabInput(&session, *this); + case RCPT: + s.out << "354 Enter the mail message terminated by ." << CRLF; + s.mailData.str(""); + s.mode = RECEIVE_DATA; + server.commands.grabInput(&session, *this); // setTimer(120.0f); - break; + break; - case MAIL: - data << "503 Please use RCPT first" << CRLF; - break; + case MAIL: + s.out << "503 Please use RCPT first" << CRLF; + break; - default: - data << "503 Please use MAIL first" << CRLF; - break; + default: + s.out << "503 Please use MAIL first" << CRLF; + break; - } - break; + } + break; case RECEIVE_DATA: - if(request.str() != ".") - session.mailData << request.str() << CRLF; - else { - session.mode = WAIT_FOR_DATA; - session.state = READY; - session.server.commands.clearGrab(&session); + if(request.str() != ".") + s.mailData << request.str() << CRLF; + else { + s.mode = WAIT_FOR_DATA; + s.state = READY; + server.commands.clearGrab(&session); // if(filterMessage(session.mailData)) { - if(session.recipientList.size() > 0) { - if(session.mailData.str().size() > 0) { - std::string ID = queueMail(server, session.sender, session.recipientList, session.mailData); - if(ID != "") { - coreutils::Log(coreutils::LOG_INFO) << "Queued message " << ID << "."; - data << "250 OK Queued message " << ID << CRLF; - } - else - data << "550 Mail message too big" << CRLF; - } else - data << "550 Mail message was empty" << CRLF; - } else - data << "250 OK Queued message " << CRLF; + if(s.recipientList.size() > 0) { + if(s.mailData.str().size() > 0) { + std::string ID = queueMail(server, session.sender, session.recipientList, session.mailData); + if(ID != "") { + coreutils::Log(coreutils::LOG_INFO) << "Queued message " << ID << "."; + s.out << "250 OK Queued message " << ID << CRLF; + } + else + s.out << "550 Mail message too big" << CRLF; + } else + s.out << "550 Mail message was empty" << CRLF; + } else + s.out << "250 OK Queued message " << CRLF; // } else // data << "550 Message is probably spam" << CRLF; - } - break; - } - return 1; + } + break; + } + return 1; } std::string __SMTP_DATA::generateMailFileName() { @@ -76,8 +82,8 @@ namespace mail { mailFile.write(mailData.str()); for(std::string recipient: recipientList) { - std::string newName = fileName + recipient; - link(fileName.c_str(), newName.c_str()); + std::string newName = fileName + recipient; + link(fileName.c_str(), newName.c_str()); } unlink(fileName.c_str()); diff --git a/__SMTP_DATA.h b/__SMTP_DATA.h index ff31e70..fb98ca4 100644 --- a/__SMTP_DATA.h +++ b/__SMTP_DATA.h @@ -5,20 +5,19 @@ # include "SMTPSession.h" namespace mail { - + class SMTPServer; - - class __SMTP_DATA : public SMTPCommand { - + + class __SMTP_DATA : public SMTPCommand { + public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - - std::string generateMailFileName(); + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; + + std::string generateMailFileName(); std::string queueMail(SMTPServer &server, std::string sender, std::vector recipientList, std::stringstream &mailData); - + }; - + } - + #endif - \ No newline at end of file diff --git a/__SMTP_EHLO.cpp b/__SMTP_EHLO.cpp index 9a9660c..d9974d5 100644 --- a/__SMTP_EHLO.cpp +++ b/__SMTP_EHLO.cpp @@ -1,19 +1,23 @@ #include "__SMTP_EHLO.h" -#include "SMTPServer.h" +#include "SMTPSession.h" + +#define CRLF "\r\n" namespace mail { - int __SMTP_EHLO::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { + int __SMTP_EHLO::processCommand(coreutils::ZString &request, core::TCPSession &session) { + + SMTPSession &s = dynamic_cast(session); + + s.clientDomainName = request[1].str(); - session.clientDomainName = request[1].str(); - - data << "250-" << server.hostName << CRLF; + s.out << "250-" << server.hostName << CRLF; // cout << "250-STARTTLS" << CRLF; // cout << "250-PIPELINING" << CRLF; // cout << "250-8BITMIME" << CRLF; - data << "250-AUTH LOGIN" << CRLF; - data << "250 HELP" << CRLF; - session.state = READY; + s.out << "250-AUTH LOGIN" << CRLF; + s.out << "250 HELP" << CRLF; + s.state = READY; return 1; } diff --git a/__SMTP_EHLO.h b/__SMTP_EHLO.h index 3704d85..40c2dd9 100644 --- a/__SMTP_EHLO.h +++ b/__SMTP_EHLO.h @@ -11,8 +11,8 @@ namespace mail { class __SMTP_EHLO : public SMTPCommand { public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; + }; } diff --git a/__SMTP_EXPN.cpp b/__SMTP_EXPN.cpp index 1ea3425..15ad103 100644 --- a/__SMTP_EXPN.cpp +++ b/__SMTP_EXPN.cpp @@ -1,11 +1,14 @@ #include "__SMTP_EXPN.h" #include "SMTPServer.h" +#define CRLF "\r\n" + namespace mail { - int __SMTP_EXPN::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - data << "252 You must know recipient." << CRLF; - session.state = READY; + int __SMTP_EXPN::processCommand(coreutils::ZString &request, core::TCPSession &session) { + SMTPSession &s = dynamic_cast(session); + s.out << "252 You must know recipient." << CRLF; + s.state = READY; return 1; } diff --git a/__SMTP_EXPN.h b/__SMTP_EXPN.h index 1cdc303..fe24f08 100644 --- a/__SMTP_EXPN.h +++ b/__SMTP_EXPN.h @@ -11,8 +11,7 @@ namespace mail { class __SMTP_EXPN : public SMTPCommand { public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_HELO.cpp b/__SMTP_HELO.cpp index bdef4dd..eb9400b 100644 --- a/__SMTP_HELO.cpp +++ b/__SMTP_HELO.cpp @@ -3,12 +3,11 @@ namespace mail { - int __SMTP_HELO::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - - std::string clientName = request[1].str(); - - data << "250 " << server.hostName << CRLF; - session.state = READY; + int __SMTP_HELO::processCommand(coreutils::ZString &request, core::TCPSession &session) { + SMTPSession &s = dynamic_cast(session); + s.clientName = request[1].str(); + s.out << "250 " << server.hostName << CRLF; + s.state = READY; return 1; } diff --git a/__SMTP_HELO.h b/__SMTP_HELO.h index 260def0..09fac75 100644 --- a/__SMTP_HELO.h +++ b/__SMTP_HELO.h @@ -1,18 +1,17 @@ #ifndef ____SMTP_HELO_h__ # define ____SMTP_HELO_h__ -# include "SMTPCommand.h" +# include "Command.h" # include "SMTPSession.h" namespace mail { class SMTPServer; - class __SMTP_HELO : public SMTPCommand { + class __SMTP_HELO : public core::Command { public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_HELP.cpp b/__SMTP_HELP.cpp index d9d4867..f122ccf 100644 --- a/__SMTP_HELP.cpp +++ b/__SMTP_HELP.cpp @@ -1,11 +1,13 @@ #include "__SMTP_HELP.h" #include "SMTPServer.h" +#define CRLF "\r\n" + namespace mail { - int __SMTP_HELP::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { - data << "250 Sure you need help." << CRLF; - session.state = READY; + int __SMTP_HELP::processCommand(coreutils::ZString &request, core::TCPSession &session) { + s.out << "250 Sure you need help." << CRLF; + s.state = READY; return 1; } diff --git a/__SMTP_HELP.h b/__SMTP_HELP.h index 68bc347..bf799ed 100644 --- a/__SMTP_HELP.h +++ b/__SMTP_HELP.h @@ -5,13 +5,9 @@ # include "SMTPSession.h" namespace mail { - - class SMTPServer; - - class __SMTP_HELP : public SMTPCommand { - - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); + class __SMTP_HELP : public SMTPCommand { + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_MAIL.cpp b/__SMTP_MAIL.cpp index 0763160..03d7829 100644 --- a/__SMTP_MAIL.cpp +++ b/__SMTP_MAIL.cpp @@ -1,29 +1,32 @@ #include "__SMTP_MAIL.h" -#include "SMTPServer.h" +#include "SMTPSession.h" + +#define CRLF "\r\n" namespace mail { - int __SMTP_MAIL::processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data) { + int __SMTP_MAIL::processCommand(coreutils::ZString &request, core::TCPSession &session) { + SMTPSession &s = dynamic_cast(session); + if(request.ifNext("MAIL FROM:")) { - request.skipWhitespace(); - if(request.ifNext("<")) { - session.sender = request.getTokenExclude(">"); - if(session.authState = USER_KNOWN) { - data << "250 OK" << CRLF; - session.recipientList.clear(); - session.state = MAIL; - } - } else - data << "550 Usage: MAIL FROM:" << CRLF; + request.skipWhitespace(); + if(request.ifNext("<")) { + s.sender = request.getTokenExclude(">"); + if(s.authState = USER_KNOWN) { + s.out << "250 OK" << CRLF; + s.recipientList.clear(); + s.state = MAIL; + } + } else + s.out << "550 Usage: MAIL FROM:" << CRLF; } else - data << "550 Usage: MAIL FROM:" << CRLF; - + s.out << "550 Usage: MAIL FROM:" << CRLF; return 1; } std::string domainOnly(std::string email) { - coreutils::PString split(email); + coreutils::ZString split(email); split.split("@"); return split[1].str(); } diff --git a/__SMTP_MAIL.h b/__SMTP_MAIL.h index f1d85be..a2b7ec1 100644 --- a/__SMTP_MAIL.h +++ b/__SMTP_MAIL.h @@ -8,12 +8,10 @@ namespace mail { class SMTPServer; - class __SMTP_MAIL : public SMTPCommand { + class __SMTP_MAIL : public Command { public: - - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_NOOP.cpp b/__SMTP_NOOP.cpp index be2f9d7..2dece60 100644 --- a/__SMTP_NOOP.cpp +++ b/__SMTP_NOOP.cpp @@ -1,21 +1,17 @@ #ifndef ____SMTP_NOOP_h__ # define ____SMTP_NOOP_h__ -# include "SMTPCommand.h" # include "SMTPSession.h" -# include "PString.h" +# include "__SMTP_NOOP.h" +# include "ZString.h" namespace mail { - class __SMTP_NOOP : public SMTPCommand { - - int processCommand(coreutils::PString request, SMTPSession &session, std::stringstream &data) { - data << "250 OK" << CRLF; - return 1; + int __SMTP_NOOP::processCommand(coreutils::ZString &request, core::TCPSession &session) { + SMTPSession &s = dynamic_cast(session); + s.out << "250 OK" << CRLF; + return 1; } - - }; - } #endif diff --git a/__SMTP_NOOP.h b/__SMTP_NOOP.h index be2f9d7..c6a032e 100644 --- a/__SMTP_NOOP.h +++ b/__SMTP_NOOP.h @@ -1,19 +1,13 @@ #ifndef ____SMTP_NOOP_h__ # define ____SMTP_NOOP_h__ -# include "SMTPCommand.h" # include "SMTPSession.h" -# include "PString.h" +# include "ZString.h" namespace mail { - class __SMTP_NOOP : public SMTPCommand { - - int processCommand(coreutils::PString request, SMTPSession &session, std::stringstream &data) { - data << "250 OK" << CRLF; - return 1; - } - + class __SMTP_NOOP : public Command { + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_QUIT.h b/__SMTP_QUIT.h index c98a93d..8f6ac51 100644 --- a/__SMTP_QUIT.h +++ b/__SMTP_QUIT.h @@ -8,12 +8,10 @@ namespace mail { class SMTPServer; - class __SMTP_QUIT : public SMTPCommand { + class __SMTP_QUIT : public Command { public: - - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_RCPT.h b/__SMTP_RCPT.h index 77c8b47..3b18730 100644 --- a/__SMTP_RCPT.h +++ b/__SMTP_RCPT.h @@ -1,19 +1,15 @@ #ifndef ____SMTP_RCPT_h__ # define ____SMTP_RCPT_h__ -# include "SMTPCommand.h" -# include "MailFileSystem.h" -# include "SMTPSession.h" +# include "Command.h" +# include "TCPSession.h" namespace mail { - class SMTPServer; - - class __SMTP_RCPT : public SMTPCommand { + class __SMTP_RCPT : public core::Command { public: - int processCommand(coreutils::PString request, SMTPSession &session, SMTPServer &server, std::stringstream &data); - + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; } diff --git a/__SMTP_RSET.h b/__SMTP_RSET.h index ce3815d..cb5d151 100644 --- a/__SMTP_RSET.h +++ b/__SMTP_RSET.h @@ -1,20 +1,16 @@ #ifndef ____SMTP_RSET_h__ #define ____SMTP_RSET_h__ -#include "SMTPCommand.h" +#include "Command.h" +#include "TCPSession.h" +#include "ZString.h" namespace mail { - class __SMTP_RSET : public SMTPCommand { - - int processCommand(coreutils::PString request, SMTPSession &session, std::stringstream &data) { - session.state = READY; - data << "250 OK" << CRLF; - return 0; - } - + class __SMTP_RSET : public core::Command { + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; - + } #endif diff --git a/__SMTP_VRFY.cpp b/__SMTP_VRFY.cpp index 856c91f..23b6838 100644 --- a/__SMTP_VRFY.cpp +++ b/__SMTP_VRFY.cpp @@ -1,10 +1,11 @@ #include "__SMTP_VRFY.h" +#define CRLF "\r\n" namespace mail { - int __SMTP_VRFY::processCommand(coreutils::PString request, SMTPSession &session, std::stringstream &data) { - data << "252 You must know who the mail is for" << CRLF; - return 0; + int __SMTP_VRFY::processCommand(coreutils::ZString &request, core::TCPSession &session) { + session.out << "252 You must know who the mail is for" << CRLF; + return 1; } } diff --git a/__SMTP_VRFY.h b/__SMTP_VRFY.h index 6dc44d9..dcc73f2 100644 --- a/__SMTP_VRFY.h +++ b/__SMTP_VRFY.h @@ -1,17 +1,16 @@ #ifndef ____SMTP_VRFY_h__ # define ____SMTP_VRFY_h__ -# include "SMTPCommand.h" -# include "PString.h" +# include "Command.h" +# include "TCPSession.h" +# include "ZString.h" namespace mail { - - class __SMTP_VRFY : public SMTPCommand { - - int processCommand(coreutils::PString request, SMTPSession &session, std::stringstream &data); - + + class __SMTP_VRFY : public core::Command { + int processCommand(coreutils::ZString &request, core::TCPSession &session) override; }; - + } #endif