aboutsummaryrefslogtreecommitdiff
path: root/src/or
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-10-03 02:37:52 +0000
committerNick Mathewson <nickm@torproject.org>2004-10-03 02:37:52 +0000
commit9e8ae9766e5d4eb94972f2e7118ce8e9c2e09381 (patch)
tree0f3716d7dcda024edbec69a67827609dfe19299d /src/or
parent5e74ce8d57e0de041480db99ffb11c4a90249355 (diff)
downloadtor-9e8ae9766e5d4eb94972f2e7118ce8e9c2e09381.tar
tor-9e8ae9766e5d4eb94972f2e7118ce8e9c2e09381.tar.gz
Only check versions against downloaded directories, not cached directories.
svn:r2413
Diffstat (limited to 'src/or')
-rw-r--r--src/or/directory.c2
-rw-r--r--src/or/dirserv.c2
-rw-r--r--src/or/or.h6
-rw-r--r--src/or/routerlist.c8
-rw-r--r--src/or/routerparse.c6
-rw-r--r--src/or/test.c2
6 files changed, 16 insertions, 10 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index f6995305f..c505d9252 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -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.");
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index 8158e6aed..a0eaf28ac 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -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);
diff --git a/src/or/or.h b/src/or/or.h
index eba01b8e6..5c14e4d69 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -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);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 7f8261595..f0756b3e0 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -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;
}
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 773340dea..52076ff1f 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -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 "))) {
diff --git a/src/or/test.c b/src/or/test.c
index f09399144..2482f3028 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -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();