- Timestamp:
- Jun 17, 2014, 11:33:22 AM (11 years ago)
- Branches:
- master
- Children:
- 120eedd
- Parents:
- d45051e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
dns.c
rd45051e r9440414 33 33 #include "icbd.h" 34 34 35 void dns_done(struct asr_result *, void *); 35 void dns_done_host(struct asr_result *, void *); 36 void dns_done_reverse(struct asr_result *, void *); 36 37 37 38 extern int dodns; 38 39 39 40 void 40 dns_done (struct asr_result *ar, void *arg)41 dns_done_host(struct asr_result *ar, void *arg) 41 42 { 42 43 struct icb_session *is = arg; 43 44 45 if (ar->ar_addrinfo) 46 freeaddrinfo(ar->ar_addrinfo); 47 48 /* just check that there's no error */ 44 49 if (ar->ar_gai_errno == 0) { 45 icbd_log(is, LOG_DEBUG, "dns resolved %s to %s", is->host,46 is->hostname);47 50 if (strncmp(is->hostname, "localhost", 48 51 sizeof "localhost" - 1) == 0) … … 56 59 57 60 void 58 dns_rresolv(struct icb_session *is, struct sockaddr *sa) 61 dns_done_reverse(struct asr_result *ar, void *arg) 62 { 63 struct icb_session *is = arg; 64 struct asr_query *as; 65 struct addrinfo hints; 66 67 if (ar->ar_gai_errno == 0) { 68 icbd_log(is, LOG_DEBUG, "reverse dns resolved %s to %s", 69 is->host, is->hostname); 70 /* try to verify that it resolves back */ 71 memset(&hints, 0, sizeof(hints)); 72 hints.ai_family = PF_UNSPEC; 73 as = getaddrinfo_async(is->hostname, NULL, &hints, NULL); 74 event_asr_run(as, dns_done_host, is); 75 } else 76 icbd_log(is, LOG_WARNING, "reverse dns resolution failed: %s", 77 gai_strerror(ar->ar_gai_errno)); 78 } 79 80 void 81 dns_resolve(struct icb_session *is, struct sockaddr *sa) 59 82 { 60 83 struct asr_query *as; … … 68 91 as = getnameinfo_async(sa, sa->sa_len, is->hostname, 69 92 sizeof is->hostname, NULL, 0, NI_NOFQDN, NULL); 70 event_asr_run(as, dns_done , is);93 event_asr_run(as, dns_done_reverse, is); 71 94 } 95
Note:
See TracChangeset
for help on using the changeset viewer.