More development.
This commit is contained in:
parent
caa8dd7d90
commit
50eb707f10
@ -1,25 +0,0 @@
|
|||||||
#ifndef BMAIMAPServer_h__
|
|
||||||
#define BMAIMAPServer_h__
|
|
||||||
|
|
||||||
#include "includes"
|
|
||||||
#include "BMATCPServerSocket.h"
|
|
||||||
#include "BMACommand.h"
|
|
||||||
class BMATCPSocket;
|
|
||||||
|
|
||||||
class BMAIMAPServer : public BMATCPServerSocket {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMAIMAPServer(BMAEPoll &ePoll, std::string url, short int port);
|
|
||||||
~BMAIMAPServer();
|
|
||||||
|
|
||||||
BMASession * getSocketAccept();
|
|
||||||
|
|
||||||
void registerCommand(BMACommand &command);
|
|
||||||
|
|
||||||
int processCommand(BMASession *session) override; ///<Output the consoles array to the console.
|
|
||||||
|
|
||||||
std::vector<BMACommand *> commands;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef __BMAIMAPSession_h__
|
|
||||||
#define __BMAIMAPSession_h__
|
|
||||||
|
|
||||||
#include "BMASession.h"
|
|
||||||
#include "BMAIMAPServer.h"
|
|
||||||
|
|
||||||
///
|
|
||||||
/// BMAIMAPSession
|
|
||||||
///
|
|
||||||
/// Extends the session parameters for this BMATCPSocket derived object.
|
|
||||||
/// Extend the protocol() method in order to define the behavior and
|
|
||||||
/// protocol interaction for this socket which is an IMAP session.
|
|
||||||
///
|
|
||||||
|
|
||||||
class BMAIMAPSession : public BMASession {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMAIMAPSession(BMAEPoll &ePoll, BMAConsoleServer &server);
|
|
||||||
~BMAIMAPSession();
|
|
||||||
|
|
||||||
virtual void output(std::stringstream &out);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void protocol(char *data, int length) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
BMAConsoleServer &server;
|
|
||||||
enum Status {WELCOME, PROMPT, INPUT, PROCESS, DONE};
|
|
||||||
Status status = WELCOME;
|
|
||||||
void doCommand(std::string request);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -20,6 +20,10 @@
|
|||||||
<File Name="__SMTP_VRFY.h"/>
|
<File Name="__SMTP_VRFY.h"/>
|
||||||
<File Name="__SMTP_NOOP.h"/>
|
<File Name="__SMTP_NOOP.h"/>
|
||||||
<File Name="__SMTP_QUIT.h"/>
|
<File Name="__SMTP_QUIT.h"/>
|
||||||
|
<File Name="SMTPService.h"/>
|
||||||
|
<File Name="SMTPSession.h"/>
|
||||||
|
<File Name="POP3Service.h"/>
|
||||||
|
<File Name="IMAPService.h"/>
|
||||||
</VirtualDirectory>
|
</VirtualDirectory>
|
||||||
<Dependencies Name="Debug"/>
|
<Dependencies Name="Debug"/>
|
||||||
<Dependencies Name="Release"/>
|
<Dependencies Name="Release"/>
|
||||||
|
@ -1,25 +0,0 @@
|
|||||||
#ifndef BMAPOP3Server_h__
|
|
||||||
#define BMAPOP3Server_h__
|
|
||||||
|
|
||||||
#include "includes"
|
|
||||||
#include "BMATCPServerSocket.h"
|
|
||||||
#include "BMACommand.h"
|
|
||||||
class BMATCPSocket;
|
|
||||||
|
|
||||||
class BMAPOP3Server : public BMATCPServerSocket {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMAPOP3Server(BMAEPoll &ePoll, std::string url, short int port);
|
|
||||||
~BMAPOP3Server();
|
|
||||||
|
|
||||||
BMASession * getSocketAccept();
|
|
||||||
|
|
||||||
void registerCommand(BMACommand &command);
|
|
||||||
|
|
||||||
int processCommand(BMASession *session) override; ///<Output the consoles array to the console.
|
|
||||||
|
|
||||||
std::vector<BMACommand *> commands;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,34 +0,0 @@
|
|||||||
#ifndef __BMAPOP3Session_h__
|
|
||||||
#define __BMAPOP3Session_h__
|
|
||||||
|
|
||||||
#include "BMASession.h"
|
|
||||||
#include "BMAPOP3Server.h"
|
|
||||||
|
|
||||||
///
|
|
||||||
/// BMAPOP3Session
|
|
||||||
///
|
|
||||||
/// Extends the session parameters for this BMATCPSocket derived object.
|
|
||||||
/// Extend the protocol() method in order to define the behavior and
|
|
||||||
/// protocol interaction for this socket which is a console session.
|
|
||||||
///
|
|
||||||
|
|
||||||
class BMAPOP3Session : public BMASession {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMAPOP3Session(BMAEPoll &ePoll, BMAPOP3Server &server);
|
|
||||||
~BMAPop3Session();
|
|
||||||
|
|
||||||
virtual void output(std::stringstream &out);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void protocol(char *data, int length) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
BMAConsoleServer &server;
|
|
||||||
enum Status {WELCOME, PROMPT, INPUT, PROCESS, DONE};
|
|
||||||
Status status = WELCOME;
|
|
||||||
void doCommand(std::string request);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,31 +0,0 @@
|
|||||||
#ifndef BMAConsoleServer_h__
|
|
||||||
#define BMAConsoleServer_h__
|
|
||||||
|
|
||||||
#include "includes"
|
|
||||||
#include "BMATCPServerSocket.h"
|
|
||||||
#include "BMACommand.h"
|
|
||||||
class BMATCPSocket;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// BMASMTPServer
|
|
||||||
///
|
|
||||||
/// Use this object to create a fully supported SMTP server.
|
|
||||||
///
|
|
||||||
|
|
||||||
class BMASMTPServer : public BMATCPServerSocket {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMASMTPServer(BMAEPoll &ePoll, std::string url, short int port);
|
|
||||||
~BMASMTPServer();
|
|
||||||
|
|
||||||
BMASession * getSocketAccept() override;
|
|
||||||
|
|
||||||
void registerCommand(BMACommand &command);
|
|
||||||
|
|
||||||
int processCommand(BMASession *session) override; ///<Output the consoles array to the console.
|
|
||||||
|
|
||||||
std::vector<BMACommand *> commands;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
@ -1,33 +0,0 @@
|
|||||||
#ifndef __BMASMTPSession_h__
|
|
||||||
#define __BMASMTPSession_h__
|
|
||||||
|
|
||||||
#include "BMASession.h"
|
|
||||||
|
|
||||||
///
|
|
||||||
/// BMAConsoleSession
|
|
||||||
///
|
|
||||||
/// Extends the session parameters for this BMATCPSocket derived object.
|
|
||||||
/// Extend the protocol() method in order to define the behavior and
|
|
||||||
/// protocol interaction for this socket which is a console session.
|
|
||||||
///
|
|
||||||
|
|
||||||
class BMASMTPSession : public BMASession {
|
|
||||||
|
|
||||||
public:
|
|
||||||
BMAConsoleSession(BMAEPoll &ePoll, BMAConsoleServer &server);
|
|
||||||
~BMAConsoleSession();
|
|
||||||
|
|
||||||
virtual void output(std::stringstream &out);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
void protocol(char *data, int length) override;
|
|
||||||
|
|
||||||
private:
|
|
||||||
BMAConsoleServer &server;
|
|
||||||
enum Status {WELCOME, PROMPT, INPUT, PROCESS, DONE};
|
|
||||||
Status status = WELCOME;
|
|
||||||
void doCommand(std::string request);
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
51
IMAPService.h
Normal file
51
IMAPService.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __IMAPService_h__
|
||||||
|
#define __IMAPService_h__
|
||||||
|
|
||||||
|
#include "Service.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "__SMTP_AUTH.h"
|
||||||
|
#include "__SMTP_DATA.h"
|
||||||
|
#include "__SMTP_EHLO.h"
|
||||||
|
#include "__SMTP_HELO.h"
|
||||||
|
#include "__SMTP_MAIL.h"
|
||||||
|
#include "__SMTP_NOOP.h"
|
||||||
|
#include "__SMTP_QUIT.h"
|
||||||
|
#include "__SMTP_RCPT.h"
|
||||||
|
#include "__SMTP_RSET.h"
|
||||||
|
#include "__SMTP_VRFY.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class IMAPService : public core::Service {
|
||||||
|
|
||||||
|
public:
|
||||||
|
IMAPService() {
|
||||||
|
commands.add(_smtp_auth, "AUTH");
|
||||||
|
commands.add(_smtp_data, "DATA");
|
||||||
|
commands.add(_smtp_ehlo, "EHLO");
|
||||||
|
commands.add(_smtp_helo, "HELO");
|
||||||
|
commands.add(_smtp_mail, "MAIL");
|
||||||
|
commands.add(_smtp_noop, "NOOP");
|
||||||
|
commands.add(_smtp_quit, "QUIT");
|
||||||
|
commands.add(_smtp_rcpt, "RCPT");
|
||||||
|
commands.add(_smtp_rset, "RSET");
|
||||||
|
commands.add(_smtp_vrfy, "VRFY");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
__SMTP_AUTH _smtp_auth;
|
||||||
|
__SMTP_DATA _smtp_data;
|
||||||
|
__SMTP_EHLO _smtp_ehlo;
|
||||||
|
__SMTP_HELO _smtp_helo;
|
||||||
|
__SMTP_MAIL _smtp_mail;
|
||||||
|
__SMTP_NOOP _smtp_noop;
|
||||||
|
__SMTP_QUIT _smtp_quit;
|
||||||
|
__SMTP_RCPT _smtp_rcpt;
|
||||||
|
__SMTP_RSET _smtp_rset;
|
||||||
|
__SMTP_VRFY _smtp_vrfy;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
POP3Service.h
Normal file
51
POP3Service.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __POP3Service_h__
|
||||||
|
#define __POP3Service_h__
|
||||||
|
|
||||||
|
#include "Service.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "__SMTP_AUTH.h"
|
||||||
|
#include "__SMTP_DATA.h"
|
||||||
|
#include "__SMTP_EHLO.h"
|
||||||
|
#include "__SMTP_HELO.h"
|
||||||
|
#include "__SMTP_MAIL.h"
|
||||||
|
#include "__SMTP_NOOP.h"
|
||||||
|
#include "__SMTP_QUIT.h"
|
||||||
|
#include "__SMTP_RCPT.h"
|
||||||
|
#include "__SMTP_RSET.h"
|
||||||
|
#include "__SMTP_VRFY.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class POP3Service : public core::Service {
|
||||||
|
|
||||||
|
public:
|
||||||
|
POP3Service() {
|
||||||
|
commands.add(_smtp_auth, "AUTH");
|
||||||
|
commands.add(_smtp_data, "DATA");
|
||||||
|
commands.add(_smtp_ehlo, "EHLO");
|
||||||
|
commands.add(_smtp_helo, "HELO");
|
||||||
|
commands.add(_smtp_mail, "MAIL");
|
||||||
|
commands.add(_smtp_noop, "NOOP");
|
||||||
|
commands.add(_smtp_quit, "QUIT");
|
||||||
|
commands.add(_smtp_rcpt, "RCPT");
|
||||||
|
commands.add(_smtp_rset, "RSET");
|
||||||
|
commands.add(_smtp_vrfy, "VRFY");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
__SMTP_AUTH _smtp_auth;
|
||||||
|
__SMTP_DATA _smtp_data;
|
||||||
|
__SMTP_EHLO _smtp_ehlo;
|
||||||
|
__SMTP_HELO _smtp_helo;
|
||||||
|
__SMTP_MAIL _smtp_mail;
|
||||||
|
__SMTP_NOOP _smtp_noop;
|
||||||
|
__SMTP_QUIT _smtp_quit;
|
||||||
|
__SMTP_RCPT _smtp_rcpt;
|
||||||
|
__SMTP_RSET _smtp_rset;
|
||||||
|
__SMTP_VRFY _smtp_vrfy;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
51
SMTPService.h
Normal file
51
SMTPService.h
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
#ifndef __SMTPService_h__
|
||||||
|
#define __SMTPService_h__
|
||||||
|
|
||||||
|
#include "Service.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "__SMTP_AUTH.h"
|
||||||
|
#include "__SMTP_DATA.h"
|
||||||
|
#include "__SMTP_EHLO.h"
|
||||||
|
#include "__SMTP_HELO.h"
|
||||||
|
#include "__SMTP_MAIL.h"
|
||||||
|
#include "__SMTP_NOOP.h"
|
||||||
|
#include "__SMTP_QUIT.h"
|
||||||
|
#include "__SMTP_RCPT.h"
|
||||||
|
#include "__SMTP_RSET.h"
|
||||||
|
#include "__SMTP_VRFY.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class SMTPService : public core::Service {
|
||||||
|
|
||||||
|
public:
|
||||||
|
SMTPService() {
|
||||||
|
commands.add(_smtp_auth, "AUTH");
|
||||||
|
commands.add(_smtp_data, "DATA");
|
||||||
|
commands.add(_smtp_ehlo, "EHLO");
|
||||||
|
commands.add(_smtp_helo, "HELO");
|
||||||
|
commands.add(_smtp_mail, "MAIL");
|
||||||
|
commands.add(_smtp_noop, "NOOP");
|
||||||
|
commands.add(_smtp_quit, "QUIT");
|
||||||
|
commands.add(_smtp_rcpt, "RCPT");
|
||||||
|
commands.add(_smtp_rset, "RSET");
|
||||||
|
commands.add(_smtp_vrfy, "VRFY");
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
__SMTP_AUTH _smtp_auth;
|
||||||
|
__SMTP_DATA _smtp_data;
|
||||||
|
__SMTP_EHLO _smtp_ehlo;
|
||||||
|
__SMTP_HELO _smtp_helo;
|
||||||
|
__SMTP_MAIL _smtp_mail;
|
||||||
|
__SMTP_NOOP _smtp_noop;
|
||||||
|
__SMTP_QUIT _smtp_quit;
|
||||||
|
__SMTP_RCPT _smtp_rcpt;
|
||||||
|
__SMTP_RSET _smtp_rset;
|
||||||
|
__SMTP_VRFY _smtp_vrfy;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
17
SMTPSession.h
Normal file
17
SMTPSession.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
#ifndef __SMTPSession_h__
|
||||||
|
#define __SMTPSession_h__
|
||||||
|
|
||||||
|
#include "includes"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class SMTPSession : public core::Session {
|
||||||
|
|
||||||
|
public:
|
||||||
|
std::string state;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_AUTH : public core::Command {
|
class __SMTP_AUTH : public core::Command {
|
||||||
|
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
#ifndef ____SMTP_DATA_h__
|
||||||
|
#define ____SMTP_DATA_h__
|
||||||
|
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class __SMTP_DATA : public core::Command {
|
||||||
|
|
||||||
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
|
||||||
|
data << "" << std::endl;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// DATA command request handling.
|
// DATA command request handling.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
//---------------------------------------------------------------------------
|
#ifndef ____SMTP_EHLO_h__
|
||||||
// EHLO command request handling.
|
#define ____SMTP_EHLO_h__
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
else if(command(input) == "EHLO") {
|
#include "Command.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class __SMTP_EHLO : public core::Command {
|
||||||
|
|
||||||
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
|
||||||
if(input.length() > 5) {
|
if(input.length() > 5) {
|
||||||
string hostName = input.substr(5);
|
string hostName = input.substr(5);
|
||||||
@ -14,12 +19,12 @@
|
|||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
cout << "250-" << getHostName() << CRLF;
|
data << "250-" << getHostName() << CRLF;
|
||||||
// cout << "250-STARTTLS" << CRLF;
|
// cout << "250-STARTTLS" << CRLF;
|
||||||
// cout << "250-PIPELINING" << CRLF;
|
// cout << "250-PIPELINING" << CRLF;
|
||||||
// cout << "250-8BITMIME" << CRLF;
|
// cout << "250-8BITMIME" << CRLF;
|
||||||
cout << "250-AUTH LOGIN" << CRLF;
|
data << "250-AUTH LOGIN" << CRLF;
|
||||||
cout << "250 HELP" << CRLF;
|
data << "250 HELP" << CRLF;
|
||||||
state = "READY";
|
session->state = "READY";
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,16 @@
|
|||||||
|
#ifndef ____SMTP_HELO_h__
|
||||||
|
#define ____SMTP_HELO_h__
|
||||||
|
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class __SMTP_HELO : public core::Command {
|
||||||
|
|
||||||
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
|
||||||
|
data << "" << std::endl;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// HELO command request handling.
|
// HELO command request handling.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -1,3 +1,16 @@
|
|||||||
|
#ifndef ____SMTP_MAIL_h__
|
||||||
|
#define ____SMTP_MAIL_h__
|
||||||
|
|
||||||
|
#include "Command.h"
|
||||||
|
|
||||||
|
namespace mail {
|
||||||
|
|
||||||
|
class __SMTP_MAIL : public core::Command {
|
||||||
|
|
||||||
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
|
||||||
|
data << "" << std::endl;
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
// MAIL command request handling.
|
// MAIL command request handling.
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
@ -1,21 +1,12 @@
|
|||||||
#ifndef ____SMTP_AUTH_h__
|
#ifndef ____SMTP_NOOP_h__
|
||||||
#define ____SMTP_AUTH_h__
|
#define ____SMTP_NOOP_h__
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_AUTH : public core::Command {
|
class __SMTP_NOOP : public core::Command {
|
||||||
|
|
||||||
int processCommand(std::string request, Session *session, std::stringstream &data);
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
data << "250 OK" << CRLF;
|
||||||
data << "" << std::endl;
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// NOOP command request handling.
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
else if(command(input) == "NOOP") {
|
|
||||||
cout << "250 OK" << CRLF;
|
|
||||||
log.message("Response: 250 OK.");
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,17 @@
|
|||||||
#ifndef ____SMTP_AUTH_h__
|
#ifndef ____SMTP_QUIT_h__
|
||||||
#define ____SMTP_AUTH_h__
|
#define ____SMTP_QUIT_h__
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_AUTH : public core::Command {
|
class __SMTP_QUIT : public core::Command {
|
||||||
|
|
||||||
int processCommand(std::string request, Session *session, std::stringstream &data);
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
data << "221 " << getHostName() << CRLF;
|
||||||
|
session->shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
data << "" << std::endl;
|
};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
}
|
||||||
// QUIT command request handling.
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
else if(command(input) == "QUIT") {
|
|
||||||
cout << "221 " << getHostName() << CRLF;
|
|
||||||
log.message("Response: 221 " + getHostName() + ".");
|
|
||||||
state = "QUIT";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
@ -1,22 +1,14 @@
|
|||||||
#ifndef ____SMTP_AUTH_h__
|
#ifndef ____SMTP_RCPT_h__
|
||||||
#define ____SMTP_AUTH_h__
|
#define ____SMTP_RCPT_h__
|
||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_AUTH : public core::Command {
|
class __SMTP_RCPT : public core::Command {
|
||||||
|
|
||||||
int processCommand(std::string request, Session *session, std::stringstream &data);
|
int processCommand(std::string request, Session *session, std::stringstream &data);
|
||||||
|
|
||||||
data << "" << std::endl;
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
// RCPT command request handling.
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
else if(command(input) == "RCPT") {
|
|
||||||
|
|
||||||
if((state == "MAIL") || (state == "RCPT")) {
|
if((state == "MAIL") || (state == "RCPT")) {
|
||||||
|
|
||||||
bool done = false;
|
bool done = false;
|
||||||
@ -41,8 +33,7 @@ namespace http {
|
|||||||
//-----------------------------------------------
|
//-----------------------------------------------
|
||||||
|
|
||||||
recipientList += aliasRecipients;
|
recipientList += aliasRecipients;
|
||||||
cout << "250 OK" << CRLF;
|
data << "250 OK" << CRLF;
|
||||||
log.message("Response: 250 OK.");
|
|
||||||
state = "RCPT";
|
state = "RCPT";
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -65,8 +56,7 @@ namespace http {
|
|||||||
//------------------------------------------
|
//------------------------------------------
|
||||||
|
|
||||||
recipientList += cleanEMail(recipient) + " ";
|
recipientList += cleanEMail(recipient) + " ";
|
||||||
cout << "250 OK" << CRLF;
|
data << "250 OK" << CRLF;
|
||||||
log.message("Response: 250 OK.");
|
|
||||||
state = "RCPT";
|
state = "RCPT";
|
||||||
done = true;
|
done = true;
|
||||||
}
|
}
|
||||||
@ -162,4 +152,11 @@ namespace http {
|
|||||||
cout << "503 Please use MAIL first" << CRLF;
|
cout << "503 Please use MAIL first" << CRLF;
|
||||||
log.message("Response: 503 Please use MAIL first.");
|
log.message("Response: 503 Please use MAIL first.");
|
||||||
}
|
}
|
||||||
}
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_RSET : public core::Command {
|
class __SMTP_RSET : public core::Command {
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
#include "Command.h"
|
#include "Command.h"
|
||||||
|
|
||||||
namespace http {
|
namespace mail {
|
||||||
|
|
||||||
class __SMTP_VRFY : public core::Command {
|
class __SMTP_VRFY : public core::Command {
|
||||||
|
|
||||||
|
50
main.cpp
50
main.cpp
@ -1,7 +1,47 @@
|
|||||||
#include <stdio.h>
|
#include "includes"
|
||||||
|
#include "EPoll.h"
|
||||||
|
#include "ConsoleServer.h"
|
||||||
|
#include "Exception.h"
|
||||||
|
#include "File.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "IPAddress.h"
|
||||||
|
#include "HTTPService.h"
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv) {
|
||||||
{
|
|
||||||
printf("hello world\n");
|
try {
|
||||||
return 0;
|
|
||||||
|
coreutils::Log(new coreutils::File("/var/log/mail.log", O_WRONLY | O_APPEND | O_CREAT, 0644));
|
||||||
|
coreutils::Log(coreutils::LOG_INFO) << "BMAMail Server starting. Build " << __DATE__ << " " << __TIME__;
|
||||||
|
|
||||||
|
std::string ipAddress = "0.0.0.0";
|
||||||
|
|
||||||
|
core::EPoll ePoll;
|
||||||
|
|
||||||
|
mail::SMTPService smtpService;
|
||||||
|
core::TCPServerSocket smtp(ePoll, smtpService, core::IPAddress(ipAddress, 25));
|
||||||
|
|
||||||
|
mail::POP3Service pop3Service;
|
||||||
|
core::TCPServerSocket pop3(ePoll, pop3Service, core::IPAddress(ipAddress, 110));
|
||||||
|
|
||||||
|
mail::IMAPService imapService;
|
||||||
|
core::TCPServerSocket imap(ePoll, imapService, core::IPAddress(ipAddress, 143));
|
||||||
|
|
||||||
|
core::ConsoleService consoleService;
|
||||||
|
core::TCPServerSocket console(ePoll, consoleService, core::IPAddress(ipAddress, 1027));
|
||||||
|
consoleService.commands.add(consoleService.commands, "help");
|
||||||
|
ePoll.start(16, 1000);
|
||||||
|
|
||||||
|
while(true)
|
||||||
|
sleep(300);
|
||||||
|
|
||||||
|
ePoll.stop();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
catch(coreutils::Exception exception) {
|
||||||
|
std::cout << exception.text << " Error reason is '" << strerror(exception.errorNumber) << "' in file " << exception.file << " at line " << exception.line << std::endl;
|
||||||
|
sleep(10);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user