summaryrefslogtreecommitdiff
path: root/src/or/hs_service.c
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2017-11-07 16:00:40 -0500
committerDavid Goulet <dgoulet@torproject.org>2017-11-20 11:02:30 -0500
commit0a3b2954487480114201758e02b3560e46ea1cca (patch)
tree0be4dc41e2d96d4c955f335e14e6e4aa28ed6a88 /src/or/hs_service.c
parente1d8e611c8fa1a3a1d3c2beb72c416c71f9cdf15 (diff)
downloadtor-0a3b2954487480114201758e02b3560e46ea1cca.tar.gz
tor-0a3b2954487480114201758e02b3560e46ea1cca.zip
hs-v3: Add a lookup service current descriptor function
This will be used by the control port command "GETINFO hs/service/desc/id/<ADDR>" which returns the encoded current descriptor for the given onion address. Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/or/hs_service.c')
-rw-r--r--src/or/hs_service.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/or/hs_service.c b/src/or/hs_service.c
index 8e2f52dcf0..349aa265d3 100644
--- a/src/or/hs_service.c
+++ b/src/or/hs_service.c
@@ -2900,6 +2900,31 @@ service_add_fnames_to_list(const hs_service_t *service, smartlist_t *list)
/* Public API */
/* ========== */
+/* Using the ed25519 public key pk, find a service for that key and return the
+ * current encoded descriptor as a newly allocated string or NULL if not
+ * found. This is used by the control port subsystem. */
+char *
+hs_service_lookup_current_desc(const ed25519_public_key_t *pk)
+{
+ const hs_service_t *service;
+
+ tor_assert(pk);
+
+ service = find_service(hs_service_map, pk);
+ if (service && service->desc_current) {
+ char *encoded_desc = NULL;
+ /* No matter what is the result (which should never be a failure), return
+ * the encoded variable, if success it will contain the right thing else
+ * it will be NULL. */
+ hs_desc_encode_descriptor(service->desc_current->desc,
+ &service->desc_current->signing_kp,
+ &encoded_desc);
+ return encoded_desc;
+ }
+
+ return NULL;
+}
+
/* Return the number of service we have configured and usable. */
unsigned int
hs_service_get_num_services(void)