mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
cleanups on 008pre1 items
svn:r1993
This commit is contained in:
parent
29818d5b6b
commit
f42f04c859
@ -80,6 +80,9 @@ void
|
|||||||
directory_get_from_dirserver(uint8_t purpose, const char *payload,
|
directory_get_from_dirserver(uint8_t purpose, const char *payload,
|
||||||
int payload_len)
|
int payload_len)
|
||||||
{
|
{
|
||||||
|
/* FFFF we might pass pick_directory_server a boolean to prefer
|
||||||
|
* picking myself for some purposes, or prefer picking not myself
|
||||||
|
* for other purposes. */
|
||||||
directory_initiate_command(router_pick_directory_server(),
|
directory_initiate_command(router_pick_directory_server(),
|
||||||
purpose, payload, payload_len);
|
purpose, payload, payload_len);
|
||||||
}
|
}
|
||||||
@ -498,6 +501,10 @@ directory_handle_command_get(connection_t *conn, char *headers,
|
|||||||
|
|
||||||
if(!strcmp(url,"/running-routers")) { /* running-routers fetch */
|
if(!strcmp(url,"/running-routers")) { /* running-routers fetch */
|
||||||
dlen = dirserv_get_runningrouters(&cp);
|
dlen = dirserv_get_runningrouters(&cp);
|
||||||
|
if(dlen < 0) { /* we failed to create cp */
|
||||||
|
connection_write_to_buf(answer503, strlen(answer503), conn);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nContent-Length: %d\r\nContent-Type: text/plain\r\n\r\n",
|
snprintf(tmp, sizeof(tmp), "HTTP/1.0 200 OK\r\nContent-Length: %d\r\nContent-Type: text/plain\r\n\r\n",
|
||||||
(int)dlen);
|
(int)dlen);
|
||||||
|
@ -455,6 +455,7 @@ list_running_servers(char **nicknames_out)
|
|||||||
continue; /* only list successfully handshaked OR's. */
|
continue; /* only list successfully handshaked OR's. */
|
||||||
if(!conn->nickname) /* it's an OP, don't list it */
|
if(!conn->nickname) /* it's an OP, don't list it */
|
||||||
continue;
|
continue;
|
||||||
|
/* XXX008 need to change this to list "!nickname" for down routers */
|
||||||
if (!router_nickname_is_approved(conn->nickname))
|
if (!router_nickname_is_approved(conn->nickname))
|
||||||
continue; /* If we removed them from the approved list, don't list it.*/
|
continue; /* If we removed them from the approved list, don't list it.*/
|
||||||
smartlist_add(nicknames, conn->nickname);
|
smartlist_add(nicknames, conn->nickname);
|
||||||
@ -580,7 +581,7 @@ dirserv_dump_directory_to_string(char *s, unsigned int maxlen,
|
|||||||
/** Most recently generated encoded signed directory. */
|
/** Most recently generated encoded signed directory. */
|
||||||
static char *the_directory = NULL;
|
static char *the_directory = NULL;
|
||||||
static int the_directory_len = -1;
|
static int the_directory_len = -1;
|
||||||
static char *cached_directory = NULL;
|
static char *cached_directory = NULL; /* used only by non-auth dirservers */
|
||||||
static time_t cached_directory_published = 0;
|
static time_t cached_directory_published = 0;
|
||||||
static int cached_directory_len = -1;
|
static int cached_directory_len = -1;
|
||||||
|
|
||||||
@ -588,8 +589,7 @@ void dirserv_set_cached_directory(const char *directory, time_t when)
|
|||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
char filename[512];
|
char filename[512];
|
||||||
if (!options.AuthoritativeDir)
|
tor_assert(!options.AuthoritativeDir);
|
||||||
return;
|
|
||||||
now = time(NULL);
|
now = time(NULL);
|
||||||
if (when>cached_directory_published &&
|
if (when>cached_directory_published &&
|
||||||
when<now+ROUTER_ALLOW_SKEW) {
|
when<now+ROUTER_ALLOW_SKEW) {
|
||||||
|
@ -451,18 +451,14 @@ static void run_scheduled_events(time_t now) {
|
|||||||
router_rebuild_descriptor();
|
router_rebuild_descriptor();
|
||||||
router_upload_dir_desc_to_dirservers();
|
router_upload_dir_desc_to_dirservers();
|
||||||
}
|
}
|
||||||
if(!options.DirPort || !options.AuthoritativeDir) {
|
|
||||||
/* XXXX should directories do this next part too? */
|
|
||||||
routerlist_remove_old_routers(); /* purge obsolete entries */
|
routerlist_remove_old_routers(); /* purge obsolete entries */
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
|
if(options.AuthoritativeDir) {
|
||||||
} else {
|
|
||||||
/* We're a directory; dump any old descriptors. */
|
/* We're a directory; dump any old descriptors. */
|
||||||
dirserv_remove_old_servers();
|
dirserv_remove_old_servers();
|
||||||
/* dirservers try to reconnect too, in case connections have failed */
|
/* dirservers try to reconnect too, in case connections have failed */
|
||||||
router_retry_connections();
|
router_retry_connections();
|
||||||
/* fetch another directory, in case it knows something we don't */
|
|
||||||
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
|
|
||||||
}
|
}
|
||||||
|
directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 0);
|
||||||
/* Force an upload of our descriptors every DirFetchPostPeriod seconds. */
|
/* Force an upload of our descriptors every DirFetchPostPeriod seconds. */
|
||||||
rend_services_upload(1);
|
rend_services_upload(1);
|
||||||
last_uploaded_services = now;
|
last_uploaded_services = now;
|
||||||
|
@ -285,14 +285,16 @@ int init_keys(void) {
|
|||||||
if(!cp) {
|
if(!cp) {
|
||||||
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
|
log_fn(LOG_INFO,"Cached directory %s not present. Ok.",keydir);
|
||||||
} else {
|
} else {
|
||||||
if(options.AuthoritativeDir && dirserv_load_from_directory_string(cp) < 0){
|
if(options.AuthoritativeDir)
|
||||||
|
if(dirserv_load_from_directory_string(cp) < 0){
|
||||||
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
|
log_fn(LOG_ERR, "Cached directory %s is corrupt", keydir);
|
||||||
tor_free(cp);
|
tor_free(cp);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* set time to 1 so it will be replaced on first download.
|
} else {
|
||||||
*/
|
/* set time to 1 so it will be replaced on first download. */
|
||||||
dirserv_set_cached_directory(cp, 1);
|
dirserv_set_cached_directory(cp, 1);
|
||||||
|
}
|
||||||
tor_free(cp);
|
tor_free(cp);
|
||||||
}
|
}
|
||||||
/* success */
|
/* success */
|
||||||
|
@ -477,11 +477,13 @@ int router_load_routerlist_from_directory(const char *s,
|
|||||||
log_fn(LOG_WARN, "Error resolving routerlist");
|
log_fn(LOG_WARN, "Error resolving routerlist");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Remember the directory, if we're nonauthoritative.*/
|
if (options.AuthoritativeDir) {
|
||||||
dirserv_set_cached_directory(s, routerlist->published_on);
|
/* Learn about the descriptors in the directory. */
|
||||||
/* Learn about the descriptors in the directory, if we're authoritative */
|
|
||||||
if (options.AuthoritativeDir)
|
|
||||||
dirserv_load_from_directory_string(s);
|
dirserv_load_from_directory_string(s);
|
||||||
|
} else {
|
||||||
|
/* Remember the directory. */
|
||||||
|
dirserv_set_cached_directory(s, routerlist->published_on);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -657,16 +659,17 @@ void routerlist_update_from_runningrouters(routerlist_t *list,
|
|||||||
router = smartlist_get(list->routers, i);
|
router = smartlist_get(list->routers, i);
|
||||||
for (j=0; j<n_names; ++j) {
|
for (j=0; j<n_names; ++j) {
|
||||||
name = smartlist_get(rr->running_routers, j);
|
name = smartlist_get(rr->running_routers, j);
|
||||||
if (!strcmp(name, router->nickname)) {
|
if (!strcasecmp(name, router->nickname)) {
|
||||||
running=1;
|
router->is_running = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (*name == '!' && strcasecmp(name+1, router->nickname)) {
|
||||||
|
router->is_running = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
router->is_running = 1; /* arma: is this correct? */
|
|
||||||
}
|
}
|
||||||
list->running_routers_updated_on = rr->published_on;
|
list->running_routers_updated_on = rr->published_on;
|
||||||
/* XXXX008 Should there also be a list of which are down, so that we
|
|
||||||
* don't mark merely unknown routers as down? */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user