[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10427: Patch from Tup: treat RESOLVED_TYPE_ERROR_TRANSIENT as a SER (in tor/trunk: . src/or)



Author: nickm
Date: 2007-05-31 19:40:35 -0400 (Thu, 31 May 2007)
New Revision: 10427

Modified:
   tor/trunk/
   tor/trunk/src/or/connection_edge.c
   tor/trunk/src/or/dns.c
   tor/trunk/src/or/dnsserv.c
   tor/trunk/src/or/eventdns.c
Log:
 r13117@catbus:  nickm | 2007-05-31 19:40:32 -0400
 Patch from Tup: treat RESOLVED_TYPE_ERROR_TRANSIENT as a SERVERFAILED, and RESOLVED_TYPE_ERROR as NOTEXIST.  Generate transient/nontransient errors more sensibly.  Set flags better on DNS replies.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r13117] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2007-05-31 19:13:12 UTC (rev 10426)
+++ tor/trunk/src/or/connection_edge.c	2007-05-31 23:40:35 UTC (rev 10427)
@@ -57,7 +57,8 @@
     if (SOCKS_COMMAND_IS_CONNECT(conn->socks_request->command))
       connection_ap_handshake_socks_reply(conn, NULL, 0, endreason);
     else if (SOCKS_COMMAND_IS_RESOLVE(conn->socks_request->command))
-      connection_ap_handshake_socks_resolved(conn, RESOLVED_TYPE_ERROR,
+      connection_ap_handshake_socks_resolved(conn,
+                                             RESOLVED_TYPE_ERROR_TRANSIENT,
                                              0, NULL, -1);
     else /* unknown or no handshake at all. send no response. */
       conn->socks_request->has_finished = 1;
@@ -1306,7 +1307,8 @@
         log_warn(LD_APP,"Address to be resolved is too large. Failing.");
         control_event_client_status(LOG_WARN, "SOCKS_BAD_HOSTNAME HOSTNAME=%s",
                                     escaped(socks->address));
-        connection_ap_handshake_socks_resolved(conn,RESOLVED_TYPE_ERROR,
+        connection_ap_handshake_socks_resolved(conn,
+                                               RESOLVED_TYPE_ERROR_TRANSIENT,
                                                0,NULL,-1);
         connection_mark_unattached_ap(conn,
                                 END_STREAM_REASON_SOCKSPROTOCOL |

Modified: tor/trunk/src/or/dns.c
===================================================================
--- tor/trunk/src/or/dns.c	2007-05-31 19:13:12 UTC (rev 10426)
+++ tor/trunk/src/or/dns.c	2007-05-31 23:40:35 UTC (rev 10427)
@@ -990,7 +990,8 @@
         /* This detach must happen after we send the end cell. */
         circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
       } else {
-        send_resolved_cell(pendconn, RESOLVED_TYPE_ERROR);
+        send_resolved_cell(pendconn, outcome == DNS_RESOLVE_FAILED_PERMANENT ?
+                          RESOLVED_TYPE_ERROR : RESOLVED_TYPE_ERROR_TRANSIENT);
         /* This detach must happen after we send the resolved cell. */
         circuit_detach_stream(circuit_get_by_edge_conn(pendconn), pendconn);
       }

Modified: tor/trunk/src/or/dnsserv.c
===================================================================
--- tor/trunk/src/or/dnsserv.c	2007-05-31 19:13:12 UTC (rev 10426)
+++ tor/trunk/src/or/dnsserv.c	2007-05-31 23:40:35 UTC (rev 10427)
@@ -32,6 +32,8 @@
   tor_assert(_data == NULL);
   log_info(LD_APP, "Got a new DNS request!");
 
+  req->flags |= 0x80; /* set RA */
+
   /* First, check whether the requesting address matches our SOCKSPolicy. */
   if ((addrlen = evdns_server_request_get_requesting_addr(req,
                                 (struct sockaddr*)&addr, sizeof(addr))) < 0) {
@@ -81,8 +83,8 @@
   }
   if (!q) {
     log_info(LD_APP, "None of the questions we got were ones we're willing "
-             "to support. Sending error.");
-    evdns_server_request_respond(req, DNS_ERR_NOTIMPL);
+             "to support. Sending NODATA.");
+    evdns_server_request_respond(req, DNS_ERR_NONE);
     return;
   }
   if (q->type == EVDNS_TYPE_A) {
@@ -183,8 +185,10 @@
                                        conn->socks_request->address,
                                        (char*)answer, ttl);
     tor_free(ans);
-  } else {
-    err = DNS_ERR_SERVERFAILED; /* Really? Not noent? */
+  } else if (answer_type == RESOLVED_TYPE_ERROR) {
+    err = DNS_ERR_NOTEXIST;
+  } else { /* answer_type == RESOLVED_TYPE_ERROR_TRANSIENT */
+    err = DNS_ERR_SERVERFAILED;
   }
 
   evdns_server_request_respond(req, err);

Modified: tor/trunk/src/or/eventdns.c
===================================================================
--- tor/trunk/src/or/eventdns.c	2007-05-31 19:13:12 UTC (rev 10426)
+++ tor/trunk/src/or/eventdns.c	2007-05-31 23:40:35 UTC (rev 10427)
@@ -962,8 +962,7 @@
 	GET16(additional);
 
 	if (flags & 0x8000) return -1; // Must not be an answer.
-	if (flags & 0x7800) return -1; // only standard queries are supported
-	flags &= 0x0300; // Only TC and RD get preserved.
+	flags &= 0x0110; // Only RD and CD get preserved.
 
 	server_req = malloc(sizeof(struct server_request));
 	if (server_req == NULL) return -1;
@@ -1001,6 +1000,13 @@
 
 	server_req->port = port;
 	port->refcnt++;
+
+	// Only standard queries are supported.
+	if (flags & 0x7800) {
+		evdns_server_request_respond(&(server_req->base), DNS_ERR_NOTIMPL);
+		return -1;
+	}
+
 	port->user_callback(&(server_req->base), port->user_data);
 
 	return 0;