[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] Make stream events for RESOLVE lookups more consistent
commit 3f837d4826cce0e7917e79d73b81aefc3fefc6bd
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Mon Mar 18 15:13:59 2013 -0400
Make stream events for RESOLVE lookups more consistent
Fixes 8203; patch by Desoxy
---
changes/bug8203 | 4 ++++
src/or/connection_edge.c | 15 +++++++++------
src/or/control.c | 10 +++-------
src/or/dnsserv.c | 10 ++++++++--
src/or/dnsserv.h | 2 +-
5 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/changes/bug8203 b/changes/bug8203
new file mode 100644
index 0000000..d26dc0f
--- /dev/null
+++ b/changes/bug8203
@@ -0,0 +1,4 @@
+ o Minor bugfixes:
+ - Make the format and order of STREAM events for DNS lookups consistent
+ among the various ways to launch DNS lookups. Fix for bug 8203;
+ bugfix on 0.2.0.24-rc. Patch by "Desoxy."
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 84d5565..0660b1f 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -1945,13 +1945,14 @@ connection_ap_handshake_send_resolve(entry_connection_t *ap_conn)
string_addr, payload_len) < 0)
return -1; /* circuit is closed, don't continue */
- tor_free(base_conn->address); /* Maybe already set by dnsserv. */
- base_conn->address = tor_strdup("(Tor_internal)");
+ if (!base_conn->address) {
+ /* This might be unnecessary. XXXX */
+ base_conn->address = tor_dup_addr(&base_conn->addr);
+ }
base_conn->state = AP_CONN_STATE_RESOLVE_WAIT;
log_info(LD_APP,"Address sent for resolve, ap socket "TOR_SOCKET_T_FORMAT
", n_circ_id %u",
base_conn->s, (unsigned)circ->base_.n_circ_id);
- control_event_stream_status(ap_conn, STREAM_EVENT_NEW, 0);
control_event_stream_status(ap_conn, STREAM_EVENT_SENT_RESOLVE, 0);
return 0;
}
@@ -2201,9 +2202,11 @@ connection_ap_handshake_socks_reply(entry_connection_t *conn, char *reply,
tor_assert(conn->socks_request); /* make sure it's an AP stream */
- control_event_stream_status(conn,
- status==SOCKS5_SUCCEEDED ? STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED,
- endreason);
+ if (!SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command)) {
+ control_event_stream_status(conn, status==SOCKS5_SUCCEEDED ?
+ STREAM_EVENT_SUCCEEDED : STREAM_EVENT_FAILED,
+ endreason);
+ }
/* Flag this stream's circuit as having completed a stream successfully
* (for path bias) */
diff --git a/src/or/control.c b/src/or/control.c
index 03e5d79..2a68464 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -2939,7 +2939,7 @@ handle_control_resolve(control_connection_t *conn, uint32_t len,
failed = smartlist_new();
SMARTLIST_FOREACH(args, const char *, arg, {
if (!is_keyval_pair(arg)) {
- if (dnsserv_launch_request(arg, is_reverse)<0)
+ if (dnsserv_launch_request(arg, is_reverse, conn)<0)
smartlist_add(failed, (char*)arg);
}
});
@@ -3742,7 +3742,7 @@ control_event_stream_status(entry_connection_t *conn, stream_status_event_t tp,
}
}
- if (tp == STREAM_EVENT_NEW) {
+ if (tp == STREAM_EVENT_NEW || tp == STREAM_EVENT_NEW_RESOLVE) {
tor_snprintf(addrport_buf,sizeof(addrport_buf), " SOURCE_ADDR=%s:%d",
ENTRY_TO_CONN(conn)->address, ENTRY_TO_CONN(conn)->port);
} else {
@@ -3752,11 +3752,7 @@ control_event_stream_status(entry_connection_t *conn, stream_status_event_t tp,
if (tp == STREAM_EVENT_NEW_RESOLVE) {
purpose = " PURPOSE=DNS_REQUEST";
} else if (tp == STREAM_EVENT_NEW) {
- if (ENTRY_TO_EDGE_CONN(conn)->is_dns_request ||
- (conn->socks_request &&
- SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command)))
- purpose = " PURPOSE=DNS_REQUEST";
- else if (conn->use_begindir) {
+ if (conn->use_begindir) {
connection_t *linked = ENTRY_TO_CONN(conn)->linked_conn;
int linked_dir_purpose = -1;
if (linked && linked->type == CONN_TYPE_DIR)
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index 7032b58..e877b18 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -147,7 +147,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
return;
}
- control_event_stream_status(entry_conn, STREAM_EVENT_NEW, 0);
+ control_event_stream_status(entry_conn, STREAM_EVENT_NEW_RESOLVE, 0);
/* Now, unless a controller asked us to leave streams unattached,
* throw the connection over to get rewritten (which will
@@ -170,7 +170,7 @@ evdns_server_callback(struct evdns_server_request *req, void *data_)
* response; -1 if we couldn't launch the request.
*/
int
-dnsserv_launch_request(const char *name, int reverse)
+dnsserv_launch_request(const char *name, int reverse, control_connection_t *control_conn)
{
entry_connection_t *entry_conn;
edge_connection_t *conn;
@@ -181,6 +181,10 @@ dnsserv_launch_request(const char *name, int reverse)
conn = ENTRY_TO_EDGE_CONN(entry_conn);
conn->base_.state = AP_CONN_STATE_RESOLVE_WAIT;
+ tor_addr_copy(&TO_CONN(conn)->addr, &control_conn->base_.addr);
+ TO_CONN(conn)->port = control_conn->base_.port;
+ TO_CONN(conn)->address = tor_dup_addr(&control_conn->base_.addr);
+
if (reverse)
entry_conn->socks_request->command = SOCKS_COMMAND_RESOLVE_PTR;
else
@@ -203,6 +207,8 @@ dnsserv_launch_request(const char *name, int reverse)
return -1;
}
+ control_event_stream_status(entry_conn, STREAM_EVENT_NEW_RESOLVE, 0);
+
/* Now, unless a controller asked us to leave streams unattached,
* throw the connection over to get rewritten (which will
* answer it immediately if it's in the cache, or completely bogus, or
diff --git a/src/or/dnsserv.h b/src/or/dnsserv.h
index 6bdb98d..8462841 100644
--- a/src/or/dnsserv.h
+++ b/src/or/dnsserv.h
@@ -20,7 +20,7 @@ void dnsserv_resolved(entry_connection_t *conn,
const char *answer,
int ttl);
void dnsserv_reject_request(entry_connection_t *conn);
-int dnsserv_launch_request(const char *name, int is_reverse);
+int dnsserv_launch_request(const char *name, int is_reverse, control_connection_t *control_conn);
#endif
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits