Tor  0.4.5.0-alpha-dev
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/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)
 

Functions

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 (time_t now, 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)
 
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)
 

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 23 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 928 of file hs_cache.c.

◆ 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 332 of file hs_cache.c.

◆ 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 989 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 1009 of file hs_cache.c.

◆ hs_cache_free_all()

void hs_cache_free_all ( void  )

Cleanup the hidden service cache subsystem.

Definition at line 1135 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 1111 of file hs_cache.c.

◆ hs_cache_handle_oom()

size_t hs_cache_handle_oom ( time_t  now,
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 1060 of file hs_cache.c.

◆ hs_cache_init()

void hs_cache_init ( void  )

Initialize the hidden service cache subsystem.

Definition at line 1120 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 311 of file hs_cache.c.

Referenced by handle_get_hs_descriptor_v3().

◆ hs_cache_purge_as_client()

void hs_cache_purge_as_client ( void  )

Purge the client descriptor cache.

Definition at line 939 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 274 of file hs_cache.c.