|
Revision 5, 1.2 KB
(checked in by nick, 3 years ago)
|
|
|
| Line | |
|---|
| 1 | /* |
|---|
| 2 | ApacheTop resolver functions |
|---|
| 3 | |
|---|
| 4 | parse() will call add_request() |
|---|
| 5 | this checks to see if we have an IP -> host mapping already |
|---|
| 6 | if not it fires off adns_submit_reverse |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | #if HAVE_ADNS_H |
|---|
| 12 | |
|---|
| 13 | #include "apachetop.h" |
|---|
| 14 | |
|---|
| 15 | Resolver::Resolver(void) |
|---|
| 16 | { |
|---|
| 17 | if (adns_init(&adns, adns_if_noenv, 0) != 0) |
|---|
| 18 | { |
|---|
| 19 | perror("adns_init"); |
|---|
| 20 | exit(1); |
|---|
| 21 | } |
|---|
| 22 | } |
|---|
| 23 | |
|---|
| 24 | Resolver::~Resolver(void) |
|---|
| 25 | { |
|---|
| 26 | adns_finish(adns); |
|---|
| 27 | } |
|---|
| 28 | |
|---|
| 29 | int Resolver::add_request(char *request, enum resolver_action act) |
|---|
| 30 | { |
|---|
| 31 | struct sockaddr_in addr; |
|---|
| 32 | |
|---|
| 33 | /* depending on resolver_action, this is an IP or a host to lookup |
|---|
| 34 | * the other way */ |
|---|
| 35 | |
|---|
| 36 | /* at the moment we only do IPs */ |
|---|
| 37 | |
|---|
| 38 | switch(act) |
|---|
| 39 | { |
|---|
| 40 | case resolver_gethost: |
|---|
| 41 | |
|---|
| 42 | /* see if this IP is in host_ip_tablei; if it is we may be |
|---|
| 43 | * able to get a host for it (or an adns is already looking |
|---|
| 44 | * it up/has looked it up and got negative reply) */ |
|---|
| 45 | |
|---|
| 46 | |
|---|
| 47 | addr.sin_family = AF_INET; |
|---|
| 48 | /* add error checking */ |
|---|
| 49 | #if HAVE_INET_ATON |
|---|
| 50 | inet_aton(request, &(addr.sin_addr)); |
|---|
| 51 | #else |
|---|
| 52 | addr.sin_addr.s_addr = inet_addr(request); |
|---|
| 53 | #endif |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | // adns_submit_reverse(adns, (struct sockaddr *)&addr, adns_r_ptr, |
|---|
| 57 | // (enum adns_queryflags)adns_qf_owner, NULL, b->dns_query); |
|---|
| 58 | |
|---|
| 59 | break; |
|---|
| 60 | } |
|---|
| 61 | } |
|---|
| 62 | #endif /* HAVE_ADNS_H */ |
|---|