29 unsigned int connection_timeout ,
unsigned int response_timeout ) :
30 m_resolver_info(server) ,
31 m_connection_timeout(connection_timeout) ,
32 m_response_timeout(response_timeout) ,
35 G_DEBUG(
"GSmtp::NetworkVerifier::ctor: " << server ) ;
36 m_client.eventSignal().connect(
G::slot(*
this,&GSmtp::NetworkVerifier::clientEvent) ) ;
41 m_client.eventSignal().disconnect() ;
45 const std::string & mail_from_parameter ,
const GNet::Address & client_ip ,
46 const std::string & auth_mechanism ,
const std::string & auth_extra )
48 if( !m_lazy || m_client.get() == NULL )
50 m_client.reset(
new RequestClient(
"verify",
"",
"\n",m_resolver_info,m_connection_timeout,m_response_timeout) ) ;
54 args.push_back( to ) ;
58 args.push_back( mail_from_parameter ) ;
60 args.push_back( auth_mechanism ) ;
61 args.push_back( auth_extra ) ;
67 void GSmtp::NetworkVerifier::clientEvent( std::string s1 , std::string s2 )
69 G_DEBUG(
"GSmtp::NetworkVerifier::clientEvent: [" << s1 <<
"] [" << s2 <<
"]" ) ;
79 if( part.size() >= 1U && part[0U] ==
"100" )
82 status.
reason =
"abort request" ;
85 else if( part.size() >= 2U && part[0U] ==
"1" )
91 else if( part.size() >= 3U && part[0U] ==
"0" )
98 else if( part.size() >= 2U && ( part[0U] ==
"2" || part[0U] ==
"3" ) )
101 status.
reason = part[1U] ;
107 status.
reason =
"external verifier protocol error" ;
117 return m_done_signal ;
static std::string printable(const std::string &in, char escape= '\\')
Returns a printable represention of the given input string.
std::list< std::string > Strings
A std::list of std::strings.
static void splitIntoFields(const std::string &in, Strings &out, const std::string &seperators, char escape= '\0', bool discard_bogus_escapes=true)
Splits the string into fields.
The Address class encapsulates an IP transport address.
static std::string fqdn()
Returns the fully-qualified-domain-name.
std::vector< std::string > StringArray
A std::vector of std::strings.
Slot0 slot(T &object, void(T::*fn)())
Part of the slot/signal system.
virtual void reset()
Final override from GSmtp::Verifier.
virtual void verify(const std::string &rcpt_to_parameter, const std::string &mail_from_parameter, const GNet::Address &client_ip, const std::string &auth_mechanism, const std::string &auth_extra)
Final override from GSmtp::Verifier.
static std::string tail(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the last part of the string after the given position.
virtual G::Signal2< std::string, VerifierStatus > & doneSignal()
Final override from GSmtp::Verifier.
virtual ~NetworkVerifier()
Destructor.
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.
static std::string head(const std::string &in, std::string::size_type pos, const std::string &default_=std::string())
Returns the first part of the string up to just before the given position.
static std::string upper(const std::string &s)
Returns a copy of 's' in which all lowercase characters have been replaced by uppercase characters...
A structure returned by GSmtp::Verifier to describe the status of a rcpt-to recipient.
NetworkVerifier(const std::string &, unsigned int, unsigned int)
Constructor.
static std::string join(const Strings &strings, const std::string &sep)
Concatenates a set of strings.
A client class that interacts with a remote process with a stateless line-based request/response prot...