mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
{flagday} actually rotate onion keys.
svn:r1662
This commit is contained in:
@@ -655,6 +655,10 @@ int getconfig(int argc, char **argv, or_options_t *options) {
|
||||
log(LOG_WARN,"DirFetchPostPeriod option must be positive.");
|
||||
result = -1;
|
||||
}
|
||||
if(options->DirFetchPostPeriod > MIN_ONION_KEY_LIFETIME/2) {
|
||||
log(LOG_WARN,"DirFetchPostPeriod is too large; clipping.");
|
||||
options->DirFetchPostPeriod = MIN_ONION_KEY_LIFETIME/2;
|
||||
}
|
||||
|
||||
if(options->KeepalivePeriod < 1) {
|
||||
log(LOG_WARN,"KeepalivePeriod option must be positive.");
|
||||
|
||||
@@ -339,7 +339,22 @@ static void run_scheduled_events(time_t now) {
|
||||
static time_t last_uploaded_services = 0;
|
||||
int i;
|
||||
|
||||
/* 1. Every DirFetchPostPeriod seconds, we get a new directory and upload
|
||||
|
||||
/* 1a. Every MIN_ONION_KEY_LIFETIME seconds, rotate the onion keys,
|
||||
* shut down and restart all cpuworkers, and update the directory if
|
||||
* necessary.
|
||||
*/
|
||||
if (options.ORPort && get_onion_key_set_at()+MIN_ONION_KEY_LIFETIME < now) {
|
||||
rotate_onion_key();
|
||||
cpuworkers_rotate();
|
||||
if (router_rebuild_descriptor()<0) {
|
||||
log_fn(LOG_WARN, "Couldn't rebuild router descriptor");
|
||||
}
|
||||
router_rebuild_descriptor();
|
||||
router_upload_dir_desc_to_dirservers();
|
||||
}
|
||||
|
||||
/* 1b. Every DirFetchPostPeriod seconds, we get a new directory and upload
|
||||
* our descriptor (if any). */
|
||||
if(time_to_fetch_directory < now) {
|
||||
/* it's time to fetch a new directory and/or post our descriptor */
|
||||
@@ -363,6 +378,7 @@ static void run_scheduled_events(time_t now) {
|
||||
time_to_fetch_directory = now + options.DirFetchPostPeriod;
|
||||
}
|
||||
|
||||
|
||||
/* 2. Every second, we examine pending circuits and prune the
|
||||
* ones which have been pending for more than a few seconds.
|
||||
* We do this before step 3, so it can try building more if
|
||||
|
||||
@@ -109,6 +109,8 @@
|
||||
#define MAX_DNS_ENTRY_AGE (15*60)
|
||||
#endif
|
||||
|
||||
#define MIN_ONION_KEY_LIFETIME (120*60)
|
||||
|
||||
#define CIRC_ID_TYPE_LOWER 0
|
||||
#define CIRC_ID_TYPE_HIGHER 1
|
||||
|
||||
@@ -963,6 +965,7 @@ cpath_build_state_t *onion_new_cpath_build_state(uint8_t purpose,
|
||||
void set_onion_key(crypto_pk_env_t *k);
|
||||
crypto_pk_env_t *get_onion_key(void);
|
||||
crypto_pk_env_t *get_previous_onion_key(void);
|
||||
time_t get_onion_key_set_at(void);
|
||||
void set_identity_key(crypto_pk_env_t *k);
|
||||
crypto_pk_env_t *get_identity_key(void);
|
||||
int init_keys(void);
|
||||
|
||||
@@ -11,12 +11,14 @@ extern or_options_t options; /* command-line and config-file options */
|
||||
/************************************************************/
|
||||
|
||||
/* private keys */
|
||||
static time_t onionkey_set_at=0;
|
||||
static crypto_pk_env_t *onionkey=NULL;
|
||||
static crypto_pk_env_t *lastonionkey=NULL;
|
||||
static crypto_pk_env_t *identitykey=NULL;
|
||||
|
||||
void set_onion_key(crypto_pk_env_t *k) {
|
||||
onionkey = k;
|
||||
onionkey_set_at = time(NULL);
|
||||
}
|
||||
|
||||
crypto_pk_env_t *get_onion_key(void) {
|
||||
@@ -28,6 +30,10 @@ crypto_pk_env_t *get_previous_onion_key(void) {
|
||||
return lastonionkey;
|
||||
}
|
||||
|
||||
time_t get_onion_key_set_at(void) {
|
||||
return onionkey_set_at;
|
||||
}
|
||||
|
||||
void set_identity_key(crypto_pk_env_t *k) {
|
||||
identitykey = k;
|
||||
}
|
||||
@@ -68,7 +74,7 @@ void rotate_onion_key(void)
|
||||
/* XXXX WINDOWS on windows, we need to protect this next bit with a lock.
|
||||
*/
|
||||
lastonionkey = onionkey;
|
||||
onionkey = prkey;
|
||||
set_onion_key(prkey);
|
||||
if (router_rebuild_descriptor() <0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user