Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

DNS Class Reference

The DNS class allows fast nonblocking resolution of hostnames and ip addresses. More...

#include <dns.h>

Collaboration diagram for DNS:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DNS ()
 The default constructor uses dns addresses read from /etc/resolv.conf.
 DNS (std::string dnsserver)
 This constructor accepts a dns server address.
 ~DNS ()
 The destructor frees all used structures.
bool ReverseLookup (std::string ip)
 This method will start the reverse lookup of an ip given in dotted decimal format, e.g.
bool ForwardLookup (std::string host)
 This method will start the forward lookup of a hostname, e.g.
bool HasResult ()
 This method will return true when the lookup is completed.
bool HasResult (int fd)
 This method will return true if the lookup's fd matches the one provided.
std::string GetResult ()
 This method returns the result of your query as a string, depending upon wether you called DNS::ReverseLookup() or DNS::ForwardLookup.
std::string GetResultIP ()
int GetFD ()
 This method returns the file handle used by the dns query socket or zero if the query is invalid for some reason, e.g.
void SetNS (std::string dnsserver)

Private Member Functions

void dns_init ()
void dns_init_2 (const char *dnsserver)
in_addr * dns_aton4 (const char *const ipstring)
char * dns_ntoa4 (const in_addr *const ip)
int dns_getip4 (const char *const name)
int dns_getip4list (const char *const name)
int dns_getname4 (const in_addr *const ip)
char * dns_getresult (const int fd)
in_addr * dns_aton4_s (const char *const ipstring, in_addr *const ip)
char * dns_ntoa4_s (const in_addr *const ip, char *const result)
char * dns_getresult_s (const int fd, char *const result)
in_addr * dns_aton4_r (const char *const ipstring)
char * dns_ntoa4_r (const in_addr *const ip)
char * dns_getresult_r (const int fd)

Private Attributes

in_addr * binip
char * result
char localbuf [1024]
int t
int myfd

Detailed Description

The DNS class allows fast nonblocking resolution of hostnames and ip addresses.

It is based heavily upon firedns by Ian Gulliver.

Definition at line 35 of file dns.h.


Constructor & Destructor Documentation

DNS::DNS  ) 
 

The default constructor uses dns addresses read from /etc/resolv.conf.

Please note that it will re-read /etc/resolv.conf for each copy of the class you instantiate, causing disk access and slow lookups if you create a lot of them. Consider passing the constructor a server address as a parameter instead.

DNS::DNS std::string  dnsserver  ) 
 

This constructor accepts a dns server address.

The address must be in dotted decimal form, e.g. 1.2.3.4.

DNS::~DNS  ) 
 

The destructor frees all used structures.


Member Function Documentation

in_addr* DNS::dns_aton4 const char *const   ipstring  )  [private]
 

in_addr* DNS::dns_aton4_r const char *const   ipstring  )  [private]
 

in_addr* DNS::dns_aton4_s const char *const   ipstring,
in_addr *const   ip
[private]
 

int DNS::dns_getip4 const char *const   name  )  [private]
 

int DNS::dns_getip4list const char *const   name  )  [private]
 

int DNS::dns_getname4 const in_addr *const   ip  )  [private]
 

char* DNS::dns_getresult const int  fd  )  [private]
 

char* DNS::dns_getresult_r const int  fd  )  [private]
 

char* DNS::dns_getresult_s const int  fd,
char *const   result
[private]
 

void DNS::dns_init  )  [private]
 

void DNS::dns_init_2 const char *  dnsserver  )  [private]
 

char* DNS::dns_ntoa4 const in_addr *const   ip  )  [private]
 

char* DNS::dns_ntoa4_r const in_addr *const   ip  )  [private]
 

char* DNS::dns_ntoa4_s const in_addr *const   ip,
char *const   result
[private]
 

bool DNS::ForwardLookup std::string  host  ) 
 

This method will start the forward lookup of a hostname, e.g.

www.inspircd.org, and returns true if the lookup was successfully initiated.

int DNS::GetFD  ) 
 

This method returns the file handle used by the dns query socket or zero if the query is invalid for some reason, e.g.

the dns server not responding.

std::string DNS::GetResult  ) 
 

This method returns the result of your query as a string, depending upon wether you called DNS::ReverseLookup() or DNS::ForwardLookup.

std::string DNS::GetResultIP  ) 
 

bool DNS::HasResult int  fd  ) 
 

This method will return true if the lookup's fd matches the one provided.

bool DNS::HasResult  ) 
 

This method will return true when the lookup is completed.

It uses poll internally to determine the status of the socket.

bool DNS::ReverseLookup std::string  ip  ) 
 

This method will start the reverse lookup of an ip given in dotted decimal format, e.g.

1.2.3.4, and returns true if the lookup was successfully initiated.

void DNS::SetNS std::string  dnsserver  ) 
 


Member Data Documentation

in_addr* DNS::binip [private]
 

Definition at line 38 of file dns.h.

char DNS::localbuf[1024] [private]
 

Definition at line 40 of file dns.h.

int DNS::myfd [private]
 

Definition at line 43 of file dns.h.

char* DNS::result [private]
 

Definition at line 39 of file dns.h.

int DNS::t [private]
 

Definition at line 41 of file dns.h.


The documentation for this class was generated from the following file:
Generated on Mon Dec 19 18:05:21 2005 for InspIRCd by  doxygen 1.4.4-20050815