[or-cvs] add a new advertised_server_mode() to distinguish ORs that

Roger Dingledine arma at seul.org
Wed Jul 21 00:12:44 UTC 2004


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

Modified Files:
	connection_or.c directory.c main.c or.h 
Log Message:
add a new advertised_server_mode() to distinguish ORs that
are willing to become servers from ones that really are servers.


Index: connection_or.c
===================================================================
RCS file: /home/or/cvsroot/src/or/connection_or.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- connection_or.c	18 Jul 2004 21:47:04 -0000	1.116
+++ connection_or.c	21 Jul 2004 00:12:42 -0000	1.117
@@ -142,9 +142,9 @@
  * handshake with an OR with identity digest <b>id_digest</b>.
  *
  * If <b>id_digest</b> is me, do nothing. If we're already connected to it,
- * return that connection. If the connect() is in progress, set conn's
- * state to 'connecting' and return. If connect() succeeds, call
- * connection_tls_start_handshake() on it.
+ * return that connection. If the connect() is in progress, set the
+ * new conn's state to 'connecting' and return it. If connect() succeeds,
+ * call * connection_tls_start_handshake() on it.
  *
  * This function is called from router_retry_connections(), for
  * ORs connecting to ORs, and circuit_establish_circuit(), for
@@ -158,7 +158,7 @@
 
   tor_assert(id_digest);
 
-  if(0) { /* XXX008 if I'm an OR and id_digest is my digest */
+  if(server_mode() && 0) { /* XXX008 if I'm an OR and id_digest is my digest */
     log_fn(LOG_WARN,"Request to connect to myself! Failing.");
     return NULL;
   }
@@ -260,7 +260,7 @@
  * If all is successful and he's an OR, then call circuit_n_conn_done()
  * to handle events that have been pending on the tls handshake
  * completion, and set the directory to be dirty (only matters if I'm
- * a dirserver).
+ * an authdirserver).
  */
 static int
 connection_tls_finish_handshake(connection_t *conn) {

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- directory.c	20 Jul 2004 06:44:16 -0000	1.117
+++ directory.c	21 Jul 2004 00:12:42 -0000	1.118
@@ -83,8 +83,8 @@
   routerinfo_t *ds;
 
   if (purpose == DIR_PURPOSE_FETCH_DIR) {
-    if (server_mode()) {
-      /* only ask authdirservers, don't ask myself */
+    if (advertised_server_mode()) {
+      /* only ask authdirservers, and don't ask myself */
       ds = router_pick_directory_server(1, 1);
     } else {
       /* anybody with a non-zero dirport will do */

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.297
retrieving revision 1.298
diff -u -d -r1.297 -r1.298
--- main.c	20 Jul 2004 23:31:00 -0000	1.297
+++ main.c	21 Jul 2004 00:12:42 -0000	1.298
@@ -467,9 +467,17 @@
   return (options.ORPort != 0);
 }
 
+/** Return true iff we have published our descriptor lately.
+ */
+int advertised_server_mode(void) {
+  return (options.ORPort != 0);
+}
+
 /** Return true iff we are trying to be an exit server.
  */
 int exit_server_mode(void) {
+  /* XXX008 NM: non-exit servers still answer resolve requests, right? How
+   * is this to be used? */
   return (options.ORPort != 0);
 }
 
@@ -506,6 +514,7 @@
     if (router_rebuild_descriptor()<0) {
       log_fn(LOG_WARN, "Couldn't rebuild router descriptor");
     }
+    /* XXX008 only if advertised_server_mode */
     router_upload_dir_desc_to_dirservers();
   }
 

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.387
retrieving revision 1.388
diff -u -d -r1.387 -r1.388
--- or.h	20 Jul 2004 20:57:46 -0000	1.387
+++ or.h	21 Jul 2004 00:12:42 -0000	1.388
@@ -1197,6 +1197,7 @@
 int authdir_mode(void);
 int clique_mode(void);
 int server_mode(void);
+advertised_server_mode(void);
 int exit_server_mode(void);
 int proxy_mode(void);
 



More information about the tor-commits mailing list