summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2004-09-27 06:00:43 +0000
committerRoger Dingledine <arma@torproject.org>2004-09-27 06:00:43 +0000
commita2517b4f0777c961843f3dc65107e9d3ce6b3846 (patch)
treebb62e7bf322540a7f0db52fd38e77248e46af0ab /src/or/routerparse.c
parenta64d0933396aa2eb52e23c82d4f6ae4f6b237187 (diff)
downloadtor-a2517b4f0777c961843f3dc65107e9d3ce6b3846.tar.gz
tor-a2517b4f0777c961843f3dc65107e9d3ce6b3846.zip
checking only 0.0.7 and 0.0.8 didn't work, because some dirservers
files have really old descriptors for the authdirservers, so we're asking them in the new format because they're too old. now we actually compare the version to a cutoff version, and act appropriately. also take this chance to use only >=0.0.8 servers for dns resolves, because of the recent bugs. we'll bump to >=0.0.9pre1 once there are some servers running that. svn:r2380
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index fdc34f205f..2b2c6dfce0 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1335,6 +1335,37 @@ static int router_get_hash_impl(const char *s, char *digest,
return 0;
}
+/** Parse the Tor version of the platform string <b>platform</b>,
+ * and compare it to the version in <b>cutoff</b>. Return 1 if
+ * the router is at least as new as the cutoff, else return 0.
+ */
+int tor_version_as_new_as(const char *platform, const char *cutoff) {
+ tor_version_t cutoff_version, router_version;
+ char *s, *start;
+ char tmp[128];
+
+ if(tor_version_parse(cutoff, &cutoff_version)<0) {
+ log_fn(LOG_WARN,"Bug: cutoff version '%s' unparsable.",cutoff);
+ return 0;
+ }
+ if(strcmpstart(platform,"Tor ")) /* nonstandard Tor; be safe and say yes */
+ return 1;
+
+ start = (char *)eat_whitespace(platform+3);
+ if (!*start) return 0;
+ s = (char *)find_whitespace(start); /* also finds '\0', which is fine */
+ if(s-start+1 >= sizeof(tmp)) /* too big, no */
+ return 0;
+ strlcpy(tmp, start, s-start+1);
+
+ if(tor_version_parse(tmp, &router_version)<0) {
+ log_fn(LOG_INFO,"Router version '%s' unparsable.",tmp);
+ return 1; /* be safe and say yes */
+ }
+
+ return tor_version_compare(&router_version, &cutoff_version) >= 0;
+}
+
int tor_version_parse(const char *s, tor_version_t *out)
{
char *eos=NULL, *cp=NULL;