From 4b49575b46e9726cc7f629c935bf4e110361d01c Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Sun, 19 Aug 2012 16:57:59 +0200 Subject: [PATCH] C-Ares: add the query data to the errormessage, so the user can evaluate this information. --- citadel/event_client.h | 2 ++ citadel/modules/c-ares-dns/serv_c-ares-dns.c | 28 +++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/citadel/event_client.h b/citadel/event_client.h index 2d26c2877..4be26614c 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -71,6 +71,8 @@ typedef struct _DNSQueryParts { ParseDNSAnswerCb DNS_CB; IO_CallBack PostDNS; + const char *QueryTYPE; + const char *QStr; int DNSStatus; void *VParsedDNSReply; FreeDNSReply DNSReplyFree; diff --git a/citadel/modules/c-ares-dns/serv_c-ares-dns.c b/citadel/modules/c-ares-dns/serv_c-ares-dns.c index 8878f995f..846720b35 100644 --- a/citadel/modules/c-ares-dns/serv_c-ares-dns.c +++ b/citadel/modules/c-ares-dns/serv_c-ares-dns.c @@ -280,7 +280,11 @@ void QueryCb(void *arg, EV_DNS_syslog(LOG_DEBUG, "C-ARES: Failed by: %s error %s\n", __FUNCTION__, ares_strerror(status)); - StrBufPlain(IO->ErrMsg, ares_strerror(status), -1); + StrBufPrintf(IO->ErrMsg, + "%s-lookup %s - %s", + IO->DNS.Query->QueryTYPE, + (IO->DNS.Query->QStr != NULL)? IO->DNS.Query->QStr : "", + ares_strerror(status)); IO->DNS.Query->DNSStatus = status; } @@ -415,6 +419,17 @@ void QueueGetHostByName(AsyncIO *IO, } +const char* QT[] = { + "A", + "AAAA", + "MX", + "NS", + "TXT", + "SRV", + "CNAME", + "PTR" +}; + int QueueQuery(ns_type Type, const char *name, AsyncIO *IO, @@ -429,6 +444,7 @@ int QueueQuery(ns_type Type, IO->DNS.Query = QueryParts; IO->DNS.Query->PostDNS = PostDNS; IO->DNS.Start = IO->Now; + IO->DNS.Query->QStr = name; InitC_ares_dns(IO); @@ -439,35 +455,41 @@ int QueueQuery(ns_type Type, switch(Type) { case ns_t_a: IO->DNS.Query->DNS_CB = ParseAnswerA; + IO->DNS.Query->QueryTYPE = QT[0]; break; case ns_t_aaaa: IO->DNS.Query->DNS_CB = ParseAnswerAAAA; + IO->DNS.Query->QueryTYPE = QT[1]; break; case ns_t_mx: IO->DNS.Query->DNS_CB = ParseAnswerMX; + IO->DNS.Query->QueryTYPE = QT[2]; break; case ns_t_ns: IO->DNS.Query->DNS_CB = ParseAnswerNS; + IO->DNS.Query->QueryTYPE = QT[3]; break; case ns_t_txt: IO->DNS.Query->DNS_CB = ParseAnswerTXT; + IO->DNS.Query->QueryTYPE = QT[4]; break; case ns_t_srv: IO->DNS.Query->DNS_CB = ParseAnswerSRV; + IO->DNS.Query->QueryTYPE = QT[5]; break; case ns_t_cname: IO->DNS.Query->DNS_CB = ParseAnswerCNAME; + IO->DNS.Query->QueryTYPE = QT[6]; break; case ns_t_ptr: - - + IO->DNS.Query->QueryTYPE = QT[7]; if (inet_pton(AF_INET, name, &address_b) == 1) { length = sizeof(struct in_addr); family = AF_INET; -- 2.30.2