[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r10129: prepare directory_post_to_dirservers() to hear what sort of (tor/trunk/src/or)



Author: arma
Date: 2007-05-07 05:28:48 -0400 (Mon, 07 May 2007)
New Revision: 10129

Modified:
   tor/trunk/src/or/directory.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/rendservice.c
   tor/trunk/src/or/router.c
Log:
prepare directory_post_to_dirservers() to hear what sort of
dir authority we'd like to upload to. at some point we should
pick a config option to say that in, for bridges.


Modified: tor/trunk/src/or/directory.c
===================================================================
--- tor/trunk/src/or/directory.c	2007-05-07 08:26:50 UTC (rev 10128)
+++ tor/trunk/src/or/directory.c	2007-05-07 09:28:48 UTC (rev 10129)
@@ -83,25 +83,24 @@
   return 1;
 }
 
-/** Start a connection to every known directory server, using
+/** Start a connection to every suitable directory server, using
  * connection purpose 'purpose' and uploading the payload 'payload'
  * (length 'payload_len').  The purpose should be one of
  * 'DIR_PURPOSE_UPLOAD_DIR' or 'DIR_PURPOSE_UPLOAD_RENDDESC'.
  *
+ * <b>type</b> specifies what sort of dir authorities (V1, V2,
+ * HIDSERV, BRIDGE) we should upload to.
+ *
  * DOCDOC extrainfo_len is in addition to payload_len.
  */
 void
-directory_post_to_dirservers(uint8_t purpose, const char *payload,
+directory_post_to_dirservers(uint8_t purpose, authority_type_t type,
+                             const char *payload,
                              size_t payload_len, size_t extrainfo_len)
 {
-  smartlist_t *dirservers;
   int post_via_tor;
-  int post_to_hidserv_only;
-
-  dirservers = router_get_trusted_dir_servers();
+  smartlist_t *dirservers = router_get_trusted_dir_servers();
   tor_assert(dirservers);
-  /* Only old dirservers handle rendezvous descriptor publishing. */
-  post_to_hidserv_only = (purpose == DIR_PURPOSE_UPLOAD_RENDDESC);
   /* This tries dirservers which we believe to be down, but ultimately, that's
    * harmless, and we may as well err on the side of getting things uploaded.
    */
@@ -113,11 +112,14 @@
       int new_enough;
 
       size_t upload_len = payload_len;
-      if (post_to_hidserv_only && !ds->is_hidserv_authority)
+      if (type == HIDSERV_AUTHORITY && !ds->is_hidserv_authority)
         continue;
-      if (!post_to_hidserv_only &&
-          !(ds->is_v1_authority || ds->is_v2_authority))
+      if (type == BRIDGE_AUTHORITY && !ds->is_bridge_authority)
         continue;
+      if (type == V1_AUTHORITY && !ds->is_v1_authority)
+        continue;
+      if (type == V2_AUTHORITY && !ds->is_v2_authority)
+        continue;
       if (purpose == DIR_PURPOSE_UPLOAD_DIR)
         ds->has_accepted_serverdesc = 0;
 

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-05-07 08:26:50 UTC (rev 10128)
+++ tor/trunk/src/or/or.h	2007-05-07 09:28:48 UTC (rev 10129)
@@ -2497,7 +2497,11 @@
 
 /********************************* directory.c ***************************/
 
-void directory_post_to_dirservers(uint8_t purpose, const char *payload,
+typedef enum {
+  V1_AUTHORITY, V2_AUTHORITY, HIDSERV_AUTHORITY, BRIDGE_AUTHORITY
+} authority_type_t;
+void directory_post_to_dirservers(uint8_t purpose, authority_type_t type,
+                                  const char *payload,
                                   size_t payload_len, size_t extrainfo_len);
 void directory_get_from_dirserver(uint8_t purpose, const char *resource,
                                   int retry_if_no_servers);
@@ -3035,9 +3039,6 @@
                                              int fascistfirewall,
                                              int for_v2_directory,
                                              int retry_if_no_servers);
-typedef enum {
-  V1_AUTHORITY, V2_AUTHORITY, HIDSERV_AUTHORITY, BRIDGE_AUTHORITY
-} authority_type_t;
 routerstatus_t *router_pick_trusteddirserver(authority_type_t type,
                                              int requireother,
                                              int fascistfirewall,

Modified: tor/trunk/src/or/rendservice.c
===================================================================
--- tor/trunk/src/or/rendservice.c	2007-05-07 08:26:50 UTC (rev 10128)
+++ tor/trunk/src/or/rendservice.c	2007-05-07 09:28:48 UTC (rev 10129)
@@ -947,7 +947,8 @@
   }
 
   /* Post it to the dirservers */
-  directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_RENDDESC, desc, desc_len, 0);
+  directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_RENDDESC,
+                               HIDSERV_AUTHORITY, desc, desc_len, 0);
   tor_free(desc);
 
   service->desc_is_dirty = 0;

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-05-07 08:26:50 UTC (rev 10128)
+++ tor/trunk/src/or/router.c	2007-05-07 09:28:48 UTC (rev 10129)
@@ -787,8 +787,8 @@
   }
   msg[desc_len+extra_len] = 0;
 
-  directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, msg, desc_len,
-                               extra_len);
+  directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, V2_AUTHORITY,
+                               msg, desc_len, extra_len);
   tor_free(msg);
 }