[or-cvs] solve the first half of bug 199: if we don"t like the looks

arma at seul.org arma at seul.org
Wed Oct 19 02:07:13 UTC 2005


Update of /home2/or/cvsroot/tor/src/or
In directory moria:/home/arma/work/onion/cvs/tor/src/or

Modified Files:
	connection_edge.c 
Log Message:
solve the first half of bug 199: if we don't like the looks
of an address, but it's the controller's job to handle it,
don't refuse it first.


Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.355
retrieving revision 1.356
diff -u -d -r1.355 -r1.356
--- connection_edge.c	12 Oct 2005 19:08:48 -0000	1.355
+++ connection_edge.c	19 Oct 2005 02:07:11 -0000	1.356
@@ -925,6 +925,7 @@
   socks_request_t *socks;
   int sockshere;
   hostname_type_t addresstype;
+  int tor_should_handle_stream = !get_options()->LeaveStreamsUnattached;
 
   tor_assert(conn);
   tor_assert(conn->type == CONN_TYPE_AP);
@@ -963,7 +964,8 @@
   /* For address map controls, remap the address */
   addressmap_rewrite(socks->address, sizeof(socks->address));
 
-  if (address_is_in_virtual_range(socks->address)) {
+  if (tor_should_handle_stream &&
+      address_is_in_virtual_range(socks->address)) {
     /* This address was probably handed out by client_dns_get_unmapped_address,
      * but the mapping was discarded for some reason.  We *don't* want to send
      * the address through tor; that's likely to fail, and may leak
@@ -980,7 +982,7 @@
    */
   addresstype = parse_extended_hostname(socks->address);
 
-  if (addresstype == BAD_HOSTNAME) {
+  if (tor_should_handle_stream && addresstype == BAD_HOSTNAME) {
     log_fn(LOG_WARN, "Invalid hostname %s; rejecting", socks->address);
     connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);
     return -1;
@@ -1008,7 +1010,7 @@
         /* XXXX Should this use server->address instead? */
         in.s_addr = htonl(r->addr);
         strlcpy(socks->address, inet_ntoa(in), sizeof(socks->address));
-      } else {
+      } else if (tor_should_handle_stream) {
         log_fn(LOG_WARN,
                "Unrecognized server in exit address '%s.exit'. Refusing.",
                safe_str(socks->address));
@@ -1021,7 +1023,8 @@
   if (addresstype != ONION_HOSTNAME) {
     /* not a hidden-service request (i.e. normal or .exit) */
 
-    if (address_is_invalid_destination(socks->address)) {
+    if (tor_should_handle_stream &&
+        address_is_invalid_destination(socks->address)) {
       log_fn(LOG_WARN,"Destination '%s' seems to be an invalid hostname. Failing.",
              safe_str(socks->address));
       connection_mark_unattached_ap(conn, END_STREAM_REASON_TORPROTOCOL);



More information about the tor-commits mailing list