diff --git a/src/or/directory.c b/src/or/directory.c index 1587384912..0cefb96414 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -83,25 +83,24 @@ purpose_is_private(uint8_t purpose) 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'. * + * type 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,10 +112,13 @@ directory_post_to_dirservers(uint8_t purpose, const char *payload, 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; diff --git a/src/or/or.h b/src/or/or.h index 82585c3db1..9f43f9ef12 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2497,7 +2497,11 @@ int assign_to_cpuworker(connection_t *cpuworker, uint8_t question_type, /********************************* 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 @@ routerstatus_t *router_pick_directory_server(int requireother, 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, diff --git a/src/or/rendservice.c b/src/or/rendservice.c index d59aed3590..5f68202856 100644 --- a/src/or/rendservice.c +++ b/src/or/rendservice.c @@ -947,7 +947,8 @@ upload_service_descriptor(rend_service_t *service, int version) } /* 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; diff --git a/src/or/router.c b/src/or/router.c index 30b55a562a..ba384b07c7 100644 --- a/src/or/router.c +++ b/src/or/router.c @@ -787,8 +787,8 @@ router_upload_dir_desc_to_dirservers(int force) } 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); }