mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
r13901@catbus: nickm | 2007-07-25 16:23:51 -0400
Make all code to generate v1 directories into conditional code. svn:r10926
This commit is contained in:
parent
83fa843663
commit
1b7a704c34
@ -30,8 +30,7 @@ const char directory_c_id[] =
|
|||||||
* - connection_dir_finished_connecting(), called from
|
* - connection_dir_finished_connecting(), called from
|
||||||
* connection_finished_connecting() in connection.c
|
* connection_finished_connecting() in connection.c
|
||||||
*/
|
*/
|
||||||
static void
|
static void directory_send_command(dir_connection_t *conn,
|
||||||
directory_send_command(dir_connection_t *conn,
|
|
||||||
int purpose, int direct, const char *resource,
|
int purpose, int direct, const char *resource,
|
||||||
const char *payload, size_t payload_len);
|
const char *payload, size_t payload_len);
|
||||||
static int directory_handle_command(dir_connection_t *conn);
|
static int directory_handle_command(dir_connection_t *conn);
|
||||||
|
@ -12,7 +12,7 @@ const char dirserv_c_id[] =
|
|||||||
* \file dirserv.c
|
* \file dirserv.c
|
||||||
* \brief Directory server core implementation. Manages directory
|
* \brief Directory server core implementation. Manages directory
|
||||||
* contents and generates directories.
|
* contents and generates directories.
|
||||||
**/
|
*/
|
||||||
|
|
||||||
/** How far in the future do we allow a router to get? (seconds) */
|
/** How far in the future do we allow a router to get? (seconds) */
|
||||||
#define ROUTER_ALLOW_SKEW (60*60*12)
|
#define ROUTER_ALLOW_SKEW (60*60*12)
|
||||||
@ -772,11 +772,26 @@ void
|
|||||||
directory_set_dirty(void)
|
directory_set_dirty(void)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
|
int set_v1_dirty;
|
||||||
|
|
||||||
if (!the_directory_is_dirty)
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
the_directory_is_dirty = now;
|
set_v1_dirty = 1;
|
||||||
if (!runningrouters_is_dirty)
|
#else
|
||||||
runningrouters_is_dirty = now;
|
/* Regenerate stubs only every 8 hours. XXXX020 */
|
||||||
|
#define STUB_REGENERATE_INTERVAL (8*60*60)
|
||||||
|
if (!the_directory || !the_runningrouters.dir)
|
||||||
|
set_v1_dirty = 1;
|
||||||
|
else if (the_directory->published < now - STUB_REGENERATE_INTERVAL ||
|
||||||
|
the_runningrouters.published < now - STUB_REGENERATE_INTERVAL)
|
||||||
|
set_v1_dirty = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (set_v1_dirty) {
|
||||||
|
if (!the_directory_is_dirty)
|
||||||
|
the_directory_is_dirty = now;
|
||||||
|
if (!runningrouters_is_dirty)
|
||||||
|
runningrouters_is_dirty = now;
|
||||||
|
}
|
||||||
if (!the_v2_networkstatus_is_dirty)
|
if (!the_v2_networkstatus_is_dirty)
|
||||||
the_v2_networkstatus_is_dirty = now;
|
the_v2_networkstatus_is_dirty = now;
|
||||||
}
|
}
|
||||||
@ -953,8 +968,12 @@ dirserv_dump_directory_to_string(char **dir_out,
|
|||||||
tor_assert(dir_out);
|
tor_assert(dir_out);
|
||||||
*dir_out = NULL;
|
*dir_out = NULL;
|
||||||
|
|
||||||
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
if (list_server_status(rl->routers, &router_status, 0))
|
if (list_server_status(rl->routers, &router_status, 0))
|
||||||
return -1;
|
return -1;
|
||||||
|
#else
|
||||||
|
router_status = tor_strdup("");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
|
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
|
||||||
&identity_pkey_len)<0) {
|
&identity_pkey_len)<0) {
|
||||||
@ -969,9 +988,11 @@ dirserv_dump_directory_to_string(char **dir_out,
|
|||||||
|
|
||||||
buf_len = 2048+strlen(recommended_versions)+
|
buf_len = 2048+strlen(recommended_versions)+
|
||||||
strlen(router_status);
|
strlen(router_status);
|
||||||
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
|
||||||
if (complete || router_is_active(ri, now))
|
if (complete || router_is_active(ri, now))
|
||||||
buf_len += ri->cache_info.signed_descriptor_len+1);
|
buf_len += ri->cache_info.signed_descriptor_len+1);
|
||||||
|
#endif
|
||||||
buf = tor_malloc(buf_len);
|
buf = tor_malloc(buf_len);
|
||||||
/* We'll be comparing against buf_len throughout the rest of the
|
/* We'll be comparing against buf_len throughout the rest of the
|
||||||
function, though strictly speaking we shouldn't be able to exceed
|
function, though strictly speaking we shouldn't be able to exceed
|
||||||
@ -992,6 +1013,7 @@ dirserv_dump_directory_to_string(char **dir_out,
|
|||||||
tor_free(identity_pkey);
|
tor_free(identity_pkey);
|
||||||
|
|
||||||
cp = buf + strlen(buf);
|
cp = buf + strlen(buf);
|
||||||
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
|
SMARTLIST_FOREACH(rl->routers, routerinfo_t *, ri,
|
||||||
{
|
{
|
||||||
size_t len = ri->cache_info.signed_descriptor_len;
|
size_t len = ri->cache_info.signed_descriptor_len;
|
||||||
@ -1006,6 +1028,7 @@ dirserv_dump_directory_to_string(char **dir_out,
|
|||||||
*cp++ = '\n'; /* add an extra newline in case somebody was depending on
|
*cp++ = '\n'; /* add an extra newline in case somebody was depending on
|
||||||
* it. */
|
* it. */
|
||||||
});
|
});
|
||||||
|
#endif
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
/* These multiple strlcat calls are inefficient, but dwarfed by the RSA
|
/* These multiple strlcat calls are inefficient, but dwarfed by the RSA
|
||||||
@ -1360,9 +1383,13 @@ generate_runningrouters(void)
|
|||||||
size_t identity_pkey_len;
|
size_t identity_pkey_len;
|
||||||
routerlist_t *rl = router_get_routerlist();
|
routerlist_t *rl = router_get_routerlist();
|
||||||
|
|
||||||
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
if (list_server_status(rl->routers, &router_status, 0)) {
|
if (list_server_status(rl->routers, &router_status, 0)) {
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
router_status = tor_strdup("");
|
||||||
|
#endif
|
||||||
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
|
if (crypto_pk_write_public_key_to_string(private_key,&identity_pkey,
|
||||||
&identity_pkey_len)<0) {
|
&identity_pkey_len)<0) {
|
||||||
log_warn(LD_BUG,"write identity_pkey to string failed!");
|
log_warn(LD_BUG,"write identity_pkey to string failed!");
|
||||||
|
@ -954,7 +954,11 @@ run_scheduled_events(time_t now)
|
|||||||
ROUTER_PURPOSE_GENERAL, NULL, 1);
|
ROUTER_PURPOSE_GENERAL, NULL, 1);
|
||||||
}
|
}
|
||||||
/** How often do we (as a cache) fetch a new V1 runningrouters document? */
|
/** How often do we (as a cache) fetch a new V1 runningrouters document? */
|
||||||
|
#ifdef FULL_V1_DIRECTORIES
|
||||||
#define V1_RUNNINGROUTERS_FETCH_PERIOD (30*60)
|
#define V1_RUNNINGROUTERS_FETCH_PERIOD (30*60)
|
||||||
|
#else
|
||||||
|
#define V1_RUNNINGROUTERS_FETCH_PERIOD (6*60*60)
|
||||||
|
#endif
|
||||||
time_to_fetch_running_routers = now + V1_RUNNINGROUTERS_FETCH_PERIOD;
|
time_to_fetch_running_routers = now + V1_RUNNINGROUTERS_FETCH_PERIOD;
|
||||||
|
|
||||||
/* Also, take this chance to remove old information from rephist
|
/* Also, take this chance to remove old information from rephist
|
||||||
|
@ -154,6 +154,9 @@
|
|||||||
#define cell_t tor_cell_t
|
#define cell_t tor_cell_t
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/** Undefine this when it's time to stop generating v1 directories. */
|
||||||
|
#define FULL_V1_DIRECTORIES
|
||||||
|
|
||||||
/** Length of longest allowable configured nickname. */
|
/** Length of longest allowable configured nickname. */
|
||||||
#define MAX_NICKNAME_LEN 19
|
#define MAX_NICKNAME_LEN 19
|
||||||
/** Length of a router identity encoded as a hexadecimal digest, plus
|
/** Length of a router identity encoded as a hexadecimal digest, plus
|
||||||
|
Loading…
Reference in New Issue
Block a user