InspIRCd  2.0
 All Classes Namespaces Functions Variables Typedefs Enumerations
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 ( )

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

Initialise the DNS UDP socket so that we can send requests

DNS::~DNS ( )

Destructor

Close the master socket

Member Function Documentation

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.

bool DNS::AddResolverClass ( Resolver r)

Add a Resolver* to the list of active classes

Add a derived Resolver to the working set

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.

int DNS::ClearCache ( )

Clear all items from the DNS cache immediately.

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

Delete a cached item from the DNS cache.

Parameters
sourceAn IP or hostname to remove
void DNS::EmptyHeader ( unsigned char *  output,
const DNSHeader header,
const int  length 
)
inlinestatic

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

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

Fill a header with data from input limited by a length

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

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

Fill an rr (resource record) with data from input

Fill a ResourceRecord class based on raw data input

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

Return the cached value of an IP or hostname

Parameters
sourceAn IP or hostname to find in the cache.
Returns
A pointer to a CachedQuery if the item exists, otherwise NULL.
int DNS::GetCName ( const char *  alias)

Start lookup of a CNAME from another hostname

Start lookup of a cname to another name

int DNS::GetIP ( const char *  name)

Start the lookup of an ipv4 from a hostname

Start lookup of an hostname to an IP address

int DNS::GetIP6 ( const char *  name)

Start lookup of an ipv6 from a hostname

Start lookup of an hostname to an IPv6 address

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

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

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

Handle a SocketEngine read event Inherited from EventHandler

Process a socket read event

Implements EventHandler.

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

Turn an in6_addr into a .ip6.arpa domain

Build an ipv6 reverse domain from an in6_addr

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.

void DNS::Rehash ( )

Re-initialize the DNS subsystem.

Member Data Documentation

Resolver* DNS::Classes[MAX_REQUEST_ID]

Currently active Resolver classes

const int DNS::QUERY_PORT = 53
static

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

DNSRequest* DNS::requests[MAX_REQUEST_ID]

Requests that are currently 'in flight'


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