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>
Sat, 27 Sep 2014 17:48:13 +0000 (18:48 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
resolver.c
secnet.h
site.c

index 6477777..f2023fa 100644 (file)
@@ -48,9 +48,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);
+           cb(cst,&ca,1,0);
        else
-           cb(cst,0,0);
+           cb(cst,0,0,"invalid IP address");
        return True;
     }
 
@@ -96,7 +96,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); /* Failure */
+               q->answer(q->cst,NULL,0,adns_strerror(ans->status));
                free(q);
                free(ans);
            } else {
@@ -132,7 +132,7 @@ static void resolver_afterpoll(void *sst, struct pollfd *fds, int nfds)
                        break;
                    }
                }
-               q->answer(q->cst,ca_buf,wslot);
+               q->answer(q->cst,ca_buf,wslot,0);
                free(q);
                free(ans);
            }
index 71f7066..0ac3f46 100644 (file)
--- a/secnet.h
+++ b/secnet.h
@@ -295,7 +295,7 @@ struct buffer_if;
    will be freed once resolve_answer_fn returns. It is in network byte
    order. */
 typedef void resolve_answer_fn(void *st, const struct comm_addr *addrs,
-                              int naddrs);
+                              int 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 e705703..d1cc25f 100644 (file)
--- a/site.c
+++ b/site.c
@@ -1193,7 +1193,7 @@ static bool_t send_msg(struct site *st)
 }
 
 static void site_resolve_callback(void *sst, const struct comm_addr *addrs,
-                                 int naddrs)
+                                 int naddrs, const char *failwhy)
 {
     struct site *st=sst;
 
@@ -1203,7 +1203,7 @@ static void site_resolve_callback(void *sst, const struct comm_addr *addrs,
        slog(st,LOG_STATE,"resolution of %s completed, %d addrs, eg: %s",
             st->address, naddrs, comm_addr_to_string(&addrs[0]));;
     } 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) {