mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 20:33:31 +01:00
Use correct logic to decide whether there are more directory servers to retry.
svn:r3257
This commit is contained in:
parent
65c4fa2614
commit
0c4186d6ee
@ -143,9 +143,12 @@ directory_post_to_dirservers(uint8_t purpose, const char *payload,
|
|||||||
* connection purpose 'purpose' requesting 'resource'. The purpose
|
* connection purpose 'purpose' requesting 'resource'. The purpose
|
||||||
* should be one of 'DIR_PURPOSE_FETCH_DIR',
|
* should be one of 'DIR_PURPOSE_FETCH_DIR',
|
||||||
* 'DIR_PURPOSE_FETCH_RENDDESC', 'DIR_PURPOSE_FETCH_RUNNING_LIST.'
|
* 'DIR_PURPOSE_FETCH_RENDDESC', 'DIR_PURPOSE_FETCH_RUNNING_LIST.'
|
||||||
|
* If <b>retry_if_no_servers</b>, then if all the possible servers seem
|
||||||
|
* down, mark them up and try again.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
directory_get_from_dirserver(uint8_t purpose, const char *resource)
|
directory_get_from_dirserver(uint8_t purpose, const char *resource,
|
||||||
|
int retry_if_no_servers)
|
||||||
{
|
{
|
||||||
routerinfo_t *r = NULL;
|
routerinfo_t *r = NULL;
|
||||||
trusted_dir_server_t *ds = NULL;
|
trusted_dir_server_t *ds = NULL;
|
||||||
@ -155,30 +158,34 @@ directory_get_from_dirserver(uint8_t purpose, const char *resource)
|
|||||||
purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
||||||
if (advertised_server_mode()) {
|
if (advertised_server_mode()) {
|
||||||
/* only ask authdirservers, and don't ask myself */
|
/* only ask authdirservers, and don't ask myself */
|
||||||
ds = router_pick_trusteddirserver(1, fascistfirewall);
|
ds = router_pick_trusteddirserver(1, fascistfirewall,
|
||||||
|
retry_if_no_servers);
|
||||||
} else {
|
} else {
|
||||||
/* anybody with a non-zero dirport will do */
|
/* anybody with a non-zero dirport will do */
|
||||||
r = router_pick_directory_server(1, fascistfirewall,
|
r = router_pick_directory_server(1, fascistfirewall,
|
||||||
purpose==DIR_PURPOSE_FETCH_RUNNING_LIST);
|
purpose==DIR_PURPOSE_FETCH_RUNNING_LIST,
|
||||||
|
retry_if_no_servers);
|
||||||
if (!r) {
|
if (!r) {
|
||||||
log_fn(LOG_INFO, "No router found for %s; falling back to dirserver list",
|
log_fn(LOG_INFO, "No router found for %s; falling back to dirserver list",
|
||||||
purpose == DIR_PURPOSE_FETCH_RUNNING_LIST
|
purpose == DIR_PURPOSE_FETCH_RUNNING_LIST
|
||||||
? "status list" : "directory");
|
? "status list" : "directory");
|
||||||
ds = router_pick_trusteddirserver(1, fascistfirewall);
|
ds = router_pick_trusteddirserver(1, fascistfirewall,
|
||||||
|
retry_if_no_servers);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
|
} else { // (purpose == DIR_PURPOSE_FETCH_RENDDESC)
|
||||||
/* only ask authdirservers, any of them will do */
|
/* only ask authdirservers, any of them will do */
|
||||||
/* Never use fascistfirewall; we're going via Tor. */
|
/* Never use fascistfirewall; we're going via Tor. */
|
||||||
ds = router_pick_trusteddirserver(0, 0);
|
ds = router_pick_trusteddirserver(0, 0, retry_if_no_servers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r)
|
if (r)
|
||||||
directory_initiate_command_router(r, purpose, resource, NULL, 0);
|
directory_initiate_command_router(r, purpose, resource, NULL, 0);
|
||||||
else if (ds)
|
else if (ds)
|
||||||
directory_initiate_command_trusted_dir(ds, purpose, resource, NULL, 0);
|
directory_initiate_command_trusted_dir(ds, purpose, resource, NULL, 0);
|
||||||
else
|
else {
|
||||||
log_fn(LOG_WARN,"No running dirservers known. Not trying. (purpose %d)", purpose);
|
log_fn(LOG_WARN,"No running dirservers known. Not trying. (purpose %d)", purpose);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Launch a new connection to the directory server <b>router</b> to upload or
|
/** Launch a new connection to the directory server <b>router</b> to upload or
|
||||||
@ -222,16 +229,9 @@ connection_dir_connect_failed(connection_t *conn)
|
|||||||
router_mark_as_down(conn->identity_digest); /* don't try him again */
|
router_mark_as_down(conn->identity_digest); /* don't try him again */
|
||||||
if (conn->purpose == DIR_PURPOSE_FETCH_DIR ||
|
if (conn->purpose == DIR_PURPOSE_FETCH_DIR ||
|
||||||
conn->purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
conn->purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
|
||||||
/* XXX This should possibly take into account that
|
log_fn(LOG_INFO, "Giving up on directory server at '%s'; retrying");
|
||||||
* !advertised_server_mode() allows us to use more directory
|
directory_get_from_dirserver(conn->purpose, NULL,
|
||||||
* servers, and fascistfirewall allows us to use less.
|
0 /* don't retry_if_no_servers */);
|
||||||
*/
|
|
||||||
if (!all_trusted_directory_servers_down()) {
|
|
||||||
log_fn(LOG_INFO,"Giving up on dirserver '%s'; trying another.", conn->address);
|
|
||||||
directory_get_from_dirserver(conn->purpose, NULL);
|
|
||||||
} else {
|
|
||||||
log_fn(LOG_INFO,"Giving up on dirserver '%s'; no more to try.", conn->address);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -605,7 +605,7 @@ static void run_scheduled_events(time_t now) {
|
|||||||
router_retry_connections();
|
router_retry_connections();
|
||||||
}
|
}
|
||||||
|
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL);
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
|
||||||
time_to_fetch_directory = now + options->DirFetchPeriod;
|
time_to_fetch_directory = now + options->DirFetchPeriod;
|
||||||
if (time_to_fetch_running_routers < now + options->StatusFetchPeriod) {
|
if (time_to_fetch_running_routers < now + options->StatusFetchPeriod) {
|
||||||
time_to_fetch_running_routers = now + options->StatusFetchPeriod;
|
time_to_fetch_running_routers = now + options->StatusFetchPeriod;
|
||||||
@ -617,7 +617,7 @@ static void run_scheduled_events(time_t now) {
|
|||||||
|
|
||||||
if (time_to_fetch_running_routers < now) {
|
if (time_to_fetch_running_routers < now) {
|
||||||
if (!authdir_mode(options)) {
|
if (!authdir_mode(options)) {
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL);
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RUNNING_LIST, NULL, 1);
|
||||||
}
|
}
|
||||||
time_to_fetch_running_routers = now + options->StatusFetchPeriod;
|
time_to_fetch_running_routers = now + options->StatusFetchPeriod;
|
||||||
}
|
}
|
||||||
@ -779,7 +779,7 @@ static int do_hup(void) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Fetch a new directory. Even authdirservers do this. */
|
/* Fetch a new directory. Even authdirservers do this. */
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL);
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
|
||||||
if (server_mode(options)) {
|
if (server_mode(options)) {
|
||||||
/* Restart cpuworker and dnsworker processes, so they get up-to-date
|
/* Restart cpuworker and dnsworker processes, so they get up-to-date
|
||||||
* configuration options. */
|
* configuration options. */
|
||||||
|
14
src/or/or.h
14
src/or/or.h
@ -1313,12 +1313,13 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type,
|
|||||||
int dir_policy_permits_address(uint32_t addr);
|
int dir_policy_permits_address(uint32_t addr);
|
||||||
void directory_post_to_dirservers(uint8_t purpose, const char *payload,
|
void directory_post_to_dirservers(uint8_t purpose, const char *payload,
|
||||||
size_t payload_len);
|
size_t payload_len);
|
||||||
void directory_get_from_dirserver(uint8_t purpose, const char *resource);
|
void directory_get_from_dirserver(uint8_t purpose, const char *resource,
|
||||||
|
int retry_if_no_servers);
|
||||||
int connection_dir_reached_eof(connection_t *conn);
|
int connection_dir_reached_eof(connection_t *conn);
|
||||||
int connection_dir_process_inbuf(connection_t *conn);
|
int connection_dir_process_inbuf(connection_t *conn);
|
||||||
int connection_dir_finished_flushing(connection_t *conn);
|
int connection_dir_finished_flushing(connection_t *conn);
|
||||||
int connection_dir_finished_connecting(connection_t *conn);
|
int connection_dir_finished_connecting(connection_t *conn);
|
||||||
int connection_dir_failed(connection_t *conn);
|
int connection_dir_connect_failed(connection_t *conn);
|
||||||
void parse_dir_policy(void);
|
void parse_dir_policy(void);
|
||||||
|
|
||||||
/********************************* dirserv.c ***************************/
|
/********************************* dirserv.c ***************************/
|
||||||
@ -1571,8 +1572,13 @@ typedef struct trusted_dir_server_t {
|
|||||||
|
|
||||||
int router_reload_router_list(void);
|
int router_reload_router_list(void);
|
||||||
void router_get_trusted_dir_servers(smartlist_t **outp);
|
void router_get_trusted_dir_servers(smartlist_t **outp);
|
||||||
routerinfo_t *router_pick_directory_server(int requireothers, int fascistfirewall, int for_running_routers);
|
routerinfo_t *router_pick_directory_server(int requireothers,
|
||||||
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers, int fascistfirewall);
|
int fascistfirewall,
|
||||||
|
int for_running_routers,
|
||||||
|
int retry_if_no_servers);
|
||||||
|
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers,
|
||||||
|
int fascistfirewall,
|
||||||
|
int retry_if_no_servers);
|
||||||
int all_trusted_directory_servers_down(void);
|
int all_trusted_directory_servers_down(void);
|
||||||
struct smartlist_t;
|
struct smartlist_t;
|
||||||
void routerlist_add_family(struct smartlist_t *sl, routerinfo_t *router);
|
void routerlist_add_family(struct smartlist_t *sl, routerinfo_t *router);
|
||||||
|
@ -250,7 +250,7 @@ rend_client_refetch_renddesc(const char *query)
|
|||||||
log_fn(LOG_INFO,"Would fetch a new renddesc here (for %s), but one is already in progress.", query);
|
log_fn(LOG_INFO,"Would fetch a new renddesc here (for %s), but one is already in progress.", query);
|
||||||
} else {
|
} else {
|
||||||
/* not one already; initiate a dir rend desc lookup */
|
/* not one already; initiate a dir rend desc lookup */
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RENDDESC, query);
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_RENDDESC, query, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,8 @@ void router_get_trusted_dir_servers(smartlist_t **outp)
|
|||||||
*/
|
*/
|
||||||
routerinfo_t *router_pick_directory_server(int requireothers,
|
routerinfo_t *router_pick_directory_server(int requireothers,
|
||||||
int fascistfirewall,
|
int fascistfirewall,
|
||||||
int for_runningrouters) {
|
int for_runningrouters,
|
||||||
|
int retry_if_no_servers) {
|
||||||
routerinfo_t *choice;
|
routerinfo_t *choice;
|
||||||
|
|
||||||
if (!routerlist)
|
if (!routerlist)
|
||||||
@ -103,7 +104,7 @@ routerinfo_t *router_pick_directory_server(int requireothers,
|
|||||||
|
|
||||||
choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
|
choice = router_pick_directory_server_impl(requireothers, fascistfirewall,
|
||||||
for_runningrouters);
|
for_runningrouters);
|
||||||
if (choice)
|
if (choice || !retry_if_no_servers)
|
||||||
return choice;
|
return choice;
|
||||||
|
|
||||||
log_fn(LOG_INFO,"No reachable router entries for dirservers. Trying them all again.");
|
log_fn(LOG_INFO,"No reachable router entries for dirservers. Trying them all again.");
|
||||||
@ -128,11 +129,12 @@ routerinfo_t *router_pick_directory_server(int requireothers,
|
|||||||
}
|
}
|
||||||
|
|
||||||
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers,
|
trusted_dir_server_t *router_pick_trusteddirserver(int requireothers,
|
||||||
int fascistfirewall) {
|
int fascistfirewall,
|
||||||
|
int retry_if_no_servers) {
|
||||||
trusted_dir_server_t *choice;
|
trusted_dir_server_t *choice;
|
||||||
|
|
||||||
choice = router_pick_trusteddirserver_impl(requireothers, fascistfirewall);
|
choice = router_pick_trusteddirserver_impl(requireothers, fascistfirewall);
|
||||||
if (choice)
|
if (choice || !retry_if_no_servers)
|
||||||
return choice;
|
return choice;
|
||||||
|
|
||||||
log_fn(LOG_INFO,"No trusted dirservers are reachable. Trying them all again.");
|
log_fn(LOG_INFO,"No trusted dirservers are reachable. Trying them all again.");
|
||||||
|
Loading…
Reference in New Issue
Block a user