E-MailRelay

gverifier.h
Go to the documentation of this file.
1//
2// Copyright (C) 2001-2024 Graeme Walker <graeme_walker@users.sourceforge.net>
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16// ===
17///
18/// \file gverifier.h
19///
20
21#ifndef G_SMTP_VERIFIER_H
22#define G_SMTP_VERIFIER_H
23
24#include "gdef.h"
25#include "gverifierstatus.h"
26#include "gbasicaddress.h"
27#include "gslot.h"
28#include "gexception.h"
29#include <string>
30
31 namespace GSmtp
32{
33 class Verifier ;
34}
35
36//| \class GSmtp::Verifier
37/// An asynchronous interface that verifies recipient 'to' addresses.
38/// This is used in the VRFY and RCPT commands in the smtp server
39/// protocol.
40/// \see GSmtp::ServerProtocol
41///
42 class GSmtp::Verifier
43{
44 public:
45 enum class Command { VRFY , RCPT } ;
46 struct Request /// Verification request passed to various GSmtp::Verifier::verify() overrides.
47 {
48 Command command {Command::RCPT} ;
49 std::string raw_address ; // recipient address as received
50 std::string address ; // recipient address to verify
51 std::string from_address ; // MAIL-FROM address if RCPT, not VRFY
52 G::BasicAddress client_ip ;
53 std::string auth_mechanism ;
54 std::string auth_extra ;
55 } ;
56 struct Config /// Configuration passed to address verifier constructors.
57 {
58 unsigned int timeout {60U} ;
59 std::string domain ;
60 Config & set_timeout( unsigned int ) noexcept ;
61 Config & set_domain( const std::string & ) ;
62 } ;
63
64 virtual void verify( const Request & ) = 0 ;
65 ///< Checks a recipient address and asynchronously returns a
66 ///< GSmtp::VerifierStatus structure to indicate whether the address
67 ///< is a local mailbox, what the full name is, and the canonical
68 ///< address.
69
70 virtual G::Slot::Signal<Command,const VerifierStatus&> & doneSignal() = 0 ;
71 ///< Returns a signal that is emit()ed when the verify() request
72 ///< is complete.
73
74 virtual void cancel() = 0 ;
75 ///< Aborts any current processing.
76
77 virtual ~Verifier() = default ;
78 ///< Destructor.
79} ;
80
81 inline GSmtp::Verifier::Config & GSmtp::Verifier::Config::set_timeout( unsigned int n ) noexcept { timeout = n ; return *this ; }
82 inline GSmtp::Verifier::Config & GSmtp::Verifier::Config::set_domain( const std::string & s ) { domain = s ; return *this ; }
83
84#endif
GSmtp::Verifier
An asynchronous interface that verifies recipient 'to' addresses.
Definition: gverifier.h:43
GSmtp::Verifier::~Verifier
virtual ~Verifier()=default
Destructor.
GSmtp::Verifier::doneSignal
virtual G::Slot::Signal< Command, const VerifierStatus & > & doneSignal()=0
Returns a signal that is emit()ed when the verify() request is complete.
GSmtp::Verifier::cancel
virtual void cancel()=0
Aborts any current processing.
GSmtp::Verifier::verify
virtual void verify(const Request &)=0
Checks a recipient address and asynchronously returns a GSmtp::VerifierStatus structure to indicate w...
G::BasicAddress
A structure that holds a network address as a string with no dependency on any low-level network libr...
Definition: gbasicaddress.h:37
gbasicaddress.h
gexception.h
gslot.h
gverifierstatus.h
GSmtp
SMTP classes.
Definition: gadminserver.h:42
GSmtp::Verifier::Config
Configuration passed to address verifier constructors.
Definition: gverifier.h:57
GSmtp::Verifier::Request
Verification request passed to various GSmtp::Verifier::verify() overrides.
Definition: gverifier.h:47
G::Slot::Signal
A slot holder, with connect() and emit() methods.
Definition: gslot.h:184