Переглянути джерело

Improve error msgs in tor-resolve.c; resolve bug 112

svn:r3947
Nick Mathewson 20 роки тому
батько
коміт
bc668233ad
2 змінених файлів з 18 додано та 12 видалено
  1. 8 7
      doc/TODO
  2. 10 5
      src/tools/tor-resolve.c

+ 8 - 7
doc/TODO

@@ -42,21 +42,21 @@ N . Switch to libevent
          bandwidth buckets under heavy load.  (Really, the logic was
          never right in the first place.)  Also, we should audit all users
          of get_pending_bytes().
-       . Find a way to make sure we have libevent 1.0 or later.
+       o Find a way to make sure we have libevent 1.0 or later.
          o Implement patch to libevent
          o Submit patch to niels making this possible.
-         - Implement Tor side once patch is accepted.
-       . Log which poll method we're using.
+         o Implement Tor side once patch is accepted.
+       o Log which poll method we're using.
          o Implement patch to libevent
          o Submit patch to niels making this possible.
-         - Implement Tor side once patch is accepted.
-       . Intercept libevent's "log" messages.
+         o Implement Tor side once patch is accepted.
+       o Intercept libevent's "log" messages.
          o Ask Niels whether a patch would be accepted.
          o Implement patch, if so.
-         - Implement Tor side once patch is accepted.
+         o Implement Tor side once patch is accepted.
        o Check return from event_set, event_add, event_del.
        o Keep pushing to get a windows patch accepted.
-       - After about 26 March, check back with Niels; he should be back
+       o After about 26 March, check back with Niels; he should be back
          by then.
 
  Security:
@@ -181,6 +181,7 @@ R  o client software not upload descriptor until:
        * no need to do this yet. few people define their ORPort.
 
  Arguable
+N - tor-resolve script should use socks5 to get better error messages.
 N - Script to try pulling bytes through slow-seeming servers so they can
     notice that they might be fast.
 N . Reverse DNS

+ 10 - 5
src/tools/tor-resolve.c

@@ -74,15 +74,21 @@ parse_socks4a_resolve_response(const char *response, size_t len,
   tor_assert(response);
   tor_assert(addr_out);
 
-  if (len < RESPONSE_LEN)
+  if (len < RESPONSE_LEN) {
+    log_fn(LOG_WARN,"Truncated socks response.");
     return -1;
-  if (((uint8_t)response[0])!=0) /* version: 0 */
+  }
+  if (((uint8_t)response[0])!=0) { /* version: 0 */
+    log_fn(LOG_WARN,"Nonzero version in socks response: bad format.");
     return -1;
+  }
   status = (uint8_t)response[1];
-  if (get_uint16(response+2)!=0) /* port: 0 */
+  if (get_uint16(response+2)!=0) { /* port: 0 */
+    log_fn(LOG_WARN,"Nonzero port in socks response: bad format.");
     return -1;
+  }
   if (status != 90) {
-    log_fn(LOG_WARN,"Got status response '%d', meaning not success.", status);
+    log_fn(LOG_WARN,"Got status response '%d': socks request failed.", status);
     return -1;
   }
 
@@ -151,7 +157,6 @@ do_resolve(const char *hostname, uint32_t sockshost, uint16_t socksport,
   }
 
   if (parse_socks4a_resolve_response(response_buf, RESPONSE_LEN,result_addr)<0){
-    log_fn(LOG_ERR, "Error parsing SOCKS response");
     return -1;
   }