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.


svn:r10129
This commit is contained in:
Roger Dingledine 2007-05-07 09:28:48 +00:00
parent f8a8b27dd2
commit 95ead29574
4 changed files with 22 additions and 18 deletions

View File

@ -83,25 +83,24 @@ purpose_is_private(uint8_t purpose)
return 1; 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' * connection purpose 'purpose' and uploading the payload 'payload'
* (length 'payload_len'). The purpose should be one of * (length 'payload_len'). The purpose should be one of
* 'DIR_PURPOSE_UPLOAD_DIR' or 'DIR_PURPOSE_UPLOAD_RENDDESC'. * '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. * DOCDOC extrainfo_len is in addition to payload_len.
*/ */
void 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) size_t payload_len, size_t extrainfo_len)
{ {
smartlist_t *dirservers;
int post_via_tor; int post_via_tor;
int post_to_hidserv_only; smartlist_t *dirservers = router_get_trusted_dir_servers();
dirservers = router_get_trusted_dir_servers();
tor_assert(dirservers); 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 /* 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. * harmless, and we may as well err on the side of getting things uploaded.
*/ */
@ -113,10 +112,13 @@ directory_post_to_dirservers(uint8_t purpose, const char *payload,
int new_enough; int new_enough;
size_t upload_len = payload_len; size_t upload_len = payload_len;
if (post_to_hidserv_only && !ds->is_hidserv_authority) if (type == HIDSERV_AUTHORITY && !ds->is_hidserv_authority)
continue; continue;
if (!post_to_hidserv_only && if (type == BRIDGE_AUTHORITY && !ds->is_bridge_authority)
!(ds->is_v1_authority || ds->is_v2_authority)) continue;
if (type == V1_AUTHORITY && !ds->is_v1_authority)
continue;
if (type == V2_AUTHORITY && !ds->is_v2_authority)
continue; continue;
if (purpose == DIR_PURPOSE_UPLOAD_DIR) if (purpose == DIR_PURPOSE_UPLOAD_DIR)
ds->has_accepted_serverdesc = 0; ds->has_accepted_serverdesc = 0;

View File

@ -2497,7 +2497,11 @@ int assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type,
/********************************* directory.c ***************************/ /********************************* 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); size_t payload_len, size_t extrainfo_len);
void directory_get_from_dirserver(uint8_t purpose, const char *resource, void directory_get_from_dirserver(uint8_t purpose, const char *resource,
int retry_if_no_servers); int retry_if_no_servers);
@ -3035,9 +3039,6 @@ routerstatus_t *router_pick_directory_server(int requireother,
int fascistfirewall, int fascistfirewall,
int for_v2_directory, int for_v2_directory,
int retry_if_no_servers); 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, routerstatus_t *router_pick_trusteddirserver(authority_type_t type,
int requireother, int requireother,
int fascistfirewall, int fascistfirewall,

View File

@ -947,7 +947,8 @@ upload_service_descriptor(rend_service_t *service, int version)
} }
/* Post it to the dirservers */ /* 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); tor_free(desc);
service->desc_is_dirty = 0; service->desc_is_dirty = 0;

View File

@ -787,8 +787,8 @@ router_upload_dir_desc_to_dirservers(int force)
} }
msg[desc_len+extra_len] = 0; msg[desc_len+extra_len] = 0;
directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, msg, desc_len, directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_DIR, V2_AUTHORITY,
extra_len); msg, desc_len, extra_len);
tor_free(msg); tor_free(msg);
} }