Only check versions against downloaded directories, not cached directories.

svn:r2413
This commit is contained in:
Nick Mathewson 2004-10-03 02:37:52 +00:00
parent 5e74ce8d57
commit 9e8ae9766e
6 changed files with 16 additions and 10 deletions

View File

@ -445,7 +445,7 @@ connection_dir_client_reached_eof(connection_t *conn)
tor_free(body); tor_free(headers);
return -1;
}
if(router_load_routerlist_from_directory(body, NULL) < 0){
if(router_load_routerlist_from_directory(body, NULL, 1) < 0){
log_fn(LOG_WARN,"I failed to parse the directory I fetched from %s:%d. Ignoring.", conn->address, conn->port);
} else {
log_fn(LOG_INFO,"updated routers.");

View File

@ -742,7 +742,7 @@ static int dirserv_regenerate_directory(void)
* necessary, but safe is better than sorry. */
new_directory = tor_strdup(the_directory);
/* use a new copy of the dir, since get_dir_from_string scribbles on it */
if (router_load_routerlist_from_directory(new_directory, get_identity_key())) {
if (router_load_routerlist_from_directory(new_directory, get_identity_key(), 1)) {
log_fn(LOG_ERR, "We just generated a directory we can't parse. Dying.");
tor_cleanup();
exit(0);

View File

@ -1420,7 +1420,8 @@ void router_mark_as_down(const char *digest);
void routerlist_remove_old_routers(int age);
int router_load_routerlist_from_file(char *routerfile, int trusted);
int router_load_routerlist_from_string(const char *s, int trusted);
int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey);
int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey,
int check_version);
int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
struct exit_policy_t *policy);
#define ADDR_POLICY_ACCEPTED 0
@ -1455,7 +1456,8 @@ int router_parse_list_from_string(const char **s,
time_t published);
int router_parse_routerlist_from_directory(const char *s,
routerlist_t **dest,
crypto_pk_env_t *pkey);
crypto_pk_env_t *pkey,
int check_version);
running_routers_t *router_parse_runningrouters(const char *str);
routerinfo_t *router_parse_entry_from_string(const char *s, const char *end);
int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);

View File

@ -65,7 +65,7 @@ int router_reload_router_list(void)
s = read_file_to_str(filename,0);
if (s) {
log_fn(LOG_INFO, "Loading cached directory from %s", filename);
if (router_load_routerlist_from_directory(s, NULL) < 0) {
if (router_load_routerlist_from_directory(s, NULL, 0) < 0) {
log_fn(LOG_WARN, "Cached directory '%s' was unparseable; ignoring.", filename);
}
if(routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) {
@ -793,10 +793,12 @@ int router_load_routerlist_from_string(const char *s, int trusted)
* signed directory <b>s</b>. If pkey is provided, check the signature against
* pkey; else check against the pkey of the signing directory server. */
int router_load_routerlist_from_directory(const char *s,
crypto_pk_env_t *pkey)
crypto_pk_env_t *pkey,
int check_version)
{
routerlist_t *new_list = NULL;
if (router_parse_routerlist_from_directory(s, &new_list, pkey)) {
if (router_parse_routerlist_from_directory(s, &new_list, pkey,
check_version)) {
log_fn(LOG_WARN, "Couldn't parse directory.");
return -1;
}

View File

@ -285,7 +285,8 @@ int check_software_version_against_directory(const char *directory,
int /* Should be static; exposed for unit tests */
router_parse_routerlist_from_directory(const char *str,
routerlist_t **dest,
crypto_pk_env_t *pkey)
crypto_pk_env_t *pkey,
int check_version)
{
directory_token_t *tok;
char digest[DIGEST_LEN];
@ -335,7 +336,8 @@ router_parse_routerlist_from_directory(const char *str,
tokens = NULL;
/* Now that we know the signature is okay, check the version. */
check_software_version_against_directory(str, options.IgnoreVersion);
if (check_version)
check_software_version_against_directory(str, options.IgnoreVersion);
/* Now try to parse the first part of the directory. */
if ((end = strstr(str,"\nrouter "))) {

View File

@ -968,7 +968,7 @@ test_dir_format()
options.Nickname = "DirServer";
test_assert(!dirserv_dump_directory_to_string(buf,8192,pk3));
cp = buf;
test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3));
test_assert(!router_parse_routerlist_from_directory(buf, &dir1, pk3, 1));
test_eq(2, smartlist_len(dir1->routers));
dirserv_free_fingerprint_list();