tor
master
|
Header file for rendcache.c. More...
Go to the source code of this file.
Data Structures | |
struct | rend_cache_entry_t |
struct | rend_cache_failure_intro_t |
struct | rend_cache_failure_t |
Macros | |
#define | REND_CACHE_MAX_AGE (2*24*60*60) |
#define | REND_CACHE_MAX_SKEW (24*60*60) |
#define | REND_CACHE_FAILURE_MAX_AGE (5*60) |
#define | MAX_INTRO_POINTS 10 |
Typedefs | |
typedef struct rend_cache_entry_t | rend_cache_entry_t |
typedef struct rend_cache_failure_intro_t | rend_cache_failure_intro_t |
typedef struct rend_cache_failure_t | rend_cache_failure_t |
Enumerations | |
enum | rend_cache_type_t { REND_CACHE_TYPE_CLIENT = 1, REND_CACHE_TYPE_SERVICE = 2 } |
Functions | |
void | rend_cache_init (void) |
void | rend_cache_clean (time_t now, rend_cache_type_t cache_type) |
void | rend_cache_failure_clean (time_t now) |
size_t | rend_cache_clean_v2_descs_as_dir (time_t cutoff) |
void | rend_cache_purge (void) |
void | rend_cache_free_all (void) |
int | rend_cache_lookup_entry (const char *query, int version, rend_cache_entry_t **entry_out) |
int | rend_cache_lookup_v2_desc_as_service (const char *query, rend_cache_entry_t **entry_out) |
int | rend_cache_lookup_v2_desc_as_dir (const char *query, const char **desc) |
int | rend_cache_store_v2_desc_as_dir (const char *desc) |
int | rend_cache_store_v2_desc_as_service (const char *desc) |
int | rend_cache_store_v2_desc_as_client (const char *desc, const char *desc_id_base32, const rend_data_t *rend_query, rend_cache_entry_t **entry) |
size_t | rend_cache_get_total_allocation (void) |
void | rend_cache_intro_failure_note (rend_intro_point_failure_t failure, const uint8_t *identity, const char *service_id) |
void | rend_cache_failure_purge (void) |
void | rend_cache_decrement_allocation (size_t n) |
void | rend_cache_increment_allocation (size_t n) |
Header file for rendcache.c.
#define REND_CACHE_FAILURE_MAX_AGE (5*60) |
How old do we keep an intro point failure entry in the failure cache?
#define REND_CACHE_MAX_AGE (2*24*60*60) |
How old do we let hidden service descriptors get before discarding them as too old?
#define REND_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?
typedef struct rend_cache_entry_t rend_cache_entry_t |
A cached rendezvous descriptor.
typedef struct rend_cache_failure_t rend_cache_failure_t |
Cache failure object indexed by service ID.
void rend_cache_clean | ( | time_t | now, |
rend_cache_type_t | cache_type | ||
) |
Removes all old entries from the client or service descriptor cache.
size_t rend_cache_clean_v2_descs_as_dir | ( | time_t | cutoff | ) |
Remove all old v2 descriptors and those for which this hidden service directory is not responsible for any more. The cutoff is the time limit for which we want to keep the cache entry. In other words, any entry created before will be removed.
void rend_cache_decrement_allocation | ( | size_t | n | ) |
Decrement the total bytes attributed to the rendezvous cache by n.
void rend_cache_failure_clean | ( | time_t | now | ) |
Remove all entries that re REND_CACHE_FAILURE_MAX_AGE old. This is called every second.
We have to clean these regurlarly else if for whatever reasons an hidden service goes offline and a client tries to connect to it during that time, a failure entry is created and the client will be unable to connect for a while even though the service has return online.
void rend_cache_failure_purge | ( | void | ) |
Remove ALL entries from the failure cache. This is also called when a NEWNYM signal is received.
void rend_cache_free_all | ( | void | ) |
Free all storage held by the service descriptor cache.
void rend_cache_increment_allocation | ( | size_t | n | ) |
Increase the total bytes attributed to the rendezvous cache by n.
void rend_cache_init | ( | void | ) |
Initializes the service descriptor cache.
void rend_cache_intro_failure_note | ( | rend_intro_point_failure_t | failure, |
const uint8_t * | identity, | ||
const char * | service_id | ||
) |
Note down an intro failure in the rend failure cache using the type of failure in failure for the relay identity digest in identity and service ID service_id. If an entry already exists in the cache, the failure type is changed with failure.
int rend_cache_lookup_entry | ( | const char * | query, |
int | version, | ||
rend_cache_entry_t ** | e | ||
) |
Lookup in the client cache the given service ID query for version.
Return 0 if found and if e is non NULL, set it with the entry found. Else, a negative value is returned and e is untouched. -EINVAL means that query is not a valid service id. -ENOENT means that no entry in the cache was found.
int rend_cache_lookup_v2_desc_as_dir | ( | const char * | desc_id, |
const char ** | desc | ||
) |
Lookup the v2 service descriptor with base32-encoded desc_id and copy the pointer to it to *desc. Return 1 on success, 0 on well-formed-but-not-found, and -1 on failure.
void rend_cache_purge | ( | void | ) |
Remove ALL entries from the rendezvous service descriptor cache.
int rend_cache_store_v2_desc_as_client | ( | const char * | desc, |
const char * | desc_id_base32, | ||
const rend_data_t * | rend_query, | ||
rend_cache_entry_t ** | entry | ||
) |
Parse the v2 service descriptor in desc, decrypt the included list of introduction points with descriptor_cookie (which may also be NULL if decryption is not necessary), and store the descriptor to the local cache under its version and service id.
If we have a newer v2 descriptor with the same ID, ignore this one. If we have an older descriptor with the same ID, replace it. If the descriptor's service ID does not match rend_query->onion_address, reject it.
If the descriptor's descriptor ID doesn't match desc_id_base32, reject it.
Return 0 on success, or -1 if we rejected the descriptor. If entry is not NULL, set it with the cache entry pointer of the descriptor.
int rend_cache_store_v2_desc_as_dir | ( | const char * | desc | ) |
Parse the v2 service descriptor(s) in desc and store it/them to the local rend cache. Don't attempt to decrypt the included list of introduction points (as we don't have a descriptor cookie for it).
If we have a newer descriptor with the same ID, ignore this one. If we have an older descriptor with the same ID, replace it.
Return 0 on success, or -1 if we couldn't parse any of them.
We should only call this function for public (e.g. non bridge) relays.
int rend_cache_store_v2_desc_as_service | ( | const char * | desc | ) |
Parse the v2 service descriptor in desc and store it to the local service rend cache. Don't attempt to decrypt the included list of introduction points.
If we have a newer descriptor with the same ID, ignore this one. If we have an older descriptor with the same ID, replace it.
Return 0 on success, or -1 if we couldn't understand the descriptor.