diff options
author | Nick Mathewson <nickm@torproject.org> | 2015-01-09 11:36:47 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2015-01-10 15:09:07 -0500 |
commit | c83d83814660b643b705ed7de4aa1fc35e2d20ad (patch) | |
tree | a40e8125e82391e69a16cac1ee73061243d00017 /src/or/dirserv.c | |
parent | 33df3e37ffecfed309a1a0f210a96620c0ebb837 (diff) | |
download | tor-c83d83814660b643b705ed7de4aa1fc35e2d20ad.tar.gz tor-c83d83814660b643b705ed7de4aa1fc35e2d20ad.zip |
Implement proposal 227-vote-on-package-fingerprints.txt
This implementation includes tests and a little documentation.
Diffstat (limited to 'src/or/dirserv.c')
-rw-r--r-- | src/or/dirserv.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index d668749c5b..dbdfff1440 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -2504,6 +2504,15 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key, v3_out->client_versions = client_versions; v3_out->server_versions = server_versions; + v3_out->package_lines = smartlist_new(); + { + config_line_t *cl; + for (cl = get_options()->RecommendedPackages; cl; cl = cl->next) { + if (validate_recommended_package_line(cl->value)) + smartlist_add(v3_out->package_lines, tor_strdup(cl->value)); + } + } + v3_out->known_flags = smartlist_new(); smartlist_split_string(v3_out->known_flags, "Authority Exit Fast Guard Stable V2Dir Valid", @@ -3249,6 +3258,48 @@ connection_dirserv_flushed_some(dir_connection_t *conn) } } +/** Return true iff <b>line</b> is a valid recommened_packages line. + */ +int +validate_recommended_package_line(const char *line) +{ + const char *cp = line; + +#define WORD() \ + do { \ + if (*cp == ' ') \ + return 0; \ + cp = strchr(cp, ' '); \ + if (!cp) \ + return 0; \ + } while (0) + + WORD(); /* skip packagename */ + ++cp; + WORD(); /* skip version */ + ++cp; + WORD(); /* Skip URL */ + ++cp; + + /* Skip digestname=digestval + */ + int foundeq = 0; + while (*cp) { + if (*cp == ' ') { + if (!foundeq) + return 0; + foundeq = 0; + } else if (*cp == '=') { + if (++foundeq > 1) + return 0; + } + ++cp; + } + + if (!foundeq) + return 0; + return 1; +} + /** Release all storage used by the directory server. */ void dirserv_free_all(void) |