|
|||
|
|||
|
#include <dns.h>
Inheritance diagram for DNS:


Public Member Functions | |
| int | GetIP (const char *name) |
| Start the lookup of an ipv4 from a hostname. | |
| int | GetName (const irc::sockets::insp_inaddr *ip) |
| Start the lookup of a hostname from an ip, always using the protocol inspircd is built for, e.g. | |
| int | 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. | |
| int | GetIP6 (const char *name) |
| Start lookup of an ipv6 from a hostname. | |
| int | GetCName (const char *alias) |
| Start lookup of a CNAME from another hostname. | |
| DNSResult | GetResult (int resultnum) |
| Fetch the result string (an ip or host) and/or an error message to go with it. | |
| void | HandleEvent (EventType et, int errornum=0) |
| Handle a SocketEngine read event Inherited from EventHandler. | |
| bool | AddResolverClass (Resolver *r) |
| Add a Resolver* to the list of active classes. | |
| DNSRequest * | AddQuery (DNSHeader *header, int &id, const char *original) |
| Add a query to the list to be sent. | |
| DNS (InspIRCd *Instance) | |
| The constructor initialises the dns socket, and clears the request lists. | |
| void | Rehash () |
| Re-initialize the DNS subsystem. | |
| ~DNS () | |
| Destructor. | |
| unsigned long | PRNG () |
| Portable random number generator, generates its random number from the ircd stats counters, effective user id, time of day and the rollover counter (currid). | |
| void | 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. | |
| CachedQuery * | GetCache (const std::string &source) |
| Return the cached value of an IP or hostname. | |
| void | DelCache (const std::string &source) |
| Delete a cached item from the DNS cache. | |
| int | ClearCache () |
| Clear all items from the DNS cache immediately. | |
| int | PruneCache () |
| Prune the DNS cache, e.g. | |
Static Public Member Functions | |
| static void | FillResourceRecord (ResourceRecord *rr, const unsigned char *input) |
| Fill an rr (resource record) with data from input. | |
| static void | FillHeader (DNSHeader *header, const unsigned char *input, const int length) |
| Fill a header with data from input limited by a length. | |
| static void | EmptyHeader (unsigned char *output, const DNSHeader *header, const int length) |
| Empty out a header into a data stream ready for transmission "on the wire". | |
| static void | MakeIP6Int (char *query, const in6_addr *ip) |
| Turn an in6_addr into a .ip6.arpa domain. | |
Public Attributes | |
| int | socketfamily |
| Server address being used currently. | |
| in_addr | myserver4 |
| IPV4 server address. | |
| Resolver * | Classes [MAX_REQUEST_ID] |
| Currently active Resolver classes. | |
| DNSRequest * | requests [MAX_REQUEST_ID] |
| Requests that are currently 'in flight'. | |
Static Public Attributes | |
| static const int | QUERY_PORT = 53 |
| The port number DNS requests are made on, and replies have as a source-port number. | |
Private Member Functions | |
| int | MakePayload (const char *name, const QueryType rr, const unsigned short rr_class, unsigned char *payload) |
| Build a dns packet payload. | |
Private Attributes | |
| InspIRCd * | ServerInstance |
| Creator/Owner object. | |
| int | currid |
| A counter used to form part of the pseudo-random id. | |
| bool | ip6munge |
| We have to turn off a few checks on received packets when people are using 4in6 (e.g. | |
| dnscache * | cache |
| Currently cached items. | |
| CacheTimer * | PruneTimer |
| A timer which ticks every hour to remove expired items from the DNS cache. | |
Static Private Attributes | |
| static const int | MAX_REQUEST_ID = 0xFFFF |
| The maximum value of a dns request id, 16 bits wide, 0xFFFF. | |
You should never use this class yourself.
Definition at line 329 of file dns.h.
|
|
The constructor initialises the dns socket, and clears the request lists.
Definition at line 392 of file dns.cpp. References TimerManager::AddTimer(), cache, Classes, currid, DEBUG, LogManager::Log(), InspIRCd::Logs, PruneTimer, Rehash(), requests, ServerInstance, EventHandler::SetFd(), and InspIRCd::Timers. |
|
|
Destructor.
Definition at line 927 of file dns.cpp. References SocketEngine::Close(), TimerManager::DelTimer(), InspIRCd::SE, ServerInstance, SocketEngine::Shutdown(), and InspIRCd::Timers. |
|
||||||||||||||||
|
Add a query to the list to be sent.
Definition at line 248 of file dns.cpp. References DNSHeader::ancount, DNSHeader::arcount, DNSHeader::flags1, DNSHeader::flags2, FLAGS_MASK_RD, DNSRequest::id, DNSHeader::id, MAX_REQUEST_ID, DNSHeader::nscount, PRNG(), DNSHeader::qdcount, requests, and ServerInstance. Referenced by GetCName(), GetIP(), GetIP6(), GetName(), and GetNameForce(). |
|
|
Add a Resolver* to the list of active classes.
Definition at line 1112 of file dns.cpp. References Classes, DEBUG, Resolver::GetId(), LogManager::Log(), InspIRCd::Logs, and ServerInstance. Referenced by InspIRCd::AddResolver(). |
|
|
Clean out all dns resolvers owned by a particular module, to make unloading a module safe if there are dns requests currently in progress.
Definition at line 1144 of file dns.cpp. References Classes, MAX_REQUEST_ID, Resolver::OnError(), and RESLOVER_FORCEUNLOAD. Referenced by ModuleManager::Unload(). |
|
|
Clear all items from the DNS cache immediately.
Definition at line 281 of file dns.cpp. References cache. |
|
|
Delete a cached item from the DNS cache.
Definition at line 943 of file dns.cpp. References cache. Referenced by Resolver::Resolver(). |
|
||||||||||||||||
|
Empty out a header into a data stream ready for transmission "on the wire".
Definition at line 191 of file dns.cpp. References DNSHeader::ancount, DNSHeader::arcount, DNSHeader::flags1, DNSHeader::flags2, DNSHeader::id, DNSHeader::nscount, DNSHeader::payload, and DNSHeader::qdcount. Referenced by DNSRequest::SendRequests(). |
|
||||||||||||||||
|
Fill a header with data from input limited by a length.
Definition at line 177 of file dns.cpp. References DNSHeader::ancount, DNSHeader::arcount, DNSHeader::flags1, DNSHeader::flags2, DNSHeader::id, DNSHeader::nscount, DNSHeader::payload, and DNSHeader::qdcount. Referenced by GetResult(). |
|
||||||||||||
|
Fill an rr (resource record) with data from input.
Definition at line 168 of file dns.cpp. References ResourceRecord::rdlength, ResourceRecord::rr_class, ResourceRecord::ttl, and ResourceRecord::type. Referenced by DNSRequest::ResultIsReady(). |
|
|
Return the cached value of an IP or hostname.
Definition at line 934 of file dns.cpp. References cache. Referenced by Resolver::Resolver(). |
|
|
Start lookup of a CNAME from another hostname.
Definition at line 497 of file dns.cpp. References AddQuery(), DNS_QUERY_CNAME, DNSHeader::payload, and DNSRequest::SendRequests(). Referenced by Resolver::Resolver(). |
|
|
Start the lookup of an ipv4 from a hostname.
Definition at line 461 of file dns.cpp. References AddQuery(), DNS_QUERY_A, DNSHeader::payload, and DNSRequest::SendRequests(). Referenced by Resolver::Resolver(). |
|
|
Start lookup of an ipv6 from a hostname.
Definition at line 479 of file dns.cpp. References AddQuery(), DNS_QUERY_AAAA, DNSHeader::payload, and DNSRequest::SendRequests(). Referenced by Resolver::Resolver(). |
|
|
Start the lookup of a hostname from an ip, always using the protocol inspircd is built for, e.g. use ipv6 reverse lookup when built for ipv6, or ipv4 lookup when built for ipv4. Definition at line 515 of file dns.cpp. References AddQuery(), DNS_QUERY_PTR, irc::sockets::insp_ntoa(), MakeIP6Int(), DNSHeader::payload, and DNSRequest::SendRequests(). Referenced by Resolver::Resolver(). |
|
||||||||||||
|
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.
Definition at line 547 of file dns.cpp. References AddQuery(), DNS_QUERY_PTR, MakeIP6Int(), DNSHeader::payload, PROTOCOL_IPV6, and DNSRequest::SendRequests(). Referenced by Resolver::Resolver(). |
|
|
Fetch the result string (an ip or host) and/or an error message to go with it.
Definition at line 613 of file dns.cpp. References InspIRCd::Config, DNS_QUERY_A, DNS_QUERY_AAAA, DNS_QUERY_CNAME, DNS_QUERY_PTR, ServerConfig::DNSServer, ERROR_MASK, FillHeader(), DNSHeader::id, ip6munge, MAXBUF, DNSRequest::orig, QUERY_PORT, SocketEngine::RecvFrom(), requests, DNSRequest::ResultIsReady(), InspIRCd::SE, ServerInstance, socketfamily, DNSRequest::ttl, and DNSRequest::type. Referenced by HandleEvent(). |
|
||||||||||||
|
Handle a SocketEngine read event Inherited from EventHandler.
Implements EventHandler. Definition at line 1056 of file dns.cpp. References cache, Classes, DEBUG, ERROR_MASK, GetResult(), DNSResult::id, LogManager::Log(), InspIRCd::Logs, Resolver::OnError(), Resolver::OnLookupComplete(), DNSResult::original, RESOLVER_NXDOMAIN, DNSResult::result, ServerInstance, InspIRCd::stats, serverstats::statsDns, serverstats::statsDnsBad, serverstats::statsDnsGood, and DNSResult::ttl. |
|
||||||||||||
|
Turn an in6_addr into a .ip6.arpa domain.
Definition at line 592 of file dns.cpp. References irc::hex(). Referenced by GetName(), and GetNameForce(). |
|
||||||||||||||||||||
|
Build a dns packet payload.
|
|
|
Portable random number generator, generates its random number from the ircd stats counters, effective user id, time of day and the rollover counter (currid).
Definition at line 1161 of file dns.cpp. References InspIRCd::Config, currid, ServerConfig::ports, ServerInstance, InspIRCd::stats, serverstats::statsAccept, serverstats::statsCollisions, serverstats::statsConnects, serverstats::statsDnsBad, serverstats::statsDnsGood, serverstats::statsRecv, and serverstats::statsSent. Referenced by AddQuery(). |
|
|
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. Definition at line 290 of file dns.cpp. References cache. Referenced by Rehash(), and CacheTimer::Tick(). |
|
|
Re-initialize the DNS subsystem.
Definition at line 306 of file dns.cpp. References SocketEngine::AddFd(), InspIRCd::BindSocket(), cache, SocketEngine::Close(), InspIRCd::Config, DEBUG, DEFAULT, SocketEngine::DelFd(), ServerConfig::DNSServer, ip6munge, LogManager::Log(), InspIRCd::Logs, SocketEngine::NonBlocking(), irc::sockets::OpenTCPSocket(), PruneCache(), InspIRCd::SE, ServerInstance, EventHandler::SetFd(), SocketEngine::Shutdown(), and socketfamily. Referenced by DNS(), and InspIRCd::Run(). |
|
|
Currently cached items.
Definition at line 360 of file dns.h. Referenced by ClearCache(), DelCache(), DNS(), GetCache(), HandleEvent(), PruneCache(), and Rehash(). |
|
|
Currently active Resolver classes.
Definition at line 393 of file dns.h. Referenced by AddResolverClass(), CleanResolvers(), DNS(), HandleEvent(), and RequestTimeout::Tick(). |
|
|
A counter used to form part of the pseudo-random id.
|
|
|
We have to turn off a few checks on received packets when people are using 4in6 (e.g. ffff:xxxx). This is a temporary kludge, Please let me know if you know how to fix it. Definition at line 355 of file dns.h. Referenced by GetResult(), and Rehash(). |
|
|
The maximum value of a dns request id, 16 bits wide, 0xFFFF.
Definition at line 342 of file dns.h. Referenced by AddQuery(), and CleanResolvers(). |
|
|
IPV4 server address.
Definition at line 388 of file dns.h. Referenced by DNSRequest::SendRequests(). |
|
|
A timer which ticks every hour to remove expired items from the DNS cache.
Definition at line 365 of file dns.h. Referenced by DNS(). |
|
|
The port number DNS requests are made on, and replies have as a source-port number.
Definition at line 404 of file dns.h. Referenced by GetResult(), and DNSRequest::SendRequests(). |
|
|
Requests that are currently 'in flight'.
Definition at line 398 of file dns.h. Referenced by AddQuery(), DNS(), GetResult(), and RequestTimeout::Tick(). |
|
|
Creator/Owner object.
Definition at line 336 of file dns.h. Referenced by AddQuery(), AddResolverClass(), DNS(), GetResult(), HandleEvent(), PRNG(), Rehash(), and ~DNS(). |
|
|
Server address being used currently.
Definition at line 377 of file dns.h. Referenced by GetResult(), and Rehash(). |