summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-06-17 15:59:27 +0000
committerNick Mathewson <nickm@torproject.org>2007-06-17 15:59:27 +0000
commit721899a44736607f6a6c9477cb42625c91fcec7a (patch)
treef06a0abd12ca44aadd700ada49af2d42f98c8389
parentd828915136af1aac50b94a4567584b3745b13f8a (diff)
downloadtor-721899a44736607f6a6c9477cb42625c91fcec7a.tar.gz
tor-721899a44736607f6a6c9477cb42625c91fcec7a.zip
r13471@catbus: nickm | 2007-06-17 11:59:25 -0400
Report address and por correctly on requests to dnsport. (Patch from Robert Hogan.) svn:r10641
-rw-r--r--ChangeLog2
-rw-r--r--src/or/dnsserv.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 782c04f3f6..9434f3afe6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,8 @@ Changes in version 0.2.0.3-alpha - 2007-??-??
o Minor features (controller):
- Add a SOURCE_ADDR field to STREAM NEW events so that controllers can
match requests to applications. (Patch from Robert Hogan.)
+ - Report address and port correctly on connections to DNSPort. (Patch
+ from Robert Hogan.)
o Deprecated features:
- RedirectExits is now deprecated.
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 659d264a7b..d0b1cdaab5 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -23,6 +23,7 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
struct evdns_server_question *q = NULL;
struct sockaddr_storage addr;
struct sockaddr *sa;
+ struct sockaddr_in *sin;
int addrlen;
uint32_t ipaddr;
int err = DNS_ERR_NONE;
@@ -49,9 +50,10 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
evdns_server_request_respond(req, DNS_ERR_SERVERFAILED);
return;
} else {
- struct sockaddr_in *sin = (struct sockaddr_in*)&addr;
+ sin = (struct sockaddr_in*)&addr;
ipaddr = ntohl(sin->sin_addr.s_addr);
}
+
if (!socks_policy_permits_address(ipaddr)) {
log_warn(LD_APP, "Rejecting DNS request from disallowed IP.");
evdns_server_request_respond(req, DNS_ERR_REFUSED);
@@ -112,6 +114,11 @@ evdns_server_callback(struct evdns_server_request *req, void *_data)
/* Make a new dummy AP connection, and attach the request to it. */
conn = TO_EDGE_CONN(connection_new(CONN_TYPE_AP, AF_INET));
conn->_base.state = AP_CONN_STATE_RESOLVE_WAIT;
+
+ TO_CONN(conn)->addr = ntohl(sin->sin_addr.s_addr);
+ TO_CONN(conn)->port = ntohs(sin->sin_port);
+ TO_CONN(conn)->address = tor_dup_addr(TO_CONN(conn)->addr);
+
if (q->type == EVDNS_TYPE_A)
conn->socks_request->command = SOCKS_COMMAND_RESOLVE;
else