unrealircd- supernets unrealircd source & configuration |
git clone git://git.acid.vegas/unrealircd.git |
Log | Files | Refs | Archive | README | LICENSE |
dns.h (1965B)
1 /* OMG... OMG! WHAT AN INCLUDE HORROR !!! */ 2 #include <ares.h> 3 #include <ares_version.h> 4 5 typedef enum { 6 DNSREQ_CLIENT = 1, 7 DNSREQ_LINKCONF = 2, 8 DNSREQ_CONNECT = 3 9 } DNSReqType; 10 11 typedef struct DNSReq DNSReq; 12 13 /* Depending on the request type, some fields are filled in: 14 * cptr: DNSREQ_CLIENT, DNSREQ_CONNECT 15 * link: DNSREQ_LINKCONF, DNSREQ_CONNECT 16 */ 17 18 struct DNSReq { 19 DNSReq *prev, *next; 20 char *name; /**< Name being resolved (only for DNSREQ_LINKCONF and DNSREQ_CONNECT) */ 21 char ipv6; /**< Resolving for ipv6 or ipv4? */ 22 DNSReqType type; /**< DNS Request type (DNSREQ_*) */ 23 Client *client; /**< Client the request is for, NULL if client died OR unavailable */ 24 ConfigItem_link *linkblock; /**< Linkblock */ 25 }; 26 27 typedef struct DNSCache DNSCache; 28 29 struct DNSCache { 30 DNSCache *prev, *next; /**< Previous and next in linked list */ 31 DNSCache *hprev, *hnext; /**< Previous and next in hash list */ 32 char *name; /**< The hostname */ 33 char *ip; /**< The IP address */ 34 time_t expires; /**< When record expires */ 35 }; 36 37 typedef struct DNSStats DNSStats; 38 39 struct DNSStats { 40 unsigned int cache_hits; 41 unsigned int cache_misses; 42 unsigned int cache_adds; 43 }; 44 45 /** Time to keep cache records. */ 46 #define DNSCACHE_TTL 600 47 48 /** Size of the hash table (prime!). 49 * Consumes <this>*4 on ia32 and <this>*4 on 64 bit 50 * 241 seems a good bet.. which ~1k on ia32 and ~2k on ia64. 51 */ 52 #define DNS_HASH_SIZE 241 53 54 /** Max # of entries we want in our cache. 55 * This: 56 * a) prevents us from using too much memory, and 57 * b) prevents us from keeping useless cache records 58 * 59 * A dnscache item is roughly ~80 bytes in size (slightly more on x86), 60 * so 241*80=~20k, which seems reasonable ;). 61 */ 62 #define DNS_MAX_ENTRIES DNS_HASH_SIZE 63 64 65 extern ares_channel resolver_channel; 66 67 extern void init_resolver(int); 68 69 struct hostent *unrealdns_doclient(Client *cptr); 70 71 extern void unreal_gethostbyname(const char *name, int family, ares_host_callback callback, void *arg); 72