Lines 1-104
Link Here
|
1 |
--- src/res.c 2006-09-19 15:45:18.000000000 +0300 |
|
|
2 |
+++ src/res.c 2009-06-17 17:50:18.000000000 +0300 |
3 |
@@ -48,10 +48,15 @@ |
4 |
|
5 |
#include <res.h> |
6 |
|
7 |
+/* Prevent crashes due to invalid prototype/ABI */ |
8 |
+#if ARES_VERSION < 0x010600 |
9 |
+ #error "You have an old c-ares version on your system and/or Unreals c-ares failed to compile!" |
10 |
+#endif |
11 |
+ |
12 |
/* Forward declerations */ |
13 |
-void unrealdns_cb_iptoname(void *arg, int status, struct hostent *he); |
14 |
-void unrealdns_cb_nametoip_verify(void *arg, int status, struct hostent *he); |
15 |
-void unrealdns_cb_nametoip_link(void *arg, int status, struct hostent *he); |
16 |
+void unrealdns_cb_iptoname(void *arg, int status, int timeouts, struct hostent *he); |
17 |
+void unrealdns_cb_nametoip_verify(void *arg, int status, int timeouts, struct hostent *he); |
18 |
+void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct hostent *he); |
19 |
void unrealdns_delasyncconnects(void); |
20 |
static unsigned int unrealdns_haship(void *binaryip, int length); |
21 |
static void unrealdns_addtocache(char *name, void *binaryip, int length); |
22 |
@@ -240,7 +245,7 @@ |
23 |
#endif |
24 |
} |
25 |
|
26 |
-void unrealdns_cb_iptoname(void *arg, int status, struct hostent *he) |
27 |
+void unrealdns_cb_iptoname(void *arg, int status, int timeouts, struct hostent *he) |
28 |
{ |
29 |
DNSReq *r = (DNSReq *)arg; |
30 |
DNSReq *newr; |
31 |
@@ -290,7 +295,7 @@ |
32 |
} |
33 |
|
34 |
|
35 |
-void unrealdns_cb_nametoip_verify(void *arg, int status, struct hostent *he) |
36 |
+void unrealdns_cb_nametoip_verify(void *arg, int status, int timeouts, struct hostent *he) |
37 |
{ |
38 |
DNSReq *r = (DNSReq *)arg; |
39 |
aClient *acptr = r->cptr; |
40 |
@@ -363,7 +368,7 @@ |
41 |
unrealdns_freeandremovereq(r); |
42 |
} |
43 |
|
44 |
-void unrealdns_cb_nametoip_link(void *arg, int status, struct hostent *he) |
45 |
+void unrealdns_cb_nametoip_link(void *arg, int status, int timeouts, struct hostent *he) |
46 |
{ |
47 |
DNSReq *r = (DNSReq *)arg; |
48 |
int n; |
49 |
@@ -390,9 +395,11 @@ |
50 |
/* fatal error while resolving */ |
51 |
sendto_realops("Unable to resolve hostname '%s', when trying to connect to server %s.", |
52 |
r->name, r->linkblock->servername); |
53 |
+ r->linkblock->refcount--; |
54 |
unrealdns_freeandremovereq(r); |
55 |
return; |
56 |
} |
57 |
+ r->linkblock->refcount--; |
58 |
|
59 |
#ifdef INET6 |
60 |
if (((he->h_length != 4) && (he->h_length != 16)) || !he->h_addr_list[0]) |
61 |
@@ -715,21 +722,34 @@ |
62 |
} else |
63 |
if (*param == 'i') /* INFORMATION */ |
64 |
{ |
65 |
- struct ares_config_info inf; |
66 |
+ struct ares_options inf; |
67 |
int i; |
68 |
+ int optmask; |
69 |
|
70 |
- ares_get_config(&inf, resolver_channel); |
71 |
+ ares_save_options(resolver_channel, &inf, &optmask); |
72 |
|
73 |
sendtxtnumeric(sptr, "****** DNS Configuration Information ******"); |
74 |
sendtxtnumeric(sptr, " c-ares version: %s",ares_version(NULL)); |
75 |
- sendtxtnumeric(sptr, " timeout: %d", inf.timeout); |
76 |
- sendtxtnumeric(sptr, " tries: %d", inf.tries); |
77 |
- sendtxtnumeric(sptr, " # of servers: %d", inf.numservers); |
78 |
- for (i = 0; i < inf.numservers; i++) |
79 |
- sendtxtnumeric(sptr, " server #%d: %s", i+1, inf.servers[i] ? inf.servers[i] : "[???]"); |
80 |
- |
81 |
- /* TODO: free or get memleak ! */ |
82 |
+ |
83 |
+ if(optmask & ARES_OPT_TIMEOUTMS) |
84 |
+ sendtxtnumeric(sptr, " timeout: %d", inf.timeout); |
85 |
+ if(optmask & ARES_OPT_TRIES) |
86 |
+ sendtxtnumeric(sptr, " tries: %d", inf.tries); |
87 |
+ if(optmask & ARES_OPT_SERVERS) |
88 |
+ { |
89 |
+ sendtxtnumeric(sptr, " # of servers: %d", inf.nservers); |
90 |
+ for (i = 0; i < inf.nservers; i++) |
91 |
+ sendtxtnumeric(sptr, " server #%d: %s", i+1, inet_ntoa(inf.servers[i])); |
92 |
+ } |
93 |
+ if(optmask & ARES_OPT_DOMAINS) |
94 |
+ { |
95 |
+ sendtxtnumeric(sptr, " # of search domains: %d", inf.ndomains); |
96 |
+ for (i = 0; i < inf.ndomains; i++) |
97 |
+ sendtxtnumeric(sptr, " domain #%d: %s", i+1, inf.domains[i]); |
98 |
+ } |
99 |
sendtxtnumeric(sptr, "****** End of DNS Configuration Info ******"); |
100 |
+ |
101 |
+ ares_destroy_options(&inf); |
102 |
} else /* STATISTICS */ |
103 |
{ |
104 |
sendtxtnumeric(sptr, "DNS CACHE Stats:"); |