summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-05-24 20:31:27 +0000
committerNick Mathewson <nickm@torproject.org>2007-05-24 20:31:27 +0000
commit17830bc03ba26dc90258f436fbd9786cf769027c (patch)
tree90e27486b71c7c4a5c8fbfdebab04a5272293d82 /src
parenta312afd67ed94422c1e23d67483ed6b67c39da28 (diff)
downloadtor-17830bc03ba26dc90258f436fbd9786cf769027c.tar.gz
tor-17830bc03ba26dc90258f436fbd9786cf769027c.zip
r12941@catbus: nickm | 2007-05-24 16:25:00 -0400
Fix some eventdns dns server bugs, and add a new eventdns function to get the address of whoever requested this lookup. svn:r10316
Diffstat (limited to 'src')
-rw-r--r--src/or/eventdns.c16
-rw-r--r--src/or/eventdns.h3
2 files changed, 17 insertions, 2 deletions
diff --git a/src/or/eventdns.c b/src/or/eventdns.c
index 48db73d7ce..0ac47fba61 100644
--- a/src/or/eventdns.c
+++ b/src/or/eventdns.c
@@ -1708,7 +1708,7 @@ evdns_server_request_respond(struct evdns_server_request *_req, int err)
if (server_request_free(req))
return 0;
- if (req->port->pending_replies)
+ if (port->pending_replies)
server_port_flush(port);
return 0;
@@ -1797,7 +1797,8 @@ server_port_free(struct evdns_server_port *port)
}
(void) event_del(&port->event);
CLEAR(&port->event);
- // XXXX actually free the port? -NM
+ // XXXX020 actually free the port? -NM
+ // XXXX yes, and fix up evdns_close_server_port to dtrt. -NM
}
// exported function
@@ -1809,6 +1810,17 @@ evdns_server_request_drop(struct evdns_server_request *_req)
return 0;
}
+// exported function
+int
+evdns_server_request_get_requesting_addr(struct evdns_server_request *_req, struct sockaddr *sa, socklen_t addr_len)
+{
+ struct server_request *req = TO_SERVER_REQUEST(_req);
+ if (addr_len < req->addrlen)
+ return -1;
+ memcpy(sa, &(req->addr), req->addrlen);
+ return req->addrlen;
+}
+
#undef APPEND16
#undef APPEND32
diff --git a/src/or/eventdns.h b/src/or/eventdns.h
index 4275031543..058b4d1b77 100644
--- a/src/or/eventdns.h
+++ b/src/or/eventdns.h
@@ -323,6 +323,9 @@ int evdns_server_request_add_aaaa_reply(struct evdns_server_request *req, const
int evdns_server_request_add_ptr_reply(struct evdns_server_request *req, struct in_addr *in, const char *inaddr_name, const char *hostname, int ttl);
int evdns_server_request_add_cname_reply(struct evdns_server_request *req, const char *name, const char *cname, int ttl);
+struct sockaddr;
+int evdns_server_request_get_requesting_addr(struct evdns_server_request *req, struct sockaddr *sa, socklen_t addr_len);
+
int evdns_server_request_respond(struct evdns_server_request *req, int err);
int evdns_server_request_drop(struct evdns_server_request *req);