diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-10-27 00:48:51 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-10-27 00:48:51 +0000 |
commit | b90b2bb848cbbfbc7babda6498e014b687704c29 (patch) | |
tree | 7d94fe9a64882b242064d40e990d4d82a5874497 /src/or/routerparse.c | |
parent | 26f3cb865202160fe6b8ecfb20a0e41fea3a4a6a (diff) | |
download | tor-b90b2bb848cbbfbc7babda6498e014b687704c29.tar.gz tor-b90b2bb848cbbfbc7babda6498e014b687704c29.zip |
Add and document router-status line using new unified liveness/verifiedness format; continue to generate running-routers; continue to parse running-routers when no router-status line is found
svn:r2592
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 476c8af989..6d3ad66506 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -32,6 +32,7 @@ typedef enum { K_ROUTER_SIGNATURE, K_PUBLISHED, K_RUNNING_ROUTERS, + K_ROUTER_STATUS, K_PLATFORM, K_OPT, K_BANDWIDTH, @@ -106,6 +107,7 @@ static struct { { "onion-key", K_ONION_KEY, NO_ARGS, NEED_KEY,RTR_ONLY }, { "router-signature", K_ROUTER_SIGNATURE, NO_ARGS, NEED_OBJ,RTR_ONLY }, { "running-routers", K_RUNNING_ROUTERS, ARGS, NO_OBJ, DIR_ONLY }, + { "router-status", K_ROUTER_STATUS, ARGS, NO_OBJ, DIR_ONLY }, { "ports", K_PORTS, ARGS, NO_OBJ, RTR_ONLY }, { "bandwidth", K_BANDWIDTH, ARGS, NO_OBJ, RTR_ONLY }, { "platform", K_PLATFORM, CONCAT_ARGS, NO_OBJ, RTR_ONLY }, @@ -393,9 +395,13 @@ router_parse_routerlist_from_directory(const char *str, } versions = tok->n_args ? tor_strdup(tok->args[0]) : tor_strdup(""); - if (!(tok = find_first_by_keyword(tokens, K_RUNNING_ROUTERS))) { - log_fn(LOG_WARN, "Missing running-routers line from directory."); - goto err; + /* Prefer router-status, then running-routers. */ + if (!(tok = find_first_by_keyword(tokens, K_ROUTER_STATUS))) { + if (!(tok = find_first_by_keyword(tokens, K_RUNNING_ROUTERS))) { + log_fn(LOG_WARN, + "Missing running-routers/router-status line from directory."); + goto err; + } } good_nickname_list = smartlist_create(); @@ -408,25 +414,21 @@ router_parse_routerlist_from_directory(const char *str, * router. */ str = end; if (router_parse_list_from_string(&str, &new_dir, - good_nickname_list, published_on)) { + good_nickname_list, + tok->tp==K_RUNNING_ROUTERS, + published_on)) { log_fn(LOG_WARN, "Error reading routers from directory"); goto err; } - new_dir->software_versions = versions; versions = NULL; - new_dir->published_on = published_on; - - SMARTLIST_FOREACH(tokens, directory_token_t *, tok, token_free(tok)); - smartlist_free(tokens); - tokens = NULL; - /* Determine if my routerinfo is considered verified. */ { static int have_warned_about_unverified_status = 0; routerinfo_t *me = router_get_my_routerinfo(); if(me) { if(router_update_status_from_smartlist(me, published_on, - good_nickname_list)==1 && + good_nickname_list, + tok->tp==K_RUNNING_ROUTERS)==1 && me->is_verified == 0 && !have_warned_about_unverified_status) { log_fn(LOG_WARN,"Dirserver %s lists your server as unverified. Please consider sending your identity fingerprint to the tor-ops.", dirnickname); have_warned_about_unverified_status = 1; @@ -434,6 +436,13 @@ router_parse_routerlist_from_directory(const char *str, } } + new_dir->software_versions = versions; versions = NULL; + new_dir->published_on = published_on; + + SMARTLIST_FOREACH(tokens, directory_token_t *, tok, token_free(tok)); + smartlist_free(tokens); + tokens = NULL; + if (*dest) routerlist_free(*dest); *dest = new_dir; @@ -497,14 +506,18 @@ router_parse_runningrouters(const char *str) goto err; } - if (!(tok = find_first_by_keyword(tokens, K_RUNNING_ROUTERS))) { - log_fn(LOG_WARN, "Missing running-routers line from directory."); - goto err; + if (!(tok = find_first_by_keyword(tokens, K_ROUTER_STATUS))) { + if (!(tok = find_first_by_keyword(tokens, K_RUNNING_ROUTERS))) { + log_fn(LOG_WARN, + "Missing running-routers/router-status line from directory."); + goto err; + } } new_list = tor_malloc_zero(sizeof(running_routers_t)); new_list->published_on = published_on; new_list->running_routers = smartlist_create(); + new_list->is_running_routers_format = (tok->tp == K_RUNNING_ROUTERS); for (i=0;i<tok->n_args;++i) { smartlist_add(new_list->running_routers, tok->args[i]); } @@ -661,7 +674,7 @@ static int check_directory_signature(const char *digest, int router_parse_list_from_string(const char **s, routerlist_t **dest, smartlist_t *good_nickname_list, - time_t published_on) + int rr_format, time_t published_on) { routerinfo_t *router; smartlist_t *routers; @@ -692,10 +705,7 @@ router_parse_list_from_string(const char **s, routerlist_t **dest, continue; } - if (good_nickname_list) { - router_update_status_from_smartlist(router, published_on, - good_nickname_list); - } else { + if (!good_nickname_list) { router->is_running = 1; /* start out assuming all dirservers are up */ router->is_verified = 1; router->status_set_at = time(NULL); @@ -704,6 +714,12 @@ router_parse_list_from_string(const char **s, routerlist_t **dest, log_fn(LOG_DEBUG,"just added router #%d.",smartlist_len(routers)); } + if (good_nickname_list) { + SMARTLIST_FOREACH(good_nickname_list, const char *, cp, + routers_update_status_from_entry(routers, published_on, + cp, rr_format)); + } + if (*dest) routerlist_free(*dest); *dest = tor_malloc_zero(sizeof(routerlist_t)); |