aboutsummaryrefslogtreecommitdiff
path: root/src/or/hs_cache.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@ev0ke.net>2016-03-29 15:08:04 -0400
committerDavid Goulet <dgoulet@torproject.org>2016-11-04 10:31:35 -0400
commit025610612d78fe0a0ec95dd88c3d44e4bf643603 (patch)
tree165a149fe0534bb58711aa61c4b2c622e7c87b25 /src/or/hs_cache.h
parent473f99bf7bdb7d23b914cd1b590451333baaf7fe (diff)
downloadtor-025610612d78fe0a0ec95dd88c3d44e4bf643603.tar.gz
tor-025610612d78fe0a0ec95dd88c3d44e4bf643603.zip
prop224: Directory cache support
This implements the proposal 224 directory descriptor cache store and lookup functionalities. Furthermore, it merges the OOM call for the HSDir cache with current protocol v2 and the new upcoming v3. Add hs_cache.{c|h} with store/lookup API. Closes #18572 Signed-off-by: David Goulet <dgoulet@torproject.org> Signed-off-by: George Kadianakis <desnacked@riseup.net>
Diffstat (limited to 'src/or/hs_cache.h')
-rw-r--r--src/or/hs_cache.h53
1 files changed, 53 insertions, 0 deletions
diff --git a/src/or/hs_cache.h b/src/or/hs_cache.h
new file mode 100644
index 0000000000..3432d61b14
--- /dev/null
+++ b/src/or/hs_cache.h
@@ -0,0 +1,53 @@
+/* Copyright (c) 2016, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/**
+ * \file hs_cache.h
+ * \brief Header file for hs_cache.c
+ **/
+
+#ifndef TOR_HS_CACHE_H
+#define TOR_HS_CACHE_H
+
+#include <stdint.h>
+
+#include "crypto.h"
+#include "crypto_ed25519.h"
+#include "hs_common.h"
+#include "hs_descriptor.h"
+#include "torcert.h"
+
+/* Descriptor representation on the directory side which is a subset of
+ * information that the HSDir can decode and serve it. */
+typedef struct hs_cache_dir_descriptor_t {
+ /* This object is indexed using the blinded pubkey located in the plaintext
+ * data which is populated only once the descriptor has been successfully
+ * decoded and validated. This simply points to that pubkey. */
+ const uint8_t *key;
+
+ /* When does this entry has been created. Used to expire entries. */
+ time_t created_ts;
+
+ /* Descriptor plaintext information. Obviously, we can't decrypt the
+ * encrypted part of the descriptor. */
+ hs_desc_plaintext_data_t *plaintext_data;
+
+ /* Encoded descriptor which is basically in text form. It's a NUL terminated
+ * string thus safe to strlen(). */
+ char *encoded_desc;
+} hs_cache_dir_descriptor_t;
+
+/* Public API */
+
+void hs_cache_init(void);
+void hs_cache_clean_as_dir(time_t now);
+size_t hs_cache_handle_oom(time_t now, size_t min_remove_bytes);
+
+/* Store and Lookup function. They are version agnostic that is depending on
+ * the requested version of the descriptor, it will be re-routed to the
+ * right function. */
+int hs_cache_store_as_dir(const char *desc);
+int hs_cache_lookup_as_dir(uint32_t version, const char *query,
+ char **desc_out);
+
+#endif /* TOR_HS_CACHE_H */