21 #ifndef G_SMTP_SERVER_PROTOCOL_H
22 #define G_SMTP_SERVER_PROTOCOL_H
42 class ServerProtocol ;
43 class ServerProtocolText ;
61 G_EXCEPTION( ProtocolDone ,
"smtp protocol done" ) ;
65 public:
virtual void protocolSend(
const std::string & s ,
bool go_secure ) = 0 ;
67 private:
void operator=(
const Sender & ) ;
72 public:
virtual std::string
greeting()
const = 0 ;
73 public:
virtual std::string
hello(
const std::string & smtp_peer_name )
const = 0 ;
74 public:
virtual std::string
received(
const std::string & smtp_peer_name )
const = 0 ;
75 public:
virtual ~Text() ;
76 private:
void operator=(
const Text & ) ;
84 Config(
bool ,
unsigned int ) ;
89 const std::string & peer_socket_name ,
Config config ) ;
112 void apply(
const std::string & line ) ;
117 void secure(
const std::string & certificate ) ;
179 void send( std::string ,
bool =
false ) ;
180 Event commandEvent(
const std::string & )
const ;
181 std::string commandWord(
const std::string & line )
const ;
182 std::string commandLine(
const std::string & line )
const ;
183 static const std::string & crlf() ;
184 bool sensitive()
const ;
186 void badClientEvent() ;
187 void processDone(
bool ,
unsigned long , std::string ) ;
188 void prepareDone(
bool ,
bool , std::string ) ;
189 bool isEndOfText(
const std::string & )
const ;
190 bool isEscaped(
const std::string & )
const ;
191 void doNoop(
const std::string & ,
bool & ) ;
192 void doNothing(
const std::string & ,
bool & ) ;
193 void doDiscarded(
const std::string & ,
bool & ) ;
194 void doDiscard(
const std::string & ,
bool & ) ;
195 void doHelp(
const std::string & line ,
bool & ) ;
196 void doExpn(
const std::string & line ,
bool & ) ;
197 void doQuit(
const std::string & ,
bool & ) ;
198 void doEhlo(
const std::string & ,
bool & ) ;
199 void doHelo(
const std::string & ,
bool & ) ;
200 void doAuth(
const std::string & ,
bool & ) ;
201 void doAuthData(
const std::string & ,
bool & ) ;
202 void doMail(
const std::string & ,
bool & ) ;
203 void doRcpt(
const std::string & ,
bool & ) ;
204 void doUnknown(
const std::string & ,
bool & ) ;
205 void doRset(
const std::string & ,
bool & ) ;
206 void doData(
const std::string & ,
bool & ) ;
207 void doContent(
const std::string & ,
bool & ) ;
208 void doComplete(
const std::string & ,
bool & ) ;
209 void doEot(
const std::string & ,
bool & ) ;
210 void doVrfy(
const std::string & ,
bool & ) ;
211 void doVrfyReply(
const std::string & line ,
bool & ) ;
212 void doVrfyToReply(
const std::string & line ,
bool & ) ;
213 void doNoRecipients(
const std::string & ,
bool & ) ;
214 void doStartTls(
const std::string & ,
bool & ) ;
215 void doSecure(
const std::string & ,
bool & ) ;
216 void verifyDone( std::string , VerifierStatus status ) ;
217 void sendBadFrom( std::string ) ;
218 void sendTooBig(
bool disconnecting =
false ) ;
219 void sendChallenge(
const std::string & ) ;
220 void sendBadTo(
const std::string & ,
bool ) ;
221 void sendOutOfSequence(
const std::string & ) ;
222 void sendGreeting(
const std::string & ) ;
224 void sendUnrecognised(
const std::string & ) ;
225 void sendNotImplemented() ;
226 void sendHeloReply() ;
227 void sendEhloReply() ;
228 void sendRsetReply() ;
229 void sendMailReply() ;
230 void sendRcptReply() ;
231 void sendDataReply() ;
232 void sendCompletionReply(
bool ok ,
const std::string & ) ;
233 void sendAuthRequired() ;
234 void sendNoRecipients() ;
235 void sendMissingParameter() ;
236 void sendVerified(
const std::string & ) ;
237 void sendNotVerified(
const std::string & ,
bool ) ;
238 void sendWillAccept(
const std::string & ) ;
239 void sendAuthDone(
bool ok ) ;
241 std::pair<std::string,std::string> parse(
const std::string & )
const ;
242 std::pair<std::string,std::string> parseFrom(
const std::string & )
const ;
243 std::pair<std::string,std::string> parseTo(
const std::string & )
const ;
244 std::string parseToParameter(
const std::string & )
const ;
245 std::string parsePeerName(
const std::string & )
const ;
246 void verify(
const std::string & ,
const std::string & ) ;
250 Verifier & m_verifier ;
251 ProtocolMessage & m_pmessage ;
254 std::string m_peer_socket_name ;
256 std::string m_smtp_peer_name ;
257 bool m_authenticated ;
259 std::string m_certificate ;
260 std::auto_ptr<GAuth::SaslServer> m_sasl ;
263 std::string m_buffer ;
264 unsigned int m_preprocessor_timeout ;
265 unsigned int m_bad_client_count ;
266 unsigned int m_bad_client_limit ;
267 bool m_disconnect_on_overflow ;
278 const GNet::Address & peer_address ,
const std::string & peer_socket_name ) ;
281 virtual std::string
greeting()
const ;
284 virtual std::string
hello(
const std::string & smtp_peer_name_from_helo )
const ;
287 virtual std::string
received(
const std::string & smtp_peer_name_from_helo )
const ;
290 static std::string
receivedLine(
const std::string & smtp_peer_name_from_helo ,
291 const std::string & peer_address ,
const std::string & peer_socket_name ,
292 const std::string & thishost ) ;
296 static std::string shortened( std::string , std::string ) ;
299 std::string m_ident ;
300 std::string m_thishost ;
302 std::string m_peer_socket_name ;
void secure(const std::string &certificate)
To be called when the transport protocol goes into secure mode.
ServerProtocolText(const std::string &ident, const std::string &thishost, const GNet::Address &peer_address, const std::string &peer_socket_name)
Constructor.
An interface used by ServerProtocol to send protocol replies.
virtual void onTimeout()
Final override from GNet::AbstractTimer.
SMTP and message-store classes.
virtual void onTimeoutException(std::exception &)
Final override from GNet::AbstractTimer.
An interface used by ServerProtocol to provide response text strings.
virtual std::string received(const std::string &smtp_peer_name_from_helo) const
Final override from GSmtp::ServerProtocol::Text.
ServerProtocol(Sender &sender, Verifier &verifier, ProtocolMessage &pmessage, const GAuth::Secrets &secrets, Text &text, GNet::Address peer_address, const std::string &peer_socket_name, Config config)
Constructor.
virtual std::string greeting() const =0
The Address class encapsulates an IP transport address.
void apply(const std::string &line)
Called on receipt of a string from the client.
virtual void protocolSend(const std::string &s, bool go_secure)=0
Implements the SMTP server-side protocol.
virtual std::string received(const std::string &smtp_peer_name) const =0
An asynchronous interface that verifies recipient 'to' addresses.
unsigned int preprocessor_timeout
Config(bool, unsigned int)
void init()
Starts the protocol. Use only once after construction.
A simple interface to a store of secrets as used in authentication.
virtual ~ServerProtocol()
Destructor.
A default implementation for the ServerProtocol::Text interface.
bool disconnect_on_overflow
A structure containing configuration parameters for ServerProtocol.
#define G_EXCEPTION(class_name, description)
define as a function rather than a type if optimising for size
An interface used by the ServerProtocol class to assemble and process an incoming message...
virtual std::string hello(const std::string &smtp_peer_name) const =0
virtual std::string hello(const std::string &smtp_peer_name_from_helo) const
Final override from GSmtp::ServerProtocol::Text.
static std::string receivedLine(const std::string &smtp_peer_name_from_helo, const std::string &peer_address, const std::string &peer_socket_name, const std::string &thishost)
Returns a standard "Received:" line.
virtual std::string greeting() const
Final override from GSmtp::ServerProtocol::Text.
A timer base class that calls a pure virtual method on expiry.