mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
prop224: Add a init/free_all function for the whole subsystem
Introduces hs_init() located in hs_common.c which initialize the entire HS v3 subsystem. This is done _prior_ to the options being loaded because we need to allocate global data structure before we load the configuration. The hs_free_all() is added to release everything from tor_free_all(). Note that both functions do NOT handle v2 service subsystem but does handle the common interface that both v2 and v3 needs such as the cache and circuitmap. Signed-off-by: David Goulet <dgoulet@torproject.org>
This commit is contained in:
parent
02e2edeb33
commit
765ed5dac1
5 changed files with 36 additions and 7 deletions
|
@ -15,7 +15,9 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "networkstatus.h"
|
||||
#include "hs_cache.h"
|
||||
#include "hs_common.h"
|
||||
#include "hs_service.h"
|
||||
#include "rendcommon.h"
|
||||
|
||||
/* Make sure that the directory for <b>service</b> is private, using the config
|
||||
|
@ -344,3 +346,23 @@ rend_data_get_pk_digest(const rend_data_t *rend_data, size_t *len_out)
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize the entire HS subsytem. This is called in tor_init() before any
|
||||
* torrc options are loaded. Only for >= v3. */
|
||||
void
|
||||
hs_init(void)
|
||||
{
|
||||
hs_circuitmap_init();
|
||||
hs_service_init();
|
||||
hs_cache_init();
|
||||
}
|
||||
|
||||
/* Release and cleanup all memory of the HS subsystem (all version). This is
|
||||
* called by tor_free_all(). */
|
||||
void
|
||||
hs_free_all(void)
|
||||
{
|
||||
hs_circuitmap_free_all();
|
||||
hs_service_free_all();
|
||||
hs_cache_free_all();
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,9 @@ typedef enum {
|
|||
HS_AUTH_KEY_TYPE_ED25519 = 2,
|
||||
} hs_auth_key_type_t;
|
||||
|
||||
void hs_init(void);
|
||||
void hs_free_all(void);
|
||||
|
||||
int hs_check_service_private_dir(const char *username, const char *path,
|
||||
unsigned int dir_group_readable,
|
||||
unsigned int create);
|
||||
|
|
|
@ -97,6 +97,13 @@ hs_service_free(hs_service_t *service)
|
|||
tor_free(service);
|
||||
}
|
||||
|
||||
/* Initialize the service HS subsystem. */
|
||||
void
|
||||
hs_service_init(void)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/* Release all global the storage of hidden service subsystem. */
|
||||
void
|
||||
hs_service_free_all(void)
|
||||
|
|
|
@ -193,6 +193,7 @@ typedef struct hs_service_t {
|
|||
/* API */
|
||||
|
||||
int hs_service_config_all(const or_options_t *options, int validate_only);
|
||||
void hs_service_init(void);
|
||||
void hs_service_free_all(void);
|
||||
|
||||
void hs_service_free(hs_service_t *service);
|
||||
|
|
|
@ -2499,9 +2499,6 @@ do_main_loop(void)
|
|||
}
|
||||
}
|
||||
|
||||
/* Initialize relay-side HS circuitmap */
|
||||
hs_circuitmap_init();
|
||||
|
||||
/* set up once-a-second callback. */
|
||||
if (! second_timer) {
|
||||
struct timeval one_second;
|
||||
|
@ -3014,9 +3011,10 @@ tor_init(int argc, char *argv[])
|
|||
rep_hist_init();
|
||||
/* Initialize the service cache. */
|
||||
rend_cache_init();
|
||||
hs_cache_init();
|
||||
addressmap_init(); /* Init the client dns cache. Do it always, since it's
|
||||
* cheap. */
|
||||
/* Initialize the HS subsystem. */
|
||||
hs_init();
|
||||
|
||||
{
|
||||
/* We search for the "quiet" option first, since it decides whether we
|
||||
|
@ -3216,10 +3214,8 @@ tor_free_all(int postfork)
|
|||
networkstatus_free_all();
|
||||
addressmap_free_all();
|
||||
dirserv_free_all();
|
||||
hs_service_free_all();
|
||||
rend_cache_free_all();
|
||||
rend_service_authorization_free_all();
|
||||
hs_cache_free_all();
|
||||
rep_hist_free_all();
|
||||
dns_free_all();
|
||||
clear_pending_onions();
|
||||
|
@ -3232,7 +3228,6 @@ tor_free_all(int postfork)
|
|||
connection_edge_free_all();
|
||||
scheduler_free_all();
|
||||
nodelist_free_all();
|
||||
hs_circuitmap_free_all();
|
||||
microdesc_free_all();
|
||||
routerparse_free_all();
|
||||
ext_orport_free_all();
|
||||
|
@ -3241,6 +3236,7 @@ tor_free_all(int postfork)
|
|||
protover_free_all();
|
||||
bridges_free_all();
|
||||
consdiffmgr_free_all();
|
||||
hs_free_all();
|
||||
if (!postfork) {
|
||||
config_free_all();
|
||||
or_state_free_all();
|
||||
|
|
Loading…
Add table
Reference in a new issue