Tor 0.4.9.2-alpha-dev
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Data Structures | Macros | Functions
hs_cache.h File Reference

Header file for hs_cache.c. More...

#include <stdint.h>
#include "feature/hs/hs_common.h"
#include "feature/hs/hs_descriptor.h"
#include "feature/hs/hs_ident.h"
#include "feature/rend/rendcommon.h"
#include "feature/nodelist/torcert.h"

Go to the source code of this file.

Data Structures

struct  hs_cache_intro_state_t
 
struct  hs_cache_client_intro_state_t
 
struct  hs_cache_dir_descriptor_t
 

Macros

#define HS_CACHE_CLIENT_INTRO_STATE_MAX_AGE   (2 * 60)
 
#define HS_CACHE_MAX_AGE   (2*24*60*60)
 
#define HS_CACHE_MAX_SKEW   (24*60*60)
 
#define HS_CACHE_FAILURE_MAX_AGE   (5*60)
 

Functions

static time_t hs_cache_max_entry_lifetime (void)
 
void hs_cache_init (void)
 
void hs_cache_free_all (void)
 
void hs_cache_clean_as_dir (time_t now)
 
size_t hs_cache_handle_oom (size_t min_remove_bytes)
 
unsigned int hs_cache_get_max_descriptor_size (void)
 
int hs_cache_store_as_dir (const char *desc)
 
int hs_cache_lookup_as_dir (uint32_t version, const char *query, const char **desc_out)
 
void hs_cache_mark_dowloaded_as_dir (const hs_ident_dir_conn_t *ident)
 
const hs_descriptor_ths_cache_lookup_as_client (const struct ed25519_public_key_t *key)
 
const char * hs_cache_lookup_encoded_as_client (const struct ed25519_public_key_t *key)
 
hs_desc_decode_status_t hs_cache_store_as_client (const char *desc_str, const struct ed25519_public_key_t *identity_pk)
 
void hs_cache_remove_as_client (const struct ed25519_public_key_t *key)
 
void hs_cache_clean_as_client (time_t now)
 
void hs_cache_purge_as_client (void)
 
void hs_cache_client_intro_state_note (const struct ed25519_public_key_t *service_pk, const struct ed25519_public_key_t *auth_key, rend_intro_point_failure_t failure)
 
const hs_cache_intro_state_ths_cache_client_intro_state_find (const struct ed25519_public_key_t *service_pk, const struct ed25519_public_key_t *auth_key)
 
void hs_cache_client_intro_state_clean (time_t now)
 
void hs_cache_client_intro_state_purge (void)
 
bool hs_cache_client_new_auth_parse (const ed25519_public_key_t *service_pk)
 
size_t hs_cache_get_total_allocation (void)
 
void hs_cache_decrement_allocation (size_t n)
 
void hs_cache_increment_allocation (size_t n)
 

Detailed Description

Header file for hs_cache.c.

Definition in file hs_cache.h.

Macro Definition Documentation

◆ HS_CACHE_CLIENT_INTRO_STATE_MAX_AGE

#define HS_CACHE_CLIENT_INTRO_STATE_MAX_AGE   (2 * 60)

This is the maximum time an introduction point state object can stay in the client cache in seconds (2 mins or 120 seconds).

Definition at line 24 of file hs_cache.h.

◆ HS_CACHE_FAILURE_MAX_AGE

#define HS_CACHE_FAILURE_MAX_AGE   (5*60)

How old do we keep an intro point failure entry in the failure cache?

Definition at line 32 of file hs_cache.h.

◆ HS_CACHE_MAX_AGE

#define HS_CACHE_MAX_AGE   (2*24*60*60)

How old do we let hidden service descriptors get before discarding them as too old?

Definition at line 27 of file hs_cache.h.

◆ HS_CACHE_MAX_SKEW

#define HS_CACHE_MAX_SKEW   (24*60*60)

How wrong do we assume our clock may be when checking whether hidden services are too old or too new?

Definition at line 30 of file hs_cache.h.

Function Documentation

◆ hs_cache_clean_as_client()

void hs_cache_clean_as_client ( time_t  now)

