aboutsummaryrefslogtreecommitdiff
path: root/src/feature/hs/hs_service.h
diff options
context:
space:
mode:
authorDavid Goulet <dgoulet@torproject.org>2022-06-28 13:43:35 -0400
committerMicah Elizabeth Scott <beth@torproject.org>2023-05-10 07:37:11 -0700
commitca74530b40aa893196de2f6cdde9bcaeec4d03c2 (patch)
tree74a38ee01bf119ec64d172b42a9bb87ba1a89d88 /src/feature/hs/hs_service.h
parent8b41e09a775e882096364210317813c830160a5b (diff)
downloadtor-ca74530b40aa893196de2f6cdde9bcaeec4d03c2.tar.gz
tor-ca74530b40aa893196de2f6cdde9bcaeec4d03c2.zip
hs: Setup service side PoW defenses
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/feature/hs/hs_service.h')
-rw-r--r--src/feature/hs/hs_service.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/feature/hs/hs_service.h b/src/feature/hs/hs_service.h
index 95461289ce..817fa67718 100644
--- a/src/feature/hs/hs_service.h
+++ b/src/feature/hs/hs_service.h
@@ -35,6 +35,11 @@
/** Maximum interval for uploading next descriptor (in seconds). */
#define HS_SERVICE_NEXT_UPLOAD_TIME_MAX (120 * 60)
+/** PoW seed expiration time is set to RAND_TIME(now+7200, 900)
+ * seconds. */
+#define HS_SERVICE_POW_SEED_ROTATE_TIME_MIN (7200 - 900)
+#define HS_SERVICE_POW_SEED_ROTATE_TIME_MAX (7200)
+
/** Collected metrics for a specific service. */
typedef struct hs_service_metrics_t {
/** Store containing the metrics values. */
@@ -257,6 +262,11 @@ typedef struct hs_service_config_t {
uint32_t intro_dos_rate_per_sec;
uint32_t intro_dos_burst_per_sec;
+ /** True iff PoW anti-DoS defenses are enabled. */
+ unsigned int has_pow_defenses_enabled : 1;
+ uint32_t pow_min_effort;
+ uint32_t pow_svc_bottom_capacity;
+
/** If set, contains the Onion Balance master ed25519 public key (taken from
* an .onion addresses) that this tor instance serves as backend. */
smartlist_t *ob_master_pubkeys;
@@ -291,6 +301,10 @@ typedef struct hs_service_state_t {
hs_subcredential_t *ob_subcreds;
/* Number of OB subcredentials */
size_t n_ob_subcreds;
+
+ /** State of the PoW defenses, which may be enabled dynamically. NULL if not
+ * defined for this service. */
+ hs_pow_service_state_t *pow_state;
} hs_service_state_t;
/** Representation of a service running on this tor instance. */