E-MailRelay
|
Implements the SMTP server-side protocol. More...
#include <gsmtpserverprotocol.h>
Classes | |
struct | Config |
A structure containing configuration parameters for ServerProtocol. More... | |
class | Sender |
An interface used by ServerProtocol to send protocol replies. More... | |
class | Text |
An interface used by ServerProtocol to provide response text strings. More... | |
Public Member Functions | |
ServerProtocol (Sender &, Verifier &, ProtocolMessage &, const GAuth::SaslServerSecrets &secrets, const std::string &sasl_server_config, Text &text, const GNet::Address &peer_address, const Config &config) | |
Constructor. More... | |
void | init () |
Starts the protocol. More... | |
virtual | ~ServerProtocol () |
Destructor. More... | |
bool | inDataState () const |
Returns true if currently in the data-transfer state. More... | |
bool | halfDuplexBusy () const |
Returns true if the protocol has received a command but not yet sent a response. More... | |
bool | halfDuplexBusy (const char *, std::size_t) const |
This overload is used for a newly-received network packet. More... | |
bool | apply (const char *line_data, std::size_t line_size, std::size_t eolsize, std::size_t linesize, char c0) |
Called on receipt of a line of text from the remote client. More... | |
void | secure (const std::string &certificate, const std::string &protocol, const std::string &cipher) |
To be called when the transport protocol goes into secure mode. More... | |
ServerProtocol (const ServerProtocol &)=delete | |
ServerProtocol (ServerProtocol &&)=delete | |
void | operator= (const ServerProtocol &)=delete |
void | operator= (ServerProtocol &&)=delete |
Implements the SMTP server-side protocol.
Uses the ProtocolMessage class as its down-stream interface, used for assembling and processing the incoming email messages.
Uses the ServerProtocol::Sender as its "sideways" interface to talk back to the email-sending client.
Definition at line 55 of file gsmtpserverprotocol.h.
GSmtp::ServerProtocol::ServerProtocol | ( | Sender & | sender, |
Verifier & | verifier, | ||
ProtocolMessage & | pmessage, | ||
const GAuth::SaslServerSecrets & | secrets, | ||
const std::string & | sasl_server_config, | ||
Text & | text, | ||
const GNet::Address & | peer_address, | ||
const Config & | config | ||
) |
Constructor.
The Verifier interface is used to verify recipient addresses. See GSmtp::Verifier.
The ProtocolMessage interface is used to assemble and process an incoming message.
The Sender interface is used to send protocol replies back to the client.
The Text interface is used to get informational text for returning to the client.
Exceptions thrown out of event-loop and timer callbacks are delivered to the given exception sink.
All references are kept.
Definition at line 37 of file gsmtpserverprotocol.cpp.
|
virtual |
Destructor.
Definition at line 123 of file gsmtpserverprotocol.cpp.
bool GSmtp::ServerProtocol::apply | ( | const char * | line_data, |
std::size_t | line_size, | ||
std::size_t | eolsize, | ||
std::size_t | linesize, | ||
char | c0 | ||
) |
Called on receipt of a line of text from the remote client.
As an optimisation this can also be a GNet::LineBuffer line fragment iff this object is currently inDataState(). Returns true. Throws ProtocolDone at the end of the protocol.
Definition at line 191 of file gsmtpserverprotocol.cpp.
bool GSmtp::ServerProtocol::halfDuplexBusy | ( | ) | const |
Returns true if the protocol has received a command but not yet sent a response.
This can be used to enforce half-duplex operation on a badly-behaved client that is attempting to do command pipelining.
Definition at line 178 of file gsmtpserverprotocol.cpp.
bool GSmtp::ServerProtocol::halfDuplexBusy | ( | const char * | , |
std::size_t | |||
) | const |
This overload is used for a newly-received network packet.
If it returns true then the packet should be queued up and only apply()d after then next use of Sender::protocolSend().
Definition at line 173 of file gsmtpserverprotocol.cpp.
bool GSmtp::ServerProtocol::inDataState | ( | ) | const |
Returns true if currently in the data-transfer state.
This can be used to enable the GNet::LineBuffer 'fragments' option.
Definition at line 166 of file gsmtpserverprotocol.cpp.
void GSmtp::ServerProtocol::init | ( | ) |
Starts the protocol.
Use only once after construction. The implementation uses the Sender interface to either send the plaintext SMTP greeting or start the TLS handshake.
Definition at line 115 of file gsmtpserverprotocol.cpp.
void GSmtp::ServerProtocol::secure | ( | const std::string & | certificate, |
const std::string & | protocol, | ||
const std::string & | cipher | ||
) |
To be called when the transport protocol goes into secure mode.
Definition at line 129 of file gsmtpserverprotocol.cpp.