InspIRCd  2.0
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
DNS Class Reference

#include <dns.h>

Inheritance diagram for DNS:
EventHandler classbase

Public Member Functions

int GetIP (const char *name)
int GetNameForce (const char *ip, ForceProtocol fp)
int GetIP6 (const char *name)
int GetCName (const char *alias)
DNSResult GetResult ()
void HandleEvent (EventType et, int errornum=0)
bool AddResolverClass (Resolver *r)
DNSRequestAddQuery (DNSHeader *header, int &id, const char *original)
 DNS ()
void Rehash ()
 ~DNS ()
void CleanResolvers (Module *module)
CachedQueryGetCache (const std::string &source)
void DelCache (const std::string &source)
int ClearCache ()
int PruneCache ()
- Public Member Functions inherited from EventHandler
int GetFd () const
int GetEventMask () const
void SetFd (int FD)
 EventHandler ()
virtual ~EventHandler ()
- Public Member Functions inherited from classbase
virtual CullResult cull ()

Static Public Member Functions

static void FillResourceRecord (ResourceRecord *rr, const unsigned char *input)
static void FillHeader (DNSHeader *header, const unsigned char *input, const int length)
static void EmptyHeader (unsigned char *output, const DNSHeader *header, const int length)
static void MakeIP6Int (char *query, const in6_addr *ip)

Public Attributes

irc::sockets::sockaddrs myserver
ResolverClasses [MAX_REQUEST_ID]
DNSRequestrequests [MAX_REQUEST_ID]

Static Public Attributes

static const int QUERY_PORT = 53

Additional Inherited Members

- Protected Attributes inherited from EventHandler
int fd

Detailed Description

DNS is a singleton class used by the core to dispatch dns requests to the dns server, and route incoming dns replies back to Resolver objects, based upon the request ID. You should never use this class yourself.

Constructor & Destructor Documentation

◆ DNS()

DNS::DNS ( )

The constructor initialises the dns socket, and clears the request lists.

Initialise the DNS UDP socket so that we can send requests

◆ ~DNS()

DNS::~DNS ( )


Close the master socket

Member Function Documentation

◆ AddQuery()

DNSRequest * DNS::AddQuery ( DNSHeader header,
int &  id,
const char *  original 

Add a query to the list to be sent

Add a query with a predefined header, and allocate an ID for it.

◆ AddResolverClass()

bool DNS::AddResolverClass ( Resolver r)

Add a Resolver* to the list of active classes

Add a derived Resolver to the working set

◆ CleanResolvers()

void DNS::CleanResolvers ( Module module)

Clean out all dns resolvers owned by a particular module, to make unloading a module safe if there are dns requests currently in progress.

◆ ClearCache()

int DNS::ClearCache ( )

Clear all items from the DNS cache immediately.

◆ DelCache()

void DNS::DelCache ( const std::string &  source)

Delete a cached item from the DNS cache.

sourceAn IP or hostname to remove

◆ EmptyHeader()

void DNS::EmptyHeader ( unsigned char *  output,
const DNSHeader header,
const int  length 

Empty out a header into a data stream ready for transmission "on the wire"

Empty a DNSHeader class out into raw data, ready for transmission

◆ FillHeader()

void DNS::FillHeader ( DNSHeader header,
const unsigned char *  input,
const int  length 

Fill a header with data from input limited by a length

Fill a DNSHeader class based on raw data input of a given length

◆ FillResourceRecord()

void DNS::FillResourceRecord ( ResourceRecord rr,
const unsigned char *  input 

Fill an rr (resource record) with data from input

Fill a ResourceRecord class based on raw data input

◆ GetCache()

CachedQuery * DNS::GetCache ( const std::string &  source)

Return the cached value of an IP or hostname

sourceAn IP or hostname to find in the cache.
A pointer to a CachedQuery if the item exists, otherwise NULL.

◆ GetCName()

int DNS::GetCName ( const char *  alias)

Start lookup of a CNAME from another hostname

Start lookup of a cname to another name

◆ GetIP()

int DNS::GetIP ( const char *  name)

Start the lookup of an ipv4 from a hostname

Start lookup of an hostname to an IP address

◆ GetIP6()

int DNS::GetIP6 ( const char *  name)

Start lookup of an ipv6 from a hostname

Start lookup of an hostname to an IPv6 address

◆ GetNameForce()

int DNS::GetNameForce ( const char *  ip,
ForceProtocol  fp 

Start lookup of a hostname from an ip, but force a specific protocol to be used for the lookup for example to perform an ipv6 reverse lookup.

Start lookup of an IP address to a hostname

◆ GetResult()

DNSResult DNS::GetResult ( )

Fetch the result string (an ip or host) and/or an error message to go with it.

Return the next id which is ready, and the result attached to it

◆ HandleEvent()

void DNS::HandleEvent ( EventType  et,
int  errornum = 0 

Handle a SocketEngine read event Inherited from EventHandler

Process a socket read event

Implements EventHandler.

◆ MakeIP6Int()

void DNS::MakeIP6Int ( char *  query,
const in6_addr *  ip 

Turn an in6_addr into a domain

Build an ipv6 reverse domain from an in6_addr

◆ PruneCache()

int DNS::PruneCache ( )

Prune the DNS cache, e.g. remove all expired items and rehash the cache buckets, but leave items in the hash which are still valid.

◆ Rehash()

void DNS::Rehash ( )

Re-initialize the DNS subsystem.

Member Data Documentation

◆ Classes

Resolver* DNS::Classes[MAX_REQUEST_ID]

Currently active Resolver classes


const int DNS::QUERY_PORT = 53

The port number DNS requests are made on, and replies have as a source-port number.

◆ requests

DNSRequest* DNS::requests[MAX_REQUEST_ID]

Requests that are currently 'in flight'

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