[or-cvs] wrong is ok, and right is fine, but in between is apparently

Roger Dingledine arma at seul.org
Sun Nov 28 11:39:57 UTC 2004


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

Modified Files:
	buffers.c circuitbuild.c circuitlist.c circuituse.c 
	connection.c connection_edge.c connection_or.c cpuworker.c 
	directory.c dirserv.c dns.c main.c relay.c rendclient.c 
	router.c routerlist.c routerparse.c 
Log Message:
wrong is ok, and right is fine, but in between is apparently
totally unacceptable to me.


Index: buffers.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- buffers.c	28 Nov 2004 09:05:46 -0000	1.118
+++ buffers.c	28 Nov 2004 11:39:53 -0000	1.119
@@ -490,7 +490,7 @@
         return 0; /* not yet */
       req->command = (unsigned char) *(buf->mem+1);
       if (req->command != SOCKS_COMMAND_CONNECT &&
-         req->command != SOCKS_COMMAND_RESOLVE) {
+          req->command != SOCKS_COMMAND_RESOLVE) {
         /* not a connect or resolve? we don't support it. */
         log_fn(LOG_WARN,"socks5: command %d not recognized. Rejecting.",
                req->command);
@@ -548,7 +548,7 @@
 
       req->command = (unsigned char) *(buf->mem+1);
       if (req->command != SOCKS_COMMAND_CONNECT &&
-         req->command != SOCKS_COMMAND_RESOLVE) {
+          req->command != SOCKS_COMMAND_RESOLVE) {
         /* not a connect or resolve? we don't support it. */
         log_fn(LOG_WARN,"socks4: command %d not recognized. Rejecting.",
                req->command);

Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- circuitbuild.c	28 Nov 2004 09:05:46 -0000	1.63
+++ circuitbuild.c	28 Nov 2004 11:39:53 -0000	1.64
@@ -281,7 +281,7 @@
   }
 
   if (onion_extend_cpath(&circ->cpath, circ->build_state, &firsthop)<0 ||
-     !CIRCUIT_IS_ORIGIN(circ)) {
+      !CIRCUIT_IS_ORIGIN(circ)) {
     log_fn(LOG_INFO,"Generating first cpath hop failed.");
     circuit_mark_for_close(circ);
     return NULL;
@@ -345,9 +345,9 @@
     if (circ->marked_for_close)
       continue;
     if (!circ->n_conn &&
-       circ->n_addr == or_conn->addr &&
-       circ->n_port == or_conn->port &&
-       !memcmp(or_conn->identity_digest, circ->n_conn_id_digest, DIGEST_LEN)) {
+        circ->n_addr == or_conn->addr &&
+        circ->n_port == or_conn->port &&
+        !memcmp(or_conn->identity_digest, circ->n_conn_id_digest, DIGEST_LEN)) {
       tor_assert(circ->state == CIRCUIT_STATE_OR_WAIT);
       if (!status) { /* or_conn failed; close circ */
         log_fn(LOG_INFO,"or_conn failed. Closing circ.");
@@ -434,8 +434,8 @@
     }
 
     if (onion_skin_create(router->onion_pkey,
-                         &(circ->cpath->handshake_state),
-                         payload) < 0) {
+                          &(circ->cpath->handshake_state),
+                          payload) < 0) {
       log_fn(LOG_WARN,"onion_skin_create (first hop) failed.");
       return -1;
     }
@@ -486,7 +486,7 @@
     /* send it to hop->prev, because it will transfer
      * it to a create cell and then send to hop */
     if (connection_edge_send_command(NULL, circ, RELAY_COMMAND_EXTEND,
-                               payload, payload_len, hop->prev) < 0)
+                                     payload, payload_len, hop->prev) < 0)
       return 0; /* circuit is closed */
 
     hop->state = CPATH_STATE_AWAITING_KEYS;
@@ -607,7 +607,7 @@
     return -1;
   }
   if (!(cpath->b_crypto =
-     crypto_create_init_cipher(key_data+(2*DIGEST_LEN)+CIPHER_KEY_LEN,0))) {
+        crypto_create_init_cipher(key_data+(2*DIGEST_LEN)+CIPHER_KEY_LEN,0))) {
     log(LOG_WARN,"backward cipher initialization failed.");
     return -1;
   }
@@ -651,7 +651,7 @@
   tor_assert(hop->state == CPATH_STATE_AWAITING_KEYS);
 
   if (onion_skin_client_handshake(hop->handshake_state, reply, keys,
-                                 DIGEST_LEN*2+CIPHER_KEY_LEN*2) < 0) {
+                                  DIGEST_LEN*2+CIPHER_KEY_LEN*2) < 0) {
     log_fn(LOG_WARN,"onion_skin_client_handshake failed.");
     return -1;
   }
