[or-cvs] Fix some more bugs; add a temporary log.

Nick Mathewson nickm at seul.org
Thu Sep 8 18:46:27 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv11203/src/or

Modified Files:
	directory.c routerlist.c routerparse.c 
Log Message:
Fix some more bugs; add a temporary log.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.259
retrieving revision 1.260
diff -u -d -r1.259 -r1.260
--- directory.c	8 Sep 2005 18:14:01 -0000	1.259
+++ directory.c	8 Sep 2005 18:46:25 -0000	1.260
@@ -175,11 +175,14 @@
 
   if (directconn) {
     if (fetch_fresh_first && purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS &&
-        strlen(resource) == HEX_DIGEST_LEN) {
+        !strcmpstart(resource,"fp/") && strlen(resource) == HEX_DIGEST_LEN+3) {
       /* Try to ask the actual dirserver its opinion. */
       char digest[DIGEST_LEN];
-      base16_decode(digest, DIGEST_LEN, resource, HEX_DIGEST_LEN);
+      base16_decode(digest, DIGEST_LEN, resource+3, HEX_DIGEST_LEN);
       ds = router_get_trusteddirserver_by_digest(digest);
+      // XXXXX NM remove this.
+      log_fn(LOG_NOTICE, "Going straight to the authority for %s? %s",resource,
+             ds? "Ok.":"Oops. I can't.");
     }
     if (!ds && fetch_fresh_first) {
       /* only ask authdirservers, and don't ask myself */
@@ -450,6 +453,7 @@
       httpcommand = "GET";//XXXX
       len = strlen(resource)+32;
       url = tor_malloc(len);
+      log_fn(LOG_NOTICE, "Asking for %s", resource);
       tor_snprintf(url, len, "/tor/status/%s", resource);
       break;
     case DIR_PURPOSE_FETCH_SERVERDESC:
@@ -884,7 +888,7 @@
   if (conn->purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {
     /* XXXX NM We *must* make certain we get the one(s) we asked for or we
      * could be partitioned. */
-    log_fn(LOG_INFO,"Received networkstatus objects (size %d)",(int) body_len);
+    log_fn(LOG_INFO,"Received networkstatus objects (size %d) from server '%s'",(int) body_len, conn->address);
     if (status_code != 200) {
       log_fn(LOG_WARN,"Received http status code %d (\"%s\") from server '%s'. Failing.",
              status_code, reason, conn->address);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.272
retrieving revision 1.273
diff -u -d -r1.272 -r1.273
--- routerlist.c	8 Sep 2005 16:18:28 -0000	1.272
+++ routerlist.c	8 Sep 2005 18:46:25 -0000	1.273
@@ -896,7 +896,8 @@
 {
   tor_free(ns->source_address);
   tor_free(ns->contact);
-  crypto_free_pk_env(ns->signing_key);
+  if (ns->signing_key)
+    crypto_free_pk_env(ns->signing_key);
   tor_free(ns->client_versions);
   tor_free(ns->server_versions);
   if (ns->entries) {
@@ -1207,6 +1208,8 @@
   time_t now;
   char fp[HEX_DIGEST_LEN+1];
 
+  log_fn(LOG_NOTICE, "setting status (%d)", is_cached);
+
   ns = networkstatus_parse_from_string(s);
   if (!ns) {
     log_fn(LOG_WARN, "Couldn't parse network status.");
@@ -1330,12 +1333,13 @@
   /* XXXX NM This could compress multiple downloads into a single request.
    * It could also be smarter on failures. */
   for (i = most_recent_idx+1; needed; ++i) {
-    char resource[HEX_DIGEST_LEN+1];
+    char resource[HEX_DIGEST_LEN+4];
     trusted_dir_server_t *ds;
     if (i >= n_dirservers)
       i = 0;
     ds = smartlist_get(trusted_dir_servers, i);
-    base16_encode(resource, sizeof(resource), ds->digest, DIGEST_LEN);
+    strlcpy(resource, "fp/", sizeof(resource));
+    base16_encode(resource+3, sizeof(resource)-3, ds->digest, DIGEST_LEN);
     directory_get_from_dirserver(DIR_PURPOSE_FETCH_NETWORKSTATUS, resource, 1);
     --needed;
   }

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -d -r1.128 -r1.129
--- routerparse.c	8 Sep 2005 18:24:26 -0000	1.128
+++ routerparse.c	8 Sep 2005 18:46:25 -0000	1.129
@@ -1212,7 +1212,7 @@
     goto err;
   }
 
-  if (tor_inet_aton(tok->args[5], &in) != 0) {
+  if (tor_inet_aton(tok->args[5], &in) == 0) {
     log_fn(LOG_WARN, "Error parsing address '%s'", tok->args[5]);
     goto err;
   }



More information about the tor-commits mailing list