]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
add a new advertised_server_mode() to distinguish ORs that
authorRoger Dingledine <arma@torproject.org>
Wed, 21 Jul 2004 00:12:42 +0000 (00:12 +0000)
committerRoger Dingledine <arma@torproject.org>
Wed, 21 Jul 2004 00:12:42 +0000 (00:12 +0000)
are willing to become servers from ones that really are servers.

svn:r2071

src/or/connection_or.c
src/or/directory.c
src/or/main.c
src/or/or.h

index 6cfc0e0df674c50d79916f24aa79ff2f4a7d22d7..d60a7f53fb6853599b5569d60d72bce1f5c1aed2 100644 (file)
@@ -142,9 +142,9 @@ connection_or_init_conn_from_address(connection_t *conn,
  * 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 @@ connection_t *connection_or_connect(uint32_t addr, uint16_t port,
 
   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 @@ int connection_tls_continue_handshake(connection_t *conn) {
  * 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 d6c9da3b1b68e0fc6b5b99887bded8d9bd4c3e44..41c1e8ed9163f41f91930ce341dbec244f083ce9 100644 (file)
@@ -83,8 +83,8 @@ directory_get_from_dirserver(uint8_t purpose, const char *payload,
   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 6b9e34d1b723e7d24f893c345ce05e5e33ae3a35..618d4a59a19396b8e0299e56becf6215c0e9cf77 100644 (file)
@@ -467,9 +467,17 @@ int server_mode(void) {
   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 @@ static void run_scheduled_events(time_t now) {
     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 a4fdecfb0f1846ac81e0e203b5b5d25607a890d0..67c4de373b96aac7966a7b86a54342c95499b88f 100644 (file)
@@ -1197,6 +1197,7 @@ void directory_has_arrived(void);
 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);