@@ -879,7 +879,7 @@
       continue; /* skip routers that are known to be down */
     }
     if (!router->is_verified &&
-       (!(options->_AllowUnverified & ALLOW_UNVERIFIED_EXIT) ||
+        (!(options->_AllowUnverified & ALLOW_UNVERIFIED_EXIT) ||
          router_is_unreliable_router(router, 1, 1))) {
       /* if it's unverified, and either we don't want it or it's unsuitable */
       n_supported[i] = -1;
@@ -894,7 +894,7 @@
       continue; /* skip routers that reject all */
     }
     if (smartlist_len(preferredentries)==1 &&
-       router == (routerinfo_t*)smartlist_get(preferredentries, 0)) {
+        router == (routerinfo_t*)smartlist_get(preferredentries, 0)) {
       n_supported[i] = -1;
       log_fn(LOG_DEBUG,"Skipping node %s (index %d) -- it's our only preferred entry node.", router->nickname, i);
       continue;

Index: circuitlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitlist.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- circuitlist.c	28 Nov 2004 09:05:46 -0000	1.20
+++ circuitlist.c	28 Nov 2004 11:39:53 -0000	1.21
@@ -317,10 +317,12 @@
   circuit_t *youngest=NULL;
 
   for (circ=global_circuitlist;circ;circ = circ->next) {
-    if (CIRCUIT_IS_ORIGIN(circ) && circ->state == CIRCUIT_STATE_OPEN &&
-       !circ->marked_for_close && circ->purpose == purpose &&
-       !circ->timestamp_dirty &&
-       (!youngest || youngest->timestamp_created < circ->timestamp_created))
+    if (CIRCUIT_IS_ORIGIN(circ) &&
+        circ->state == CIRCUIT_STATE_OPEN &&
+        !circ->marked_for_close &&
+        circ->purpose == purpose &&
+        !circ->timestamp_dirty &&
+        (!youngest || youngest->timestamp_created < circ->timestamp_created))
       youngest = circ;
   }
   return youngest;

Index: circuituse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuituse.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- circuituse.c	28 Nov 2004 09:05:46 -0000	1.26
+++ circuituse.c	28 Nov 2004 11:39:53 -0000	1.27
@@ -89,7 +89,7 @@
       }
     } else { /* not general */
       if (rend_cmp_service_ids(conn->rend_query, circ->rend_query) &&
-         (circ->rend_query[0] || purpose != CIRCUIT_PURPOSE_C_REND_JOINED)) {
+          (circ->rend_query[0] || purpose != CIRCUIT_PURPOSE_C_REND_JOINED)) {
         /* this circ is not for this conn, and it's not suitable
          * for cannibalizing either */
         return 0;
@@ -111,11 +111,11 @@
        */
       if (b->timestamp_dirty) {
         if (a->timestamp_dirty &&
-           a->timestamp_dirty > b->timestamp_dirty)
+            a->timestamp_dirty > b->timestamp_dirty)
           return 1;
       } else {
         if (a->timestamp_dirty ||
-           a->timestamp_created > b->timestamp_created)
+            a->timestamp_created > b->timestamp_created)
           return 1;
       }
       break;
