34 m_task(*this,es,
"<<verifier exec error: __strerror__>>",
G::Root::nobody())
38void GSmtp::ExecutableVerifier::verify(
const std::string & to_address ,
40 const std::string & auth_mechanism ,
const std::string & auth_extra )
42 G_DEBUG(
"GSmtp::ExecutableVerifier::verify: to \"" << to_address <<
"\": from \"" << from_address <<
"\": "
43 <<
"ip \"" << ip.
hostPartString() <<
"\": auth-mechanism \"" << auth_mechanism <<
"\": "
44 <<
"auth-extra \"" << auth_extra <<
"\"" ) ;
47 commandline.add( to_address ) ;
48 commandline.add( from_address ) ;
52 commandline.add( auth_extra ) ;
54 G_LOG(
"GSmtp::ExecutableVerifier: address verifier: executing " << commandline.displayString() ) ;
55 m_to_address = to_address ;
56 m_task.start( commandline ) ;
59void GSmtp::ExecutableVerifier::onTaskDone(
int exit_code ,
const std::string & result_in )
61 std::string result( result_in ) ;
67 result_parts.reserve( 2U ) ;
69 std::size_t parts = result_parts.size() ;
70 result_parts.resize( 2U ) ;
72 G_LOG(
"GSmtp::ExecutableVerifier: address verifier: exit code " << exit_code <<
": "
76 if( exit_code == 0 && parts >= 2 )
82 else if( exit_code == 1 && parts >= 2 )
87 else if( exit_code == 100 )
93 bool temporary = exit_code == 3 ;
95 std::string response = parts > 0U ?
97 std::string(
"mailbox unavailable") ;
99 std::string reason = parts > 1U ?
101 (
"exit code " +
G::Str::fromInt(exit_code) ) ;
104 temporary , response , reason ) ;
107 doneSignal().emit( status ) ;
112 return m_done_signal ;
115void GSmtp::ExecutableVerifier::cancel()
The GNet::Address class encapsulates a TCP/UDP transport address.
std::string hostPartString(bool raw=false) const
Returns a string which represents the network address.
std::string displayString(bool with_scope_id=false) const
Returns a string which represents the transport address.
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
static std::string canonicalName()
Returns the canonical network name assiciated with hostname().
ExecutableVerifier(GNet::ExceptionSink, const G::Path &)
Constructor.
static VerifierStatus local(const std::string &recipient, const std::string &full_name, const std::string &mbox)
Constructor for a valid local mailbox.
static VerifierStatus invalid(const std::string &recipient, bool temporary=false, const std::string &response={}, const std::string &reason={})
Factory for an invalid address.
static VerifierStatus remote(const std::string &recipient, const std::string &address={})
Constructor for a valid remote mailbox.
A structure representing an external program, holding a path and a set of arguments.
A Path object represents a file system path.
static void splitIntoFields(const std::string &in, StringArray &out, string_view ws, char escape='\0', bool remove_escapes=true)
Splits the string into fields.
static std::string & trimRight(std::string &s, string_view ws, std::size_t limit=0U)
Trims the rhs of s, taking off up to 'limit' of the 'ws' characters.
static std::string printable(const std::string &in, char escape='\\')
Returns a printable representation of the given input string, using chacter code ranges 0x20 to 0x7e ...
static unsigned int replaceAll(std::string &s, const std::string &from, const std::string &to)
Does a global replace on string 's', replacing all occurrences of sub-string 'from' with 'to'.
static std::string lower(const std::string &s)
Returns a copy of 's' in which all Latin-1 upper-case characters have been replaced by lower-case cha...
std::vector< std::string > StringArray
A std::vector of std::strings.