C-Ares: add the query data to the errormessage, so the user can evaluate this informa...
authorWilfried Goesgens <dothebart@citadel.org>
Sun, 19 Aug 2012 14:57:59 +0000 (16:57 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Sun, 19 Aug 2012 14:57:59 +0000 (16:57 +0200)
citadel/event_client.h
citadel/modules/c-ares-dns/serv_c-ares-dns.c

index 2d26c2877b645030a5df06af25979db49f1199b4..4be26614c215837d904f70d508aafd5a82e1f1e2 100644 (file)
@@ -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;
index 8878f995f67d63a3fbe0d95866388c75a87472d1..846720b35a2c3f3513e21570eac1042d9e02f0a4 100644 (file)
@@ -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;