@@ -199,7 +199,7 @@
 
     /* some debug logs, to help track bugs */
     if (victim->purpose >= CIRCUIT_PURPOSE_C_INTRODUCING &&
-       victim->purpose <= CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) {
+        victim->purpose <= CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED) {
       if (!victim->timestamp_dirty)
         log_fn(LOG_DEBUG,"Considering %sopen purp %d to %s (circid %d). (clean).",
                victim->state == CIRCUIT_STATE_OPEN ? "" : "non",
@@ -216,25 +216,25 @@
     /* if circ is !open, or if it's open but purpose is a non-finished
      * intro or rend, then mark it for close */
     if (victim->state != CIRCUIT_STATE_OPEN ||
-       victim->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND ||
-       victim->purpose == CIRCUIT_PURPOSE_C_INTRODUCING ||
-       victim->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
+        victim->purpose == CIRCUIT_PURPOSE_C_ESTABLISH_REND ||
+        victim->purpose == CIRCUIT_PURPOSE_C_INTRODUCING ||
+        victim->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
 
-       /* it's a rend_ready circ, but it's already picked a query */
-       (victim->purpose == CIRCUIT_PURPOSE_C_REND_READY &&
-        victim->rend_query[0]) ||
+        /* it's a rend_ready circ, but it's already picked a query */
+        (victim->purpose == CIRCUIT_PURPOSE_C_REND_READY &&
+         victim->rend_query[0]) ||
 
-       /* c_rend_ready circs measure age since timestamp_dirty,
-        * because that's set when they switch purposes
-        */
-       /* rend and intro circs become dirty each time they
-        * make an introduction attempt. so timestamp_dirty
-        * will reflect the time since the last attempt.
-        */
-       ((victim->purpose == CIRCUIT_PURPOSE_C_REND_READY ||
-         victim->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED ||
-         victim->purpose == CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) &&
-        victim->timestamp_dirty + MIN_SECONDS_BEFORE_EXPIRING_CIRC > now)) {
+        /* c_rend_ready circs measure age since timestamp_dirty,
+         * because that's set when they switch purposes
+         */
+        /* rend and intro circs become dirty each time they
+         * make an introduction attempt. so timestamp_dirty
+         * will reflect the time since the last attempt.
+         */
+        ((victim->purpose == CIRCUIT_PURPOSE_C_REND_READY ||
+          victim->purpose == CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED ||
+          victim->purpose == CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) &&
+         victim->timestamp_dirty + MIN_SECONDS_BEFORE_EXPIRING_CIRC > now)) {
       if (victim->n_conn)
         log_fn(LOG_INFO,"Abandoning circ %s:%d:%d (state %d:%s, purpose %d)",
                victim->n_conn->address, victim->n_port, victim->n_circ_id,
@@ -264,10 +264,12 @@
   time_t now = time(NULL);
 
   for (circ=global_circuitlist;circ;circ = circ->next) {
-    if (CIRCUIT_IS_ORIGIN(circ) && circ->state != CIRCUIT_STATE_OPEN &&
-       !circ->marked_for_close && circ->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
-       (!circ->timestamp_dirty ||
-        circ->timestamp_dirty + get_options()->NewCircuitPeriod < now)) {
+    if (CIRCUIT_IS_ORIGIN(circ) &&
+        circ->state != CIRCUIT_STATE_OPEN &&
+        !circ->marked_for_close &&
+        circ->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
+        (!circ->timestamp_dirty ||
+         circ->timestamp_dirty + get_options()->NewCircuitPeriod < now)) {
       exitrouter = router_get_by_digest(circ->build_state->chosen_exit_digest);
       if (exitrouter && connection_ap_can_use_exit(conn, exitrouter))
         if (++num >= MIN_CIRCUITS_HANDLING_STREAM)
@@ -305,8 +307,9 @@
       client_dns_clean();
     circuit_expire_old_circuits();
 
-    if (get_options()->RunTesting && circ &&
-               circ->timestamp_created + TESTING_CIRCUIT_INTERVAL < now) {
+    if (get_options()->RunTesting &&
+        circ &&
+        circ->timestamp_created + TESTING_CIRCUIT_INTERVAL < now) {
       log_fn(LOG_INFO,"Creating a new testing circuit.");
       circuit_launch_by_identity(CIRCUIT_PURPOSE_C_GENERAL, NULL);
     }
@@ -320,7 +323,7 @@
   /* if there's no open circ, and less than 5 are on the way,
    * go ahead and try another. */
   if (!circ && circuit_count_building(CIRCUIT_PURPOSE_C_GENERAL)
-              < CIRCUIT_MIN_BUILDING_GENERAL) {
+               < CIRCUIT_MIN_BUILDING_GENERAL) {
     circuit_launch_by_identity(CIRCUIT_PURPOSE_C_GENERAL, NULL);
   }
 
@@ -720,7 +723,7 @@
     tor_free(exitname);
 
     if (circ &&
-       (desired_circuit_purpose != CIRCUIT_PURPOSE_C_GENERAL)) {
+        desired_circuit_purpose != CIRCUIT_PURPOSE_C_GENERAL) {
       /* then write the service_id into circ */
       strlcpy(circ->rend_query, conn->rend_query, sizeof(circ->rend_query));
     }

Index: connection.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.301
retrieving revision 1.302
diff -u -d -r1.301 -r1.302
--- connection.c	28 Nov 2004 09:05:46 -0000	1.301
+++ connection.c	28 Nov 2004 11:39:53 -0000	1.302
@@ -713,11 +713,11 @@
     return;
   }
   if (connection_speaks_cells(conn) &&
-     conn->state == OR_CONN_STATE_OPEN &&
-     conn->receiver_bucket == 0) {
-      log_fn(LOG_DEBUG,"receiver bucket exhausted. Pausing.");
-      conn->wants_to_read = 1;
-      connection_stop_reading(conn);
+      conn->state == OR_CONN_STATE_OPEN &&
+      conn->receiver_bucket == 0) {
+    log_fn(LOG_DEBUG,"receiver bucket exhausted. Pausing.");
+    conn->wants_to_read = 1;
+    connection_stop_reading(conn);
   }
 }
 
@@ -757,12 +757,12 @@
     }
 
     if (conn->wants_to_read == 1 /* it's marked to turn reading back on now */
-       && global_read_bucket > 0 /* and we're allowed to read */
-       && global_write_bucket > 0 /* and we're allowed to write (XXXX,
-                                   * not the best place to check this.) */
-       && (!connection_speaks_cells(conn) ||
-           conn->state != OR_CONN_STATE_OPEN ||
-           conn->receiver_bucket > 0)) {
+        && global_read_bucket > 0 /* and we're allowed to read */
+        && global_write_bucket > 0 /* and we're allowed to write (XXXX,
+                                    * not the best place to check this.) */
+        && (!connection_speaks_cells(conn) ||
+            conn->state != OR_CONN_STATE_OPEN ||
+            conn->receiver_bucket > 0)) {
       /* and either a non-cell conn or a cell conn with non-empty bucket */
       log_fn(LOG_DEBUG,"waking up conn (fd %d)",conn->s);
       conn->wants_to_read = 0;
@@ -839,7 +839,7 @@
        /* XXX I suspect pollerr may make Windows not get to this point. :( */
        router_mark_as_down(conn->identity_digest);
        if (conn->purpose == DIR_PURPOSE_FETCH_DIR &&
-          !all_trusted_directory_servers_down()) {
+           !all_trusted_directory_servers_down()) {
          log_fn(LOG_INFO,"Giving up on dirserver %s; trying another.", conn->address);
          directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL);
        }
@@ -1117,7 +1117,7 @@
   for (i=0;i<n;i++) {
     conn = carray[i];
     if (conn->addr == addr && conn->port == port && !conn->marked_for_close &&
-       (!best || best->timestamp_created < conn->timestamp_created))
+        (!best || best->timestamp_created < conn->timestamp_created))
       best = conn;
   }
   return best;
@@ -1134,9 +1134,9 @@
     conn = carray[i];
     if (conn->type != type)
       continue;
-    if (!memcmp(conn->identity_digest, digest, DIGEST_LEN)
-        && !conn->marked_for_close
-        && (!best || best->timestamp_created < conn->timestamp_created))
+    if (!memcmp(conn->identity_digest, digest, DIGEST_LEN) &&
+        !conn->marked_for_close &&
+        (!best || best->timestamp_created < conn->timestamp_created))
       best = conn;
   }
   return best;
@@ -1207,8 +1207,8 @@
   for (i=0;i<n;i++) {
     conn = carray[i];
     if (conn->type == type &&
-       !conn->marked_for_close &&
-       !rend_cmp_service_ids(rendquery, conn->rend_query))
+        !conn->marked_for_close &&
+        !rend_cmp_service_ids(rendquery, conn->rend_query))
       return conn;
   }
   return NULL;
@@ -1217,9 +1217,9 @@
 /** Return 1 if <b>conn</b> is a listener conn, else return 0. */
 int connection_is_listener(connection_t *conn) {
   if (conn->type == CONN_TYPE_OR_LISTENER ||
-     conn->type == CONN_TYPE_AP_LISTENER ||
-     conn->type == CONN_TYPE_DIR_LISTENER ||
-     conn->type == CONN_TYPE_CONTROL_LISTENER)
+      conn->type == CONN_TYPE_AP_LISTENER ||
+      conn->type == CONN_TYPE_DIR_LISTENER ||
+      conn->type == CONN_TYPE_CONTROL_LISTENER)
     return 1;
   return 0;
 }
@@ -1234,9 +1234,9 @@
     return 0;
 
   if ((conn->type == CONN_TYPE_OR && conn->state == OR_CONN_STATE_OPEN) ||
-     (conn->type == CONN_TYPE_AP && conn->state == AP_CONN_STATE_OPEN) ||
-     (conn->type == CONN_TYPE_EXIT && conn->state == EXIT_CONN_STATE_OPEN) ||
-     (conn->type == CONN_TYPE_CONTROL && conn->state ==CONTROL_CONN_STATE_OPEN))
+      (conn->type == CONN_TYPE_AP && conn->state == AP_CONN_STATE_OPEN) ||
+      (conn->type == CONN_TYPE_EXIT && conn->state == EXIT_CONN_STATE_OPEN) ||
+      (conn->type == CONN_TYPE_CONTROL && conn->state ==CONTROL_CONN_STATE_OPEN))
     return 1;
 
   return 0;

