Fix bug in upload/download of hsdesc with microdescs

Previously we were using router_get_by_id(foo) to test "do we have a
descriptor that will let us make an anonymous circuit to foo".  But
that isn't right for microdescs: we should have been using node_t.

Fixes bug 3601; bugfix on 0.2.3.1-alpha.
This commit is contained in:
Nick Mathewson 2011-07-15 18:53:29 -04:00
parent 8157dcbdf8
commit b8943461c0
3 changed files with 12 additions and 5 deletions

4
changes/bug3601 Normal file
View File

@ -0,0 +1,4 @@
o Major bugfixes:
- Using microdescriptors no longer prevents Tor from uploading and
downloading hidden service descriptors. Fixes bug 3601; bugfix
on 0.2.3.1-alpha.

View File

@ -510,10 +510,11 @@ directory_get_from_hs_dir(const char *desc_id, const rend_data_t *rend_query)
directory_clean_last_hid_serv_requests(now);
SMARTLIST_FOREACH(responsible_dirs, routerstatus_t *, dir, {
if (lookup_last_hid_serv_request(dir, desc_id_base32, 0, 0) +
REND_HID_SERV_DIR_REQUERY_PERIOD >= now ||
!router_get_by_id_digest(dir->identity_digest))
SMARTLIST_DEL_CURRENT(responsible_dirs, dir);
time_t last = lookup_last_hid_serv_request(dir, desc_id_base32, 0, 0);
const node_t *node = node_get_by_id(dir->identity_digest);
if (last + REND_HID_SERV_DIR_REQUERY_PERIOD >= now ||
!node || !node_has_descriptor(node))
SMARTLIST_DEL_CURRENT(responsible_dirs, dir);
});
hs_dir = smartlist_choose(responsible_dirs);

View File

@ -1632,12 +1632,14 @@ directory_post_to_hs_dir(rend_service_descriptor_t *renddesc,
for (j = 0; j < smartlist_len(responsible_dirs); j++) {
char desc_id_base32[REND_DESC_ID_V2_LEN_BASE32 + 1];
char *hs_dir_ip;
const node_t *node;
hs_dir = smartlist_get(responsible_dirs, j);
if (smartlist_digest_isin(renddesc->successful_uploads,
hs_dir->identity_digest))
/* Don't upload descriptor if we succeeded in doing so last time. */
continue;
if (!router_get_by_id_digest(hs_dir->identity_digest)) {
node = node_get_by_id(hs_dir->identity_digest);
if (!node || !node_has_descriptor(node)) {
log_info(LD_REND, "Not sending publish request for v2 descriptor to "
"hidden service directory %s; we don't have its "
"router descriptor. Queuing for later upload.",