21#ifndef G_SMTP_SERVER_H
22#define G_SMTP_SERVER_H
52 using AddressList = std::vector<GNet::Address> ;
56 bool allow_remote{
false} ;
58 unsigned int port{0U} ;
60 bool anonymous{
false} ;
61 std::string filter_address ;
62 unsigned int filter_timeout{0U} ;
63 std::string verifier_address ;
64 unsigned int verifier_timeout{0U} ;
68 std::string sasl_server_config ;
69 std::string dnsbl_config ;
73 const std::string & ident ,
bool anonymous ,
const std::string & filter_address ,
74 unsigned int filter_timeout ,
const std::string & verifier_adress ,
77 const std::string & dnsbl_config ) ;
78 Config & set_allow_remote(
bool =
true ) ;
80 Config & set_port(
unsigned int ) ;
81 Config & set_ident(
const std::string & ) ;
82 Config & set_anonymous(
bool =
true ) ;
83 Config & set_filter_address(
const std::string & ) ;
84 Config & set_filter_timeout(
unsigned int ) ;
85 Config & set_verifier_address(
const std::string & ) ;
86 Config & set_verifier_timeout(
unsigned int ) ;
90 Config & set_sasl_server_config(
const std::string & ) ;
91 Config & set_dnsbl_config(
const std::string & ) ;
96 const Config & server_config ,
const std::string & forward_to ,
123 void operator=(
const Server & ) = delete ;
124 void operator=(
Server && ) = delete ;
128 std::unique_ptr<ProtocolMessage> newProtocolMessageStore( std::unique_ptr<Filter> ) ;
129 std::unique_ptr<ProtocolMessage> newProtocolMessageForward(
GNet::ExceptionSink , std::unique_ptr<ProtocolMessage> ) ;
130 std::unique_ptr<ServerProtocol::Text> newProtocolText(
bool ,
const GNet::Address & )
const ;
138 std::string m_sasl_server_config ;
139 std::string m_forward_to ;
141 std::string m_sasl_client_config ;
152 G_EXCEPTION( SendError ,
"failed to send smtp response" ) ;
156 std::unique_ptr<ServerProtocol::Text> ptext ) ;
160 void onSendComplete()
override ;
161 void onDelete(
const std::string & reason )
override ;
162 bool onReceive(
const char * , std::size_t , std::size_t , std::size_t ,
char )
override ;
163 void onSecure(
const std::string & ,
const std::string & ,
const std::string & )
override ;
164 void protocolSend(
const std::string & line ,
bool )
override ;
165 void protocolShutdown()
override ;
167 void onData(
const char * , std::size_t )
override ;
173 void operator=(
const ServerPeer & ) = delete ;
177 void onCheckTimeout() ;
178 void onFlushTimeout() ;
185 std::unique_ptr<Verifier> m_verifier ;
186 std::unique_ptr<ProtocolMessage> m_pmessage ;
187 std::unique_ptr<ServerProtocol::Text> m_ptext ;
192inline GSmtp::Server::Config & GSmtp::Server::Config::set_allow_remote(
bool b ) { allow_remote = b ;
return *this ; }
194inline GSmtp::Server::Config & GSmtp::Server::Config::set_port(
unsigned int n ) { port = n ;
return *this ; }
195inline GSmtp::Server::Config & GSmtp::Server::Config::set_ident(
const std::string & s ) { ident = s ;
return *this ; }
196inline GSmtp::Server::Config & GSmtp::Server::Config::set_anonymous(
bool b ) { anonymous = b ;
return *this ; }
197inline GSmtp::Server::Config & GSmtp::Server::Config::set_filter_address(
const std::string & s ) { filter_address = s ;
return *this ; }
198inline GSmtp::Server::Config & GSmtp::Server::Config::set_filter_timeout(
unsigned int t ) { filter_timeout = t ;
return *this ; }
199inline GSmtp::Server::Config & GSmtp::Server::Config::set_verifier_address(
const std::string & s ) { verifier_address = s ;
return *this ; }
200inline GSmtp::Server::Config & GSmtp::Server::Config::set_verifier_timeout(
unsigned int t ) { verifier_timeout = t ;
return *this ; }
203inline GSmtp::Server::Config & GSmtp::Server::Config::set_protocol_config(
const ServerProtocol::Config & c ) { protocol_config = c ;
return *this ; }
204inline GSmtp::Server::Config & GSmtp::Server::Config::set_sasl_server_config(
const std::string & s ) { sasl_server_config = s ;
return *this ; }
205inline GSmtp::Server::Config & GSmtp::Server::Config::set_dnsbl_config(
const std::string & s ) { dnsbl_config = s ;
return *this ; }
An interface used by GAuth::SaslClient to obtain a client id and its authentication secret.
An interface used by GAuth::SaslServer to obtain authentication secrets.
The GNet::Address class encapsulates a TCP/UDP transport address.
A callback interface for GNet::DnsBlock.
A result structure for GNet::DnsBlock, as delivered by the DnsBlockCallback interface.
Implements DNS blocklisting, as per RFC-5782.
A potential ExceptionSink that is realised by bind()ing an exception source pointer.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
A class that does line buffering, supporting auto-detection of line endings and fixed-size block extr...
A server that listens on more than one address using a facade pattern to multiple GNet::Server instan...
A structure that GNet::Server uses to configure its ServerPeer objects.
A structure used in GNet::Server::newPeer().
An abstract base class for the GNet::Server's connection to a remote client.
A timer class template in which the timeout is delivered to the specified method.
A factory interface for GSmtp::Filter message processors.
A class which allows SMTP messages to be stored and retrieved.
Handles a connection from a remote SMTP client.
ServerPeer(GNet::ExceptionSinkUnbound, const GNet::ServerPeerInfo &peer_info, Server &server, const GAuth::SaslServerSecrets &server_secrets, const Server::Config &server_config, std::unique_ptr< ServerProtocol::Text > ptext)
Constructor.
An interface used by ServerProtocol to send protocol replies.
Implements the SMTP server-side protocol.
G::Slot::Signal< const std::string &, const std::string & > & eventSignal()
Returns a signal that indicates that something has happened.
~Server() override
Destructor.
Server(GNet::ExceptionSink es, MessageStore &store, FilterFactory &, const GAuth::SaslClientSecrets &client_secrets, const GAuth::SaslServerSecrets &server_secrets, const Config &server_config, const std::string &forward_to, const GSmtp::Client::Config &client_config)
Constructor.
std::unique_ptr< ProtocolMessage > newProtocolMessage(GNet::ExceptionSink)
Called by GSmtp::ServerPeer to construct a ProtocolMessage.
void report() const
Generates helpful diagnostics after construction.
SMTP and message-store classes.
std::vector< std::string > StringArray
A std::vector of std::strings.
A structure used in GNet::MultiServer::newPeer().
A configuration structure for GNet::Server.
A structure containing GSmtp::Client configuration parameters.
A structure containing configuration parameters for ServerProtocol.
A structure containing GSmtp::Server configuration parameters.