Index: connection_edge.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_edge.c,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -d -r1.243 -r1.244
--- connection_edge.c	28 Nov 2004 09:05:46 -0000	1.243
+++ connection_edge.c	28 Nov 2004 11:39:53 -0000	1.244
@@ -213,12 +213,12 @@
   /* deliver a 'connected' relay cell back through the circuit. */
   if (connection_edge_is_rendezvous_stream(conn)) {
     if (connection_edge_send_command(conn, circuit_get_by_conn(conn),
-                                    RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
+                                     RELAY_COMMAND_CONNECTED, NULL, 0, conn->cpath_layer) < 0)
       return 0; /* circuit is closed, don't continue */
   } else {
     *(uint32_t*)connected_payload = htonl(conn->addr);
     if (connection_edge_send_command(conn, circuit_get_by_conn(conn),
-         RELAY_COMMAND_CONNECTED, connected_payload, 4, conn->cpath_layer) < 0)
+        RELAY_COMMAND_CONNECTED, connected_payload, 4, conn->cpath_layer) < 0)
       return 0; /* circuit is closed, don't continue */
   }
   tor_assert(conn->package_window > 0);
@@ -515,7 +515,7 @@
   log_fn(LOG_DEBUG,"Sending relay cell to begin stream %d.",ap_conn->stream_id);
 
   if (connection_edge_send_command(ap_conn, circ, RELAY_COMMAND_BEGIN,
-                               payload, payload_len, ap_conn->cpath_layer) < 0)
+                                   payload, payload_len, ap_conn->cpath_layer) < 0)
     return -1; /* circuit is closed, don't continue */
 
   ap_conn->package_window = STREAMWINDOW_START;
@@ -1000,8 +1000,8 @@
     return tor_version_as_new_as(exit->platform, "0.0.9pre1");
   }
   addr = client_dns_lookup_entry(conn->socks_request->address);
-  if (router_compare_addr_to_addr_policy(addr,
-     conn->socks_request->port, exit->exit_policy) < 0)
+  if (router_compare_addr_to_addr_policy(addr, conn->socks_request->port,
+                                         exit->exit_policy) < 0)
     return 0;
   return 1;
 }

Index: connection_or.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/connection_or.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- connection_or.c	28 Nov 2004 09:05:46 -0000	1.147
+++ connection_or.c	28 Nov 2004 11:39:53 -0000	1.148
@@ -208,7 +208,7 @@
   tor_assert(id_digest);
 
   if (server_mode(get_options()) && (me=router_get_my_routerinfo()) &&
-     !memcmp(me->identity_digest, id_digest,DIGEST_LEN)) {
+      !memcmp(me->identity_digest, id_digest,DIGEST_LEN)) {
     log_fn(LOG_WARN,"Request to connect to myself! Failing.");
     return NULL;
   }
@@ -385,8 +385,8 @@
 
   router = router_get_by_nickname(nickname);
   if (router && /* we know this nickname */
-     router->is_verified && /* make sure it's the right guy */
-     memcmp(digest_rcvd, router->identity_digest, DIGEST_LEN) != 0) {
+      router->is_verified && /* make sure it's the right guy */
+      memcmp(digest_rcvd, router->identity_digest, DIGEST_LEN) != 0) {
     log_fn(LOG_WARN, "Identity key not as expected for router claiming to be '%s' (%s:%d) ", nickname, conn->address, conn->port);
     return -1;
   }
