41 AnonymousText(
const std::string & thishost ,
const GNet::Address & peer_address ,
const std::string & peer_socket_name ) ;
42 virtual std::string
greeting()
const ;
43 virtual std::string
hello(
const std::string & peer_name )
const ;
44 virtual std::string
received(
const std::string & smtp_peer_name )
const ;
45 std::string m_thishost ;
47 std::string m_peer_socket_name ;
51 AnonymousText::AnonymousText(
const std::string & thishost ,
const GNet::Address & peer_address ,
const std::string & peer_socket_name ) :
52 m_thishost(thishost) ,
53 m_peer_address(peer_address) ,
54 m_peer_socket_name(peer_socket_name)
58 std::string AnonymousText::greeting()
const
63 std::string AnonymousText::hello(
const std::string & )
const
68 std::string AnonymousText::received(
const std::string & smtp_peer_name )
const
79 Server & server , std::auto_ptr<ProtocolMessage> pmessage ,
const GAuth::Secrets & server_secrets ,
80 const std::string & verifier_address ,
unsigned int verifier_timeout ,
81 std::auto_ptr<ServerProtocol::Text> ptext ,
83 GNet::BufferedServerPeer( peer_info , crlf() ) ,
85 m_verifier(
VerifierFactory::newVerifier(verifier_address,verifier_timeout) ) ,
86 m_pmessage( pmessage ) ,
88 m_protocol( *this , *m_verifier.get() , *m_pmessage.get() , server_secrets , *m_ptext.get() ,
89 peer_info.m_address , peer_info.m_name , protocol_config )
92 << (peer_info.
m_name.empty()?
"":
" ") << peer_info.
m_name ) ;
96 const std::string & GSmtp::ServerPeer::crlf()
98 static const std::string s(
"\015\012" ) ;
104 G_LOG_S(
"GSmtp::ServerPeer: smtp connection closed: " << reason << (reason.empty()?
"":
": ")
105 << peerAddress().second.displayString() ) ;
107 m_server.eventSignal().emit(
"done" , reason ) ;
118 m_protocol.apply( line ) ;
124 m_protocol.secure( certificate ) ;
127 void GSmtp::ServerPeer::protocolSend(
const std::string & line ,
bool go_secure )
139 GNet::MultiServer(
GNet::MultiServer::addressList(config.interfaces,config.port) , config.use_connection_lookup ) ,
141 m_processor_address(config.processor_address) ,
142 m_processor_timeout(config.processor_timeout) ,
143 m_client_config(client_config) ,
144 m_ident(config.ident) ,
145 m_allow_remote(config.allow_remote) ,
146 m_server_secrets(server_secrets) ,
147 m_smtp_server(smtp_server_address) ,
148 m_smtp_connection_timeout(smtp_connection_timeout) ,
149 m_client_secrets(client_secrets) ,
150 m_verifier_address(config.verifier_address) ,
151 m_verifier_timeout(config.verifier_timeout) ,
152 m_anonymous(config.anonymous)
164 return m_event_signal ;
169 serverReport(
"smtp" ) ;
179 G_WARNING(
"GSmtp::Server: configured to reject non-local smtp connection: " << reason ) ;
183 std::auto_ptr<ServerProtocol::Text> ptext( newProtocolText(m_anonymous,peer_info.
m_address,peer_info.
m_name) ) ;
184 std::auto_ptr<ProtocolMessage> pmessage( newProtocolMessage() ) ;
185 return new ServerPeer( peer_info , *
this , pmessage , m_server_secrets ,
186 m_verifier_address , m_verifier_timeout ,
189 catch( std::exception & e )
191 G_WARNING(
"GSmtp::Server: exception from new connection: " << e.what() ) ;
199 return new AnonymousText(
GNet::Local::fqdn() , peer_address , peer_socket_name ) ;
206 return new ProtocolMessageStore( m_store , processor ) ;
212 throw G::Exception(
"proxying disabled at build time" ) ;
214 return new ProtocolMessageForward( m_store , pm ,
215 m_client_config , m_client_secrets , m_smtp_server , m_smtp_connection_timeout ) ;
223 std::auto_ptr<ProtocolMessage> pmstore( newProtocolMessageStore(store_processor) ) ;
224 const bool do_forward = ! m_smtp_server.empty() ;
227 std::auto_ptr<ProtocolMessage> forward( newProtocolMessageForward(pmstore) ) ;
228 return forward.release() ;
232 return pmstore.release() ;
239 const std::string & ident_ ,
bool anonymous_ ,
240 const std::string & processor_address_ ,
241 unsigned int processor_timeout_ ,
242 const std::string & verifier_address_ ,
243 unsigned int verifier_timeout_ ,
244 bool use_connection_lookup_ ) :
245 allow_remote(allow_remote_) ,
247 interfaces(interfaces_) ,
249 anonymous(anonymous_) ,
250 processor_address(processor_address_) ,
251 processor_timeout(processor_timeout_) ,
252 verifier_address(verifier_address_) ,
253 verifier_timeout(verifier_timeout_) ,
254 use_connection_lookup(use_connection_lookup_)
virtual ~Server()
Destructor.
GNet::ServerPeer * newPeer(GNet::Server::PeerInfo)
From MultiServer.
An abstract base class for the GNet::Server's connection to a remote client.
Represents a connection from an SMTP client.
An interface used by ServerProtocol to provide response text strings.
static Processor * newProcessor(const std::string &address, unsigned int timeout)
Returns a Processor on the heap.
virtual std::string greeting() const =0
The Address class encapsulates an IP transport address.
static bool isLocal(const Address &)
Returns true if the given address appears to be local.
static std::string fqdn()
Returns the fully-qualified-domain-name.
Server(MessageStore &store, const GAuth::Secrets &client_secrets, const GAuth::Secrets &server_secrets, Config server_config, std::string smtp_server_address, unsigned int smtp_connection_timeout, GSmtp::Client::Config client_config)
Constructor.
void report() const
Generates helpful diagnostics after construction.
virtual std::string received(const std::string &smtp_peer_name) const =0
G::Signal2< std::string, std::string > & eventSignal()
Returns a signal that indicates that something has happened.
void init()
Starts the protocol. Use only once after construction.
A structure containing GSmtp::Server configuration parameters.
virtual bool onReceive(const std::string &line)
Final override from GNet::BufferedServerPeer.
std::string displayString(bool with_port=true, bool with_scope_id=false) const
Returns a string which represents the address for debugging and diagnostics purposes.
A class which allows SMTP messages (envelope+content) to be stored and retrieved. ...
A simple interface to a store of secrets as used in authentication.
virtual void onDelete(const std::string &reason)
Final override from GNet::ServerPeer.
virtual void onSecure(const std::string &)
Final override from GNet::SocketProtocolSink.
A default implementation for the ServerProtocol::Text interface.
A structure containing GSmtp::Client configuration parameters.
A factory for addresss verifiers.
A structure containing configuration parameters for ServerProtocol.
A general-purpose exception class derived from std::exception and containing a std::string.
virtual void onSendComplete()
Final override from GNet::BufferedServerPeer.
An interface used by the ServerProtocol class to assemble and process an incoming message...
Config(bool, unsigned int, const AddressList &, const std::string &, bool, const std::string &, unsigned int, const std::string &, unsigned int, bool)
ServerPeer(GNet::Server::PeerInfo, Server &server, std::auto_ptr< ProtocolMessage > pmessage, const GAuth::Secrets &, const std::string &verifier_address, unsigned int verifier_timeout, std::auto_ptr< ServerProtocol::Text > ptext, ServerProtocol::Config)
Constructor.
virtual std::string hello(const std::string &smtp_peer_name) const =0
std::list< Address > AddressList
A structure used in GNet::Server::newPeer().
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.