summaryrefslogtreecommitdiff
path: root/src/or/rendcommon.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-01 03:43:02 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-01 03:43:02 +0000
commitd1df046e3b230d9b445d146577eab428c3f4aa0a (patch)
tree82034dfe1dd7411b20a2429ef395dedde14fa740 /src/or/rendcommon.c
parent5da5d2bd7926707dcd9d2a40e50f5b2f9f26745a (diff)
downloadtor-d1df046e3b230d9b445d146577eab428c3f4aa0a.tar.gz
tor-d1df046e3b230d9b445d146577eab428c3f4aa0a.zip
r16314@catbus: nickm | 2007-10-31 23:40:08 -0400
Clients download and cache new hidden descriptor format. svn:r12302
Diffstat (limited to 'src/or/rendcommon.c')
-rw-r--r--src/or/rendcommon.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index 6c75555705..535a212365 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -778,18 +778,26 @@ rend_valid_service_id(const char *query)
/** If we have a cached rend_cache_entry_t for the service ID <b>query</b>
* with <b>version</b>, set *<b>e</b> to that entry and return 1.
- * Else return 0.
+ * Else return 0. If <b>version</b> is nonnegative, only return an entry
+ * in that descriptor format version. Otherwise (if <b>version</b> is
+ * negative), return the most recent format we have.
*/
int
rend_cache_lookup_entry(const char *query, int version, rend_cache_entry_t **e)
{
char key[REND_SERVICE_ID_LEN+2]; /* <version><query>\0 */
tor_assert(rend_cache);
- tor_assert(!version);
if (!rend_valid_service_id(query))
return -1;
- tor_snprintf(key, sizeof(key), "%d%s", version, query);
- *e = strmap_get_lc(rend_cache, key);
+ *e = NULL;
+ if (version != 0) {
+ tor_snprintf(key, sizeof(key), "2%s", query);
+ *e = strmap_get_lc(rend_cache, key);
+ }
+ if (!*e && version != 2) {
+ tor_snprintf(key, sizeof(key), "0%s", query);
+ *e = strmap_get_lc(rend_cache, key);
+ }
if (!*e)
return 0;
return 1;