E-MailRelay
gdnsbl_enabled.cpp
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 gdnsbl_enabled.cpp
19///
20
21#include "gdef.h"
22#include "gdnsbl.h"
23#include "gdnsblock.h"
24#include <utility>
25
26class GNet::DnsblImp : private DnsBlockCallback
27{
28public:
29 DnsblImp( std::function<void(bool)> callback , EventState es , std::string_view config ) :
30 m_callback(std::move(callback)) ,
31 m_block(*this,es,config)
32 {
33 }
34 void onDnsBlockResult( const DnsBlockResult & result ) override
35 {
36 result.log() ;
37 result.warn() ;
38 m_callback( result.allow() ) ;
39 }
40 std::function<void(bool)> m_callback ;
41 DnsBlock m_block ;
42} ;
43
44GNet::Dnsbl::Dnsbl( std::function<void(bool)> callback , EventState es , std::string_view config ) :
45 m_imp(std::make_unique<DnsblImp>(callback,es,config))
46{
47}
48
50= default ;
51
52void GNet::Dnsbl::start( const Address & address )
53{
54 m_imp->m_block.start( address ) ;
55}
56
57bool GNet::Dnsbl::busy() const
58{
59 return m_imp->m_block.busy() ;
60}
61
62void GNet::Dnsbl::checkConfig( const std::string & config )
63{
64 DnsBlock::checkConfig( config ) ;
65}
66
static void checkConfig(const std::string &)
Checks the configure() string, throwing on error.
Definition: gdnsblock.cpp:79
bool busy() const
Returns true after start() and before the completion callback.
static void checkConfig(const std::string &)
See DnsBlock::checkConfig().
void start(const Address &)
Starts an asychronous check on the given address.
Dnsbl(std::function< void(bool)> callback, EventState, std::string_view config={})
Constructor. See DnsBlock::DnsBlock().
~Dnsbl()
Destructor.
STL namespace.