Clean all client caches using the current time now.

Definition at line 1027 of file hs_cache.c.

Referenced by clean_caches_callback().

◆ hs_cache_clean_as_dir()

void hs_cache_clean_as_dir ( time_t  now)

Clean all directory caches using the current time now.

Definition at line 422 of file hs_cache.c.

Referenced by clean_caches_callback().

◆ hs_cache_client_intro_state_clean()

void hs_cache_client_intro_state_clean ( time_t  now)

Cleanup the client introduction state cache.

Definition at line 1086 of file hs_cache.c.

Referenced by rend_cache_failure_clean_callback().

◆ hs_cache_client_intro_state_purge()

void hs_cache_client_intro_state_purge ( void  )

Purge the client introduction state cache.

Definition at line 1106 of file hs_cache.c.

◆ hs_cache_client_new_auth_parse()

bool hs_cache_client_new_auth_parse ( const ed25519_public_key_t service_pk)

Definition at line 1123 of file hs_cache.c.

◆ hs_cache_decrement_allocation()

void hs_cache_decrement_allocation ( size_t  n)

Decrement the total bytes attributed to the rendezvous cache by n.

Definition at line 1233 of file hs_cache.c.

Referenced by remove_v3_desc_as_client().

◆ hs_cache_free_all()

void hs_cache_free_all ( void  )

Cleanup the hidden service cache subsystem.

Definition at line 1210 of file hs_cache.c.

Referenced by hs_free_all().

◆ hs_cache_get_max_descriptor_size()

unsigned int hs_cache_get_max_descriptor_size ( void  )

Return the maximum size of a v3 HS descriptor.

Definition at line 1186 of file hs_cache.c.

◆ hs_cache_get_total_allocation()

size_t hs_cache_get_total_allocation ( void  )

Definition at line 1226 of file hs_cache.c.

◆ hs_cache_handle_oom()

size_t hs_cache_handle_oom ( size_t  min_remove_bytes)

Do a round of OOM cleanup on all directory caches. Return the amount of removed bytes. It is possible that the returned value is lower than min_remove_bytes if the caches get emptied out so the caller should be aware of this.

Definition at line 1157 of file hs_cache.c.

◆ hs_cache_increment_allocation()

void hs_cache_increment_allocation ( size_t  n)

Increase the total bytes attributed to the rendezvous cache by n.

Definition at line 1250 of file hs_cache.c.

◆ hs_cache_init()

void hs_cache_init ( void  )

Initialize the hidden service cache subsystem.

Definition at line 1195 of file hs_cache.c.

Referenced by hs_init().

◆ hs_cache_lookup_as_dir()

int hs_cache_lookup_as_dir ( uint32_t  version,
const char *  query,
const char **  desc_out 
)

Using the query, lookup in our directory cache the entry. If found, 1 is returned and desc_out is populated with a newly allocated string being the encoded descriptor. If not found, 0 is returned and desc_out is untouched. On error, a negative value is returned and desc_out is untouched.

Definition at line 385 of file hs_cache.c.

Referenced by handle_get_hs_descriptor_v3().

◆ hs_cache_mark_dowloaded_as_dir()

void hs_cache_mark_dowloaded_as_dir ( const hs_ident_dir_conn_t ident)

Using the given directory identifier, lookup the descriptor in our cache and if present, increment the downloaded counter. This is done when the directory connection fetching this descriptor is closed.

Definition at line 408 of file hs_cache.c.

Referenced by connection_dir_about_to_close().

◆ hs_cache_max_entry_lifetime()

static time_t hs_cache_max_entry_lifetime ( void  )
inlinestatic

Definition at line 82 of file hs_cache.h.

◆ hs_cache_purge_as_client()

void hs_cache_purge_as_client ( void  )

Purge the client descriptor cache.

Definition at line 1036 of file hs_cache.c.

◆ hs_cache_store_as_dir()

int hs_cache_store_as_dir ( const char *  desc)

Given an encoded descriptor, store it in the directory cache depending on which version it is. Return a negative value on error. On success, 0 is returned.

Definition at line 348 of file hs_cache.c.