@@ -455,7 +455,7 @@
  * during periods of high load we won't read the entire megabyte from
  * input before pushing any data out. */
   if (conn->outbuf_flushlen-CELL_NETWORK_SIZE < MIN_TLS_FLUSHLEN &&
-     conn->outbuf_flushlen >= MIN_TLS_FLUSHLEN) {
+      conn->outbuf_flushlen >= MIN_TLS_FLUSHLEN) {
     int extra = conn->outbuf_flushlen - MIN_TLS_FLUSHLEN;
     conn->outbuf_flushlen = MIN_TLS_FLUSHLEN;
     if (connection_handle_write(conn) < 0) {

Index: cpuworker.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/cpuworker.c,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- cpuworker.c	28 Nov 2004 09:05:46 -0000	1.58
+++ cpuworker.c	28 Nov 2004 11:39:53 -0000	1.59
@@ -235,7 +235,7 @@
 
     if (question_type == CPUWORKER_TASK_ONION) {
       if (onion_skin_server_handshake(question, onion_key, last_onion_key,
-        reply_to_proxy, keys, 40+32) < 0) {
+          reply_to_proxy, keys, 40+32) < 0) {
         /* failure */
         log_fn(LOG_WARN,"onion_skin_server_handshake failed.");
         memset(buf,0,LEN_ONION_RESPONSE); /* send all zeros for failure */

Index: directory.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.173
retrieving revision 1.174
diff -u -d -r1.173 -r1.174
--- directory.c	28 Nov 2004 09:05:46 -0000	1.173
+++ directory.c	28 Nov 2004 11:39:53 -0000	1.174
@@ -277,14 +277,14 @@
   conn->state = DIR_CONN_STATE_CONNECTING;
 
   if (purpose == DIR_PURPOSE_FETCH_DIR ||
-     purpose == DIR_PURPOSE_UPLOAD_DIR ||
-     purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
+      purpose == DIR_PURPOSE_UPLOAD_DIR ||
+      purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
     /* then we want to connect directly */
     switch (connection_connect(conn, conn->address, addr, dir_port)) {
       case -1:
         router_mark_as_down(conn->identity_digest); /* don't try him again */
         if (purpose == DIR_PURPOSE_FETCH_DIR &&
-           !all_trusted_directory_servers_down()) {
+            !all_trusted_directory_servers_down()) {
           log_fn(LOG_INFO,"Giving up on dirserver '%s'; trying another.", conn->address);
           directory_get_from_dirserver(purpose, NULL);
         }
@@ -475,8 +475,8 @@
   while (isspace((int)*headers)) headers++; /* tolerate leading whitespace */
 
   if (sscanf(headers, "HTTP/1.%d %d", &n1, &n2) < 2 ||
-     (n1 != 0 && n1 != 1) ||
-     (n2 < 100 || n2 >= 600)) {
+      (n1 != 0 && n1 != 1) ||
+      (n2 < 100 || n2 >= 600)) {
     log_fn(LOG_WARN,"Failed to parse header '%s'",headers);
     return -1;
   }
@@ -538,8 +538,8 @@
   int compression;
 
   switch (fetch_from_buf_http(conn->inbuf,
-                             &headers, MAX_HEADERS_SIZE,
-                             &body, &body_len, MAX_DIR_SIZE)) {
+                              &headers, MAX_HEADERS_SIZE,
+                              &body, &body_len, MAX_DIR_SIZE)) {
     case -1: /* overflow */
       log_fn(LOG_WARN,"'fetch' response too large. Failing.");
       return -1;
@@ -550,7 +550,7 @@
   }
 
   if (parse_http_response(headers, &status_code, &date_header,
-                         &compression) < 0) {
+                          &compression) < 0) {
     log_fn(LOG_WARN,"Unparseable headers. Closing.");
     tor_free(body); tor_free(headers);
     return -1;
@@ -782,7 +782,7 @@
   }
 
   if (!strcmp(url,"/tor/running-routers") ||
-     !strcmp(url,"/tor/running-routers.z")) { /* running-routers fetch */
+      !strcmp(url,"/tor/running-routers.z")) { /* running-routers fetch */
     int deflated = !strcmp(url,"/tor/dir.z");
     tor_free(url);
     if (!authdir_mode(get_options())) {
@@ -926,8 +926,8 @@
   tor_assert(conn->type == CONN_TYPE_DIR);
 
   switch (fetch_from_buf_http(conn->inbuf,
-                             &headers, MAX_HEADERS_SIZE,
-                             &body, &body_len, MAX_BODY_SIZE)) {
+                              &headers, MAX_HEADERS_SIZE,
+                              &body, &body_len, MAX_BODY_SIZE)) {
     case -1: /* overflow */
       log_fn(LOG_WARN,"Invalid input. Closing.");
       return -1;

Index: dirserv.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- dirserv.c	28 Nov 2004 09:05:46 -0000	1.125
+++ dirserv.c	28 Nov 2004 11:39:53 -0000	1.126
@@ -114,7 +114,7 @@
       continue;
     }
     if (strlen(fingerprint) != FINGERPRINT_LEN ||
-       !crypto_pk_check_fingerprint_syntax(fingerprint)) {
+        !crypto_pk_check_fingerprint_syntax(fingerprint)) {
       log_fn(LOG_WARN, "Invalid fingerprint (nickname '%s', fingerprint %s). Skipping.",
              nickname, fingerprint);
       continue;

Index: dns.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/dns.c,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- dns.c	28 Nov 2004 09:05:46 -0000	1.122
+++ dns.c	28 Nov 2004 11:39:53 -0000	1.123
@@ -353,8 +353,8 @@
 
   SPLAY_FOREACH(resolve, cache_tree, &cache_root) {
     for (pend = resolve->pending_connections;
-        pend;
-        pend = pend->next) {
+         pend;
+         pend = pend->next) {
       tor_assert(pend->conn != conn);
     }
   }
@@ -368,8 +368,8 @@
 
   SPLAY_FOREACH(resolve, cache_tree, &cache_root) {
     for (pend = resolve->pending_connections;
-        pend;
-        pend = pend->next) {
+         pend;
+         pend = pend->next) {
       assert_connection_ok(pend->conn, 0);
       tor_assert(pend->conn->s == -1);
       tor_assert(!connection_in_array(pend->conn));

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.395
retrieving revision 1.396
diff -u -d -r1.395 -r1.396
--- main.c	28 Nov 2004 09:05:46 -0000	1.395
+++ main.c	28 Nov 2004 11:39:53 -0000	1.396
@@ -252,7 +252,7 @@
      * should be a &&.
      */
     if (!connection_is_reading(conn) ||
-       !connection_has_pending_tls_data(conn))
+        !connection_has_pending_tls_data(conn))
       return; /* this conn should not read */
 
   log_fn(LOG_DEBUG,"socket %d wants to read.",conn->s);
@@ -263,15 +263,15 @@
   if (
     /* XXX does POLLHUP also mean it's definitely broken? */
 #ifdef MS_WINDOWS
-    (poll_array[i].revents & POLLERR) ||
+      (poll_array[i].revents & POLLERR) ||
 #endif
-    connection_handle_read(conn) < 0) {
-      if (!conn->marked_for_close) {
-        /* this connection is broken. remove it */
-        log_fn(LOG_WARN,"Unhandled error on read for %s connection (fd %d); removing",
-               CONN_TYPE_TO_STRING(conn->type), conn->s);
-        connection_mark_for_close(conn);
-      }
+      connection_handle_read(conn) < 0) {
+    if (!conn->marked_for_close) {
+      /* this connection is broken. remove it */
+      log_fn(LOG_WARN,"Unhandled error on read for %s connection (fd %d); removing",
+             CONN_TYPE_TO_STRING(conn->type), conn->s);
+      connection_mark_for_close(conn);
+    }
   }
   assert_connection_ok(conn, time(NULL));
   assert_all_pending_dns_resolves_ok();
@@ -411,8 +411,8 @@
 
   /* Expire any directory connections that haven't sent anything for 5 min */
   if (conn->type == CONN_TYPE_DIR &&
-     !conn->marked_for_close &&
-     conn->timestamp_lastwritten + 5*60 < now) {
+      !conn->marked_for_close &&
+      conn->timestamp_lastwritten + 5*60 < now) {
     log_fn(LOG_INFO,"Expiring wedged directory conn (fd %d, purpose %d)", conn->s, conn->purpose);
     connection_mark_for_close(conn);
     return;
@@ -421,12 +421,12 @@
   /* If we haven't written to an OR connection for a while, then either nuke
      the connection or send a keepalive, depending. */
   if (connection_speaks_cells(conn) &&
-     now >= conn->timestamp_lastwritten + options->KeepalivePeriod) {
+      now >= conn->timestamp_lastwritten + options->KeepalivePeriod) {
     routerinfo_t *router = router_get_by_digest(conn->identity_digest);
     if ((!connection_state_is_open(conn)) ||
-       (we_are_hibernating() && !circuit_get_by_conn(conn)) ||
-       (!clique_mode(options) && !circuit_get_by_conn(conn) &&
-       (!router || !server_mode(options) || !router_is_clique_mode(router)))) {
+        (we_are_hibernating() && !circuit_get_by_conn(conn)) ||
+        (!clique_mode(options) && !circuit_get_by_conn(conn) &&
+        (!router || !server_mode(options) || !router_is_clique_mode(router)))) {
       /* our handshake has expired; we're hibernating;
        * or we have no circuits and we're both either OPs or normal ORs,
        * then kill it. */
@@ -727,7 +727,7 @@
   for (i=0;i<nfds;i++) {
     conn = connection_array[i];
     if (connection_has_pending_tls_data(conn) &&
-       connection_is_reading(conn)) {
+        connection_is_reading(conn)) {
       log_fn(LOG_DEBUG,"sock %d has pending bytes.",conn->s);
       return 0; /* has pending bytes to read; don't let poll wait. */
     }
@@ -1174,24 +1174,23 @@
   service_status.dwServiceType = SERVICE_WIN32_OWN_PROCESS;
   service_status.dwCurrentState = SERVICE_START_PENDING;
   service_status.dwControlsAccepted =
-        SERVICE_ACCEPT_STOP |
-                SERVICE_ACCEPT_SHUTDOWN;
+        SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
   service_status.dwWin32ExitCode = 0;
   service_status.dwServiceSpecificExitCode = 0;
   service_status.dwCheckPoint = 0;
   service_status.dwWaitHint = 1000;
   hStatus = RegisterServiceCtrlHandler(GENSRV_SERVICENAME, (LPHANDLER_FUNCTION) nt_service_control);
   if (hStatus == 0) {
-        // failed;
-        return;
+    // failed;
+    return;
   }
   err = tor_init(backup_argc, backup_argv); // refactor this part out of tor_main and do_main_loop
   if (err) {
-        // failed.
-        service_status.dwCurrentState = SERVICE_STOPPED;
-        service_status.dwWin32ExitCode = -1;
+    // failed.
+    service_status.dwCurrentState = SERVICE_STOPPED;
+    service_status.dwWin32ExitCode = -1;
     SetServiceStatus(hStatus, &service_status);
-        return;
+    return;
   }
   service_status.dwCurrentState = SERVICE_RUNNING;
   SetServiceStatus(hStatus, &service_status);
@@ -1280,13 +1279,13 @@
   }
 
   if ((hService = CreateService(hSCManager, GENSRV_SERVICENAME, GENSRV_DISPLAYNAME,
-    SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS, SERVICE_DEMAND_START,
-    SERVICE_ERROR_IGNORE, command, NULL, NULL,
-    NULL, NULL, NULL)) == NULL) {
-      printf("Failed: CreateService()\n");
-      CloseServiceHandle(hSCManager);
-      free(command);
-      return 0;
+                                SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS,
+                                SERVICE_DEMAND_START, SERVICE_ERROR_IGNORE, command,
+                                NULL, NULL, NULL, NULL, NULL)) == NULL) {
+    printf("Failed: CreateService()\n");
+    CloseServiceHandle(hSCManager);
+    free(command);
+    return 0;
   }
 
   CloseServiceHandle(hService);

Index: relay.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/relay.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- relay.c	28 Nov 2004 09:05:46 -0000	1.27
+++ relay.c	28 Nov 2004 11:39:53 -0000	1.28
@@ -111,7 +111,7 @@
   relay_header_unpack(&rh, in);
 //  log_fn(LOG_DEBUG,"before crypt: %d",rh.recognized);
   if (( encrypt_mode && crypto_cipher_encrypt(cipher, out, in, CELL_PAYLOAD_SIZE)) ||
-     (!encrypt_mode && crypto_cipher_decrypt(cipher, out, in, CELL_PAYLOAD_SIZE))) {
+      (!encrypt_mode && crypto_cipher_decrypt(cipher, out, in, CELL_PAYLOAD_SIZE))) {
     log_fn(LOG_WARN,"Error during relay encryption");
     return -1;
   }
@@ -351,7 +351,7 @@
     if (rh.stream_id == tmpconn->stream_id) {
       log_fn(LOG_DEBUG,"found conn for stream %d.", rh.stream_id);
       if (cell_direction == CELL_DIRECTION_OUT ||
-         connection_edge_is_rendezvous_stream(tmpconn))
+          connection_edge_is_rendezvous_stream(tmpconn))
         return tmpconn;
     }
   }
@@ -655,8 +655,8 @@
    * conn points to the recognized stream. */
 
   if (conn &&
-     conn->state != AP_CONN_STATE_OPEN &&
-     conn->state != EXIT_CONN_STATE_OPEN) {
+      conn->state != AP_CONN_STATE_OPEN &&
+      conn->state != EXIT_CONN_STATE_OPEN) {
     return connection_edge_process_relay_cell_not_open(
              &rh, cell, circ, conn, layer_hint);
   }
@@ -679,8 +679,8 @@
       return 0;
     case RELAY_COMMAND_DATA:
       ++stats_n_data_cells_received;
-      if ((layer_hint && --layer_hint->deliver_window < 0) ||
-         (!layer_hint && --circ->deliver_window < 0)) {
+      if (( layer_hint && --layer_hint->deliver_window < 0) ||
+          (!layer_hint && --circ->deliver_window < 0)) {
         log_fn(LOG_WARN,"(relay data) circ deliver_window below 0. Killing.");
         connection_edge_end(conn, END_STREAM_REASON_MISC, conn->cpath_layer);
         connection_mark_for_close(conn);
@@ -910,7 +910,7 @@
   }
 
   if (connection_edge_send_command(conn, circ, RELAY_COMMAND_DATA,
-                               payload, length, conn->cpath_layer) < 0)
+                                   payload, length, conn->cpath_layer) < 0)
     return 0; /* circuit is closed, don't continue */
 
   if (!conn->cpath_layer) { /* non-rendezvous exit */
@@ -957,7 +957,7 @@
     log_fn(LOG_DEBUG,"Outbuf %d, Queueing stream sendme.", (int)conn->outbuf_flushlen);
     conn->deliver_window += STREAMWINDOW_INCREMENT;
     if (connection_edge_send_command(conn, circ, RELAY_COMMAND_SENDME,
-                                    NULL, 0, conn->cpath_layer) < 0) {
+                                     NULL, 0, conn->cpath_layer) < 0) {
       log_fn(LOG_WARN,"connection_edge_send_command failed. Returning.");
       return; /* the circuit's closed, don't continue */
     }
@@ -991,7 +991,7 @@
 
   for ( ; conn; conn=conn->next_stream) {
     if ((!layer_hint && conn->package_window > 0) ||
-       (layer_hint && conn->package_window > 0 && conn->cpath_layer == layer_hint)) {
+        (layer_hint && conn->package_window > 0 && conn->cpath_layer == layer_hint)) {
       connection_start_reading(conn);
       /* handle whatever might still be on the inbuf */
       connection_edge_package_raw_inbuf(conn, 1);
@@ -1054,14 +1054,14 @@
 //  log_fn(LOG_INFO,"Considering: layer_hint is %s",
 //         layer_hint ? "defined" : "null");
   while ((layer_hint ? layer_hint->deliver_window : circ->deliver_window) <
-         CIRCWINDOW_START - CIRCWINDOW_INCREMENT) {
+          CIRCWINDOW_START - CIRCWINDOW_INCREMENT) {
     log_fn(LOG_DEBUG,"Queueing circuit sendme.");
     if (layer_hint)
       layer_hint->deliver_window += CIRCWINDOW_INCREMENT;
     else
       circ->deliver_window += CIRCWINDOW_INCREMENT;
     if (connection_edge_send_command(NULL, circ, RELAY_COMMAND_SENDME,
-                                    NULL, 0, layer_hint) < 0) {
+                                     NULL, 0, layer_hint) < 0) {
       log_fn(LOG_WARN,"connection_edge_send_command failed. Circuit's closed.");
       return; /* the circuit's closed, don't continue */
     }

Index: rendclient.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/rendclient.c,v
retrieving revision 1.66
retrieving revision 1.67
diff -u -d -r1.66 -r1.67
--- rendclient.c	28 Nov 2004 09:05:46 -0000	1.66
+++ rendclient.c	28 Nov 2004 11:39:53 -0000	1.67
@@ -205,7 +205,7 @@
      * If none remain, refetch the service descriptor.
      */
     if (rend_client_remove_intro_point(circ->build_state->chosen_exit_name,
-                                      circ->rend_query) > 0) {
+                                       circ->rend_query) > 0) {
       /* There are introduction points left. re-extend the circuit to
        * another intro point and try again. */
       routerinfo_t *r;
@@ -315,7 +315,7 @@
   crypt_path_t *hop;
   char keys[DIGEST_LEN+CPATH_KEY_MATERIAL_LEN];
 
-  if ( (circ->purpose != CIRCUIT_PURPOSE_C_REND_READY &&
+  if ((circ->purpose != CIRCUIT_PURPOSE_C_REND_READY &&
        circ->purpose != CIRCUIT_PURPOSE_C_REND_READY_INTRO_ACKED)
       || !circ->build_state->pending_final_cpath) {
     log_fn(LOG_WARN,"Got rendezvous2 cell from Bob, but not expecting it. Closing.");

Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.129
retrieving revision 1.130
diff -u -d -r1.129 -r1.130
--- router.c	28 Nov 2004 09:05:46 -0000	1.129
+++ router.c	28 Nov 2004 11:39:53 -0000	1.130
@@ -191,34 +191,34 @@
   }
 
   switch (file_status(fname)) {
-  case FN_DIR:
-  case FN_ERROR:
-    log(LOG_ERR, "Can't read key from %s", fname);
-    goto error;
-  case FN_NOENT:
-    log(LOG_INFO, "No key found in %s; generating fresh key.", fname);
-    if (crypto_pk_generate_key(prkey)) {
-      log(LOG_ERR, "Error generating onion key");
-      goto error;
-    }
-    if (crypto_pk_check_key(prkey) <= 0) {
-      log(LOG_ERR, "Generated key seems invalid");
-      goto error;
-    }
-    log(LOG_INFO, "Generated key seems valid");
-    if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
-      log(LOG_ERR, "Couldn't write generated key to %s.", fname);
-      goto error;
-    }
-    return prkey;
-  case FN_FILE:
-    if (crypto_pk_read_private_key_from_filename(prkey, fname)) {
-      log(LOG_ERR, "Error loading private key.");
+    case FN_DIR:
+    case FN_ERROR:
+      log(LOG_ERR, "Can't read key from %s", fname);
       goto error;
-    }
-    return prkey;
-  default:
-    tor_assert(0);
+    case FN_NOENT:
+      log(LOG_INFO, "No key found in %s; generating fresh key.", fname);
+      if (crypto_pk_generate_key(prkey)) {
+        log(LOG_ERR, "Error generating onion key");
+        goto error;
+      }
+      if (crypto_pk_check_key(prkey) <= 0) {
+        log(LOG_ERR, "Generated key seems invalid");
+        goto error;
+      }
+      log(LOG_INFO, "Generated key seems valid");
+      if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
+        log(LOG_ERR, "Couldn't write generated key to %s.", fname);
+        goto error;
+      }
+      return prkey;
+    case FN_FILE:
+      if (crypto_pk_read_private_key_from_filename(prkey, fname)) {
+        log(LOG_ERR, "Error loading private key.");
+        goto error;
+      }
+      return prkey;
+    default:
+      tor_assert(0);
   }
 
  error:
@@ -402,7 +402,7 @@
     if (!clique_mode(options) && !router_is_clique_mode(router))
       continue;
     if (!connection_get_by_identity_digest(router->identity_digest,
-                                          CONN_TYPE_OR)) {
+                                           CONN_TYPE_OR)) {
       /* not in the list */
       log_fn(LOG_DEBUG,"connecting to OR at %s:%u.",router->address,router->or_port);
       connection_or_connect(router->addr, router->or_port, router->identity_digest);
@@ -650,14 +650,14 @@
 
   /* PEM-encode the onion key */
   if (crypto_pk_write_public_key_to_string(router->onion_pkey,
-                                          &onion_pkey,&onion_pkeylen)<0) {
+                                           &onion_pkey,&onion_pkeylen)<0) {
     log_fn(LOG_WARN,"write onion_pkey to string failed!");
     return -1;
   }
 
   /* PEM-encode the identity key key */
   if (crypto_pk_write_public_key_to_string(router->identity_pkey,
-                                          &identity_pkey,&identity_pkeylen)<0) {
+                                           &identity_pkey,&identity_pkeylen)<0) {
     log_fn(LOG_WARN,"write identity_pkey to string failed!");
     tor_free(onion_pkey);
     return -1;

Index: routerlist.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.191
retrieving revision 1.192
diff -u -d -r1.191 -r1.192
--- routerlist.c	28 Nov 2004 09:05:46 -0000	1.191
+++ routerlist.c	28 Nov 2004 11:39:53 -0000	1.192
@@ -62,8 +62,8 @@
       log_fn(LOG_WARN, "Cached directory at '%s' was unparseable; ignoring.", filename);
     }
     if (routerlist &&
-       ((routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2)
-        || is_recent)) {
+        ((routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2)
+         || is_recent)) {
       /* XXX use new onion key lifetime when 0.0.8 servers are obsolete */
       directory_has_arrived(st.st_mtime); /* do things we've been waiting to do */
     }
@@ -354,9 +354,9 @@
   for (i=0;i<smartlist_len(routerlist->routers);i++) {
     router = smartlist_get(routerlist->routers, i);
     if (router->is_running &&
-       (router->is_verified ||
-       (allow_unverified &&
-        !router_is_unreliable_router(router, preferuptime, preferbandwidth)))) {
+        (router->is_verified ||
+        (allow_unverified &&
+         !router_is_unreliable_router(router, preferuptime, preferbandwidth)))) {
       /* If it's running, and either it's verified or we're ok picking
        * unverified routers and this one is suitable.
        */

Index: routerparse.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.86
retrieving revision 1.87
diff -u -d -r1.86 -r1.87
--- routerparse.c	28 Nov 2004 09:05:46 -0000	1.86
+++ routerparse.c	28 Nov 2004 11:39:53 -0000	1.87
@@ -433,10 +433,9 @@
     static int have_warned_about_unverified_status = 0;
     routerinfo_t *me = router_get_my_routerinfo();
     if (me) {
-      if (router_update_status_from_smartlist(me, published_on,
-                                             good_nickname_list,
-                                          tok->tp==K_RUNNING_ROUTERS)==1 &&
-        me->is_verified == 0 && !have_warned_about_unverified_status) {
+      if (router_update_status_from_smartlist(me,
+            published_on, good_nickname_list, tok->tp==K_RUNNING_ROUTERS)==1 &&
+          me->is_verified == 0 && !have_warned_about_unverified_status) {
         log_fn(LOG_WARN,"Dirserver '%s' lists your server as unverified. Please consider sending your identity fingerprint to the tor-ops.", dirnickname);
         have_warned_about_unverified_status = 1;
       }



More information about the tor-commits mailing list