aboutsummaryrefslogtreecommitdiff
path: root/src/or/routers.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2003-08-23 10:09:25 +0000
committerRoger Dingledine <arma@torproject.org>2003-08-23 10:09:25 +0000
commit36f055e7ee7975fa6982cdfef8409b7a303166c5 (patch)
tree25c71ce947f9079be7fa2c55e5d0c9eef7a7cb34 /src/or/routers.c
parent33b0569fba5a098e3aa25c50397ca59a0d63bb4a (diff)
downloadtor-36f055e7ee7975fa6982cdfef8409b7a303166c5.tar
tor-36f055e7ee7975fa6982cdfef8409b7a303166c5.tar.gz
start honoring the recommended_versions string
your client exits if you're running a version not in the directory's list of acceptable versions (unless you have a config variable set to override). svn:r408
Diffstat (limited to 'src/or/routers.c')
-rw-r--r--src/or/routers.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/or/routers.c b/src/or/routers.c
index 4ed858732..c6e4d1012 100644
--- a/src/or/routers.c
+++ b/src/or/routers.c
@@ -168,6 +168,7 @@ void directory_free(directory_t *directory)
for (i = 0; i < directory->n_routers; ++i)
routerinfo_free(directory->routers[i]);
free(directory->routers);
+ /* XXX are we leaking directory->software_versions here? */
free(directory);
}
@@ -506,6 +507,25 @@ static int router_get_dir_hash(char *s, char *digest)
return 0;
}
+/* return 0 if myversion is in start. Else return -1. */
+int compare_recommended_versions(char *myversion, char *start) {
+ int len_myversion = strlen(myversion);
+ char *comma;
+ char *end = start + strlen(start);
+
+ log_fn(LOG_DEBUG,"checking '%s' in '%s'.", myversion, start);
+
+ for(;;) {
+ comma = strchr(start, ',');
+ if( ((comma ? comma : end) - start == len_myversion) &&
+ !strncmp(start, myversion, len_myversion)) /* only do strncmp if the length matches */
+ return 0; /* success, it's there */
+ if(!comma)
+ return -1; /* nope */
+ start = comma+1;
+ }
+}
+
int router_get_dir_from_string(char *s, crypto_pk_env_t *pkey)
{
if (router_get_dir_from_string_impl(s, &directory, pkey)) {
@@ -516,7 +536,17 @@ int router_get_dir_from_string(char *s, crypto_pk_env_t *pkey)
log(LOG_ERR, "Error resolving directory");
return -1;
}
- /* XXXX Check version number */
+ if (compare_recommended_versions(VERSION, directory->software_versions) < 0) {
+ log(LOG_ERR, "You are running tor version %s, which is no longer supported.\nPlease upgrade to one of %s.", VERSION, RECOMMENDED_SOFTWARE_VERSIONS);
+ if(options.IgnoreVersion) {
+ log(LOG_WARNING, "IgnoreVersion is set. If it breaks, we told you so.");
+ } else {
+ log(LOG_ERR,"Set IgnoreVersion config variable if you want to survive this error.");
+ fflush(0);
+ exit(0);
+ }
+ }
+
return 0;
}