chiark / gitweb /
resolver: Log reason for DNS resolution failure
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 18 Sep 2014 17:38:17 +0000 (18:38 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 5 Oct 2014 21:39:06 +0000 (22:39 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
resolver.c
secnet.h
site.c

index d203a96..83afd2f 100644 (file)
@@ -47,9 +47,9 @@ static bool_t resolve_request(void *sst, cstring_t name,
        ca.ia.sin.sin_family=AF_INET;
        ca.ia.sin.sin_port=htons(port);
        if (inet_aton(trimmed,&ca.ia.sin.sin_addr))
-           cb(cst,&ca,1,1);
+           cb(cst,&ca,1,1,0);
        else
-           cb(cst,0,0,0);
+           cb(cst,0,0,0,"invalid IP address");
        return True;
     }
 
@@ -95,7 +95,7 @@ static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds)
        if (rv==0) {
            q=qp;
            if (ans->status!=adns_s_ok) {
-               q->answer(q->cst,NULL,0,0); /* Failure */
+               q->answer(q->cst,NULL,0,0,adns_strerror(ans->status));
                free(q);
                free(ans);
            } else {
@@ -127,7 +127,7 @@ static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds)
                    memcpy(&ca->ia,&ra->addr,ra->len);
                    wslot++;
                }
-               q->answer(q->cst,ca_buf,wslot,total);
+               q->answer(q->cst,ca_buf,wslot,total,0);
                free(q);
                free(ans);
            }
index ad4d91c..6724698 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -297,7 +297,8 @@ struct buffer_if;
    actually found in the DNS, which may be bigger if addrs is equal
    to MAX_PEER_ADDRS (ie there were too many). */
 typedef void resolve_answer_fn(void *st, const struct comm_addr *addrs,
-                              int naddrs, int was_naddrs);
+                              int naddrs, int was_naddrs,
+                              const char *failwhy);
 typedef bool_t resolve_request_fn(void *st, cstring_t name,
                                  int remoteport, struct comm_if *comm,
                                  resolve_answer_fn *cb, void *cst);
diff --git a/site.c b/site.c
index d360699..15dace8 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1191,7 +1191,8 @@ static bool_t send_msg(struct site *st)
 }
 
 static void site_resolve_callback(void *sst, const struct comm_addr *addrs,
-                                 int naddrs, int was_naddrs)
+                                 int naddrs, int was_naddrs,
+                                 const char *failwhy)
 {
     struct site *st=sst;
 
@@ -1206,7 +1207,7 @@ static void site_resolve_callback(void *sst, const struct comm_addr *addrs,
                 was_naddrs, naddrs);
        }
     } else {
-       slog(st,LOG_ERROR,"resolution of %s failed",st->address);
+       slog(st,LOG_ERROR,"resolution of %s failed: %s",st->address,failwhy);
     }
 
     switch (st->state) {