E-MailRelay
Public Types | Public Member Functions | Static Public Member Functions | List of all members
GNet::DnsBlock Class Reference

Implements DNS blocklisting, as per RFC-5782. More...

#include <gdnsblock.h>

+ Inheritance diagram for GNet::DnsBlock:
+ Collaboration diagram for GNet::DnsBlock:

Public Types

using ResultList = std::vector< DnsBlockServerResult >
 

Public Member Functions

 DnsBlock (DnsBlockCallback &, EventState, std::string_view config={})
 Constructor. More...
 
void configure (const Address &dns_server, unsigned int threshold, bool allow_on_timeout, G::TimeInterval timeout, const G::StringArray &servers)
 Configures the object after construction. More...
 
void configure (std::string_view)
 Configuration overload taking a configuration string containing comma-separated fields of: dns-server-address, timeout-ms, threshold, dnsbl-server-list. More...
 
void start (const Address &)
 Starts an asychronous check on the given address. More...
 
bool busy () const
 Returns true after start() and before the completion callback. More...
 
 DnsBlock (const DnsBlock &)=delete
 
 DnsBlock (DnsBlock &&)=delete
 
DnsBlockoperator= (const DnsBlock &)=delete
 
DnsBlockoperator= (DnsBlock &&)=delete
 

Static Public Member Functions

static void checkConfig (const std::string &)
 Checks the configure() string, throwing on error. More...
 

Detailed Description

Implements DNS blocklisting, as per RFC-5782.

The implementation sends DNS requests for each configured block-list server incorporating the IP address to be tested, for example "1.0.168.192.nospam.com". All requests go to the same DNS server and are cached or routed in the normal way, so the block-list servers are not contacted directly.

Definition at line 145 of file gdnsblock.h.

Member Typedef Documentation

◆ ResultList

using GNet::DnsBlock::ResultList = std::vector<DnsBlockServerResult>

Definition at line 153 of file gdnsblock.h.

Constructor & Destructor Documentation

◆ DnsBlock()

GNet::DnsBlock::DnsBlock ( DnsBlockCallback callback,
EventState  es,
std::string_view  config = {} 
)

Constructor.

Use configure() if necessary and then start(), one time only.

Definition at line 69 of file gdnsblock.cpp.

Member Function Documentation

◆ busy()

bool GNet::DnsBlock::busy ( ) const

Returns true after start() and before the completion callback.

Definition at line 240 of file gdnsblock.cpp.

◆ checkConfig()

void GNet::DnsBlock::checkConfig ( const std::string &  config)
static

Checks the configure() string, throwing on error.

Definition at line 79 of file gdnsblock.cpp.

◆ configure() [1/2]

void GNet::DnsBlock::configure ( const Address dns_server,
unsigned int  threshold,
bool  allow_on_timeout,
G::TimeInterval  timeout,
const G::StringArray servers 
)

Configures the object after construction.

Definition at line 145 of file gdnsblock.cpp.

◆ configure() [2/2]

void GNet::DnsBlock::configure ( std::string_view  config)

Configuration overload taking a configuration string containing comma-separated fields of: dns-server-address, timeout-ms, threshold, dnsbl-server-list.

Definition at line 91 of file gdnsblock.cpp.

◆ start()

void GNet::DnsBlock::start ( const Address address)

Starts an asychronous check on the given address.

The result is delivered via the callback interface passed to the ctor.

Definition at line 188 of file gdnsblock.cpp.


The documentation for this class was generated from the following files: