[or-cvs] r10332: hack to make reverse lookups work with dnsport. note that it (in tor/trunk: . src/or)

nickm at seul.org nickm at seul.org
Fri May 25 18:49:26 UTC 2007


Author: nickm
Date: 2007-05-25 14:49:26 -0400 (Fri, 25 May 2007)
New Revision: 10332

Modified:
   tor/trunk/
   tor/trunk/src/or/connection_edge.c
Log:
 r12964 at catbus:  nickm | 2007-05-25 14:49:23 -0400
 hack to make reverse lookups work with dnsport.  note that it is a hack. note some trouble spots.



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

Modified: tor/trunk/src/or/connection_edge.c
===================================================================
--- tor/trunk/src/or/connection_edge.c	2007-05-25 18:40:09 UTC (rev 10331)
+++ tor/trunk/src/or/connection_edge.c	2007-05-25 18:49:26 UTC (rev 10332)
@@ -1209,9 +1209,11 @@
 
   if (socks->command == SOCKS_COMMAND_RESOLVE_PTR) {
     if (addressmap_rewrite_reverse(socks->address, sizeof(socks->address))) {
+      char *result = tor_strdup(socks->address);
+      /* remember _what_ is supposed to have been resolved. */
+      strlcpy(socks->address, orig_address, sizeof(socks->address));
       connection_ap_handshake_socks_resolved(conn, RESOLVED_TYPE_HOSTNAME,
-                                             strlen(socks->address),
-                                             socks->address, -1);
+                                             strlen(result), result, -1);
       connection_mark_unattached_ap(conn,
                                  END_STREAM_REASON_DONE |
                                  END_STREAM_REASON_FLAG_ALREADY_SOCKS_REPLIED);
@@ -1363,7 +1365,7 @@
                    conn, circ, cpath) < 0) ||
         (!circ &&
          connection_ap_handshake_attach_circuit(conn) < 0)) {
-      connection_mark_unattached_ap(conn, END_STREAM_REASON_CANT_ATTACH);
+      connection_mark_unattached_ap(conn, END_STREAM_REASON_CANT_ATTACH);//xxxdup
       return -1;
     }
     return 0;
@@ -1847,16 +1849,30 @@
   } else {
     struct in_addr in;
     uint32_t a;
+    size_t len = strlen(ap_conn->socks_request->address);
+    char c = 0;
+    if (!strcasecmpend(ap_conn->socks_request->address, ".in-addr.arpa")) {
+      c = ap_conn->socks_request->address[len-13];
+      ap_conn->socks_request->address[len-13] = '\0';
+    }
     if (tor_inet_aton(ap_conn->socks_request->address, &in) == 0) {
       connection_mark_unattached_ap(ap_conn, END_STREAM_REASON_INTERNAL);
       return -1;
     }
-    a = ntohl(in.s_addr);
-    tor_snprintf(inaddr_buf, sizeof(inaddr_buf), "%d.%d.%d.%d.in-addr.arpa",
-                 (int)(uint8_t)((a    )&0xff),
-                 (int)(uint8_t)((a>>8 )&0xff),
-                 (int)(uint8_t)((a>>16)&0xff),
-                 (int)(uint8_t)((a>>24)&0xff));
+    /* DOCDOC */
+    if (c) {
+      /* this path happens on DNS. Can we unify? XXXX020 */
+      ap_conn->socks_request->address[len-13] = c;
+      strlcpy(inaddr_buf, ap_conn->socks_request->address, sizeof(inaddr_buf));
+    } else {
+      /* this path happens on tor-resolve. Can we unify? XXXX020 */
+      a = ntohl(in.s_addr);
+      tor_snprintf(inaddr_buf, sizeof(inaddr_buf), "%d.%d.%d.%d.in-addr.arpa",
+                   (int)(uint8_t)((a    )&0xff),
+                   (int)(uint8_t)((a>>8 )&0xff),
+                   (int)(uint8_t)((a>>16)&0xff),
+                   (int)(uint8_t)((a>>24)&0xff));
+    }
     string_addr = inaddr_buf;
     payload_len = strlen(inaddr_buf)+1;
     tor_assert(payload_len <= RELAY_PAYLOAD_SIZE);



More information about the tor-commits mailing list