commit 05766eae3099ff1542b1dc4715b824d206b7c84f Author: David Goulet dgoulet@torproject.org Date: Tue Nov 7 15:38:02 2017 -0500
hs-v3: Add an encoded descriptor client cache lookup function
This commit adds hs_cache_lookup_encoded_as_client() function that returns the encoded descriptor for a given service public key. This will be needed by the "GETINFO hs/client/desc/id/<ADDR>" control port command.
Signed-off-by: David Goulet dgoulet@torproject.org --- src/or/hs_cache.c | 18 ++++++++++++++++++ src/or/hs_cache.h | 2 ++ 2 files changed, 20 insertions(+)
diff --git a/src/or/hs_cache.c b/src/or/hs_cache.c index 3ebe13fb4..b864a0f71 100644 --- a/src/or/hs_cache.c +++ b/src/or/hs_cache.c @@ -706,6 +706,24 @@ cache_clean_v3_as_client(time_t now) }
/** Public API: Given the HS ed25519 identity public key in <b>key</b>, return + * its HS encoded descriptor if it's stored in our cache, or NULL if not. */ +const char * +hs_cache_lookup_encoded_as_client(const ed25519_public_key_t *key) +{ + hs_cache_client_descriptor_t *cached_desc = NULL; + + tor_assert(key); + + cached_desc = lookup_v3_desc_as_client(key->pubkey); + if (cached_desc) { + tor_assert(cached_desc->encoded_desc); + return cached_desc->encoded_desc; + } + + return NULL; +} + +/** Public API: Given the HS ed25519 identity public key in <b>key</b>, return * its HS descriptor if it's stored in our cache, or NULL if not. */ const hs_descriptor_t * hs_cache_lookup_as_client(const ed25519_public_key_t *key) diff --git a/src/or/hs_cache.h b/src/or/hs_cache.h index 2dcc518a7..a141634cc 100644 --- a/src/or/hs_cache.h +++ b/src/or/hs_cache.h @@ -81,6 +81,8 @@ int hs_cache_lookup_as_dir(uint32_t version, const char *query,
const hs_descriptor_t * hs_cache_lookup_as_client(const ed25519_public_key_t *key); +const char * +hs_cache_lookup_encoded_as_client(const ed25519_public_key_t *key); int hs_cache_store_as_client(const char *desc_str, const ed25519_public_key_t *identity_pk); void hs_cache_clean_as_client(time_t now);