29 const std::string & server ) :
32 m_connection_timeout(config.timeout) ,
33 m_response_timeout(config.timeout) ,
34 m_command(Command::VRFY)
36 G_DEBUG(
"GVerifiers::NetworkVerifier::ctor: " << server ) ;
43 m_client_ptr.eventSignal().disconnect() ;
44 m_client_ptr.deletedSignal().disconnect() ;
47void GVerifiers::NetworkVerifier::verify( Command command ,
const std::string & mail_to_address ,
51 if( m_client_ptr.get() ==
nullptr )
53 unsigned int idle_timeout = 0U ;
54 m_client_ptr.reset( std::make_unique<GSmtp::RequestClient>(
57 m_location , m_connection_timeout , m_response_timeout ,
61 G_LOG(
"GVerifiers::NetworkVerifier: verification request: ["
62 <<
G::Str::printable(mail_to_address) <<
"] (" << info.client_ip.displayString() <<
")" ) ;
65 args.push_back( mail_to_address ) ;
66 args.push_back( info.mail_from_parameter ) ;
67 args.push_back( info.client_ip.displayString() ) ;
68 args.push_back( info.domain ) ;
70 args.push_back( info.auth_extra ) ;
72 m_to_address = mail_to_address ;
76void GVerifiers::NetworkVerifier::clientDeleted(
const std::string & reason )
78 G_DEBUG(
"GVerifiers::NetworkVerifier::clientDeleted: reason=[" << reason <<
"]" ) ;
81 std::string to_address = m_to_address ;
82 m_to_address.erase() ;
85 doneSignal().emit( m_command , status ) ;
89void GVerifiers::NetworkVerifier::clientEvent(
const std::string & s1 ,
const std::string & s2 ,
const std::string & )
91 G_DEBUG(
"GVerifiers::NetworkVerifier::clientEvent: [" << s1 <<
"] [" << s2 <<
"]" ) ;
94 G_LOG(
"GVerifiers::NetworkVerifier: verification response: [" <<
G::Str::printable(s2) <<
"]" ) ;
101 std::size_t part_count = f.count() ;
107 if( part_count && part_0 ==
"100"_sv )
109 status.is_valid = false ;
110 status.abort = true ;
112 else if( part_count >= 2U && part_0 ==
"1"_sv )
114 std::string address = G::sv_to_string( part_1 ) ;
117 else if( part_count >= 3U && part_0 ==
"0"_sv )
119 std::string mbox = G::sv_to_string( part_1 ) ;
120 std::string full_name = G::sv_to_string( part_2 ) ;
123 else if( part_count >= 2U && ( part_0 ==
"2"_sv || part_0 ==
"3"_sv ) )
125 bool temporary = part_0 ==
"3"_sv ;
126 std::string response = G::sv_to_string( part_1 ) ;
128 if( part_count >= 3U ) reason = G::sv_to_string( part_2 ) ;
130 temporary , response , reason ) ;
133 doneSignal().emit( m_command , status ) ;
139 return m_done_signal ;
142void GVerifiers::NetworkVerifier::cancel()
144 m_to_address.erase() ;
145 m_client_ptr.reset() ;
G::Slot::Signal< const std::string & > & deletedSignal() noexcept
A signal that is triggered after deleteSignal() once the client has been deleted and the ClientPtr is...
G::Slot::Signal< const std::string &, const std::string &, const std::string & > & eventSignal() noexcept
A signal that is linked to the contained client's eventSignal().
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
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 function for an invalid address.
static VerifierStatus remote(const std::string &recipient, const std::string &address={})
Constructor for a valid remote mailbox.
NetworkVerifier(GNet::ExceptionSink, const GSmtp::Verifier::Config &config, const std::string &server)
Constructor.
~NetworkVerifier() override
Destructor.
static std::string join(string_view sep, const StringArray &strings)
Concatenates an array of strings with separators.
static std::string lower(string_view)
Returns a copy of 's' in which all seven-bit upper-case characters have been replaced by lower-case c...
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 ...
A zero-copy string field iterator where the field separators are short fixed strings.
A class like c++17's std::string_view.
Slot< Args... > slot(TSink &sink, void(TSink::*method)(Args...))
A factory function for Slot objects.
std::vector< std::string > StringArray
A std::vector of std::strings.
Configuration passed to address verifier constructors.
Extra information passed to GSmtp::Verifier::verify().