aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerlist.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r--src/or/routerlist.c257
1 files changed, 0 insertions, 257 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 1cfec6ff5..9b6006694 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -923,16 +923,6 @@ router_get_routerlist(routerlist_t **prouterlist)
*prouterlist = routerlist;
}
-#if 0
-/** Return the publication time on the current routerlist, or 0 if we have no
- * routerlist. */
-time_t
-routerlist_get_published_time(void)
-{
- return routerlist ? routerlist->published_on : 0;
-}
-#endif
-
/** Free all storage held by <b>router</b>. */
void
routerinfo_free(routerinfo_t *router)
@@ -1262,14 +1252,6 @@ router_load_single_router(const char *s, const char **msg)
routerinfo_free(ri);
return 0;
}
-#if 0
- if (routerlist && routerlist->running_routers) {
- running_routers_t *rr = routerlist->running_routers;
- router_update_status_from_smartlist(ri,
- rr->published_on,
- rr->running_routers);
- }
-#endif
/* XXXX011 update router status from networkstatus!! */
if (router_add_to_routerlist(ri, msg, 0)<0) {
@@ -1337,55 +1319,6 @@ router_load_routers_from_string(const char *s, int from_cache,
smartlist_free(changed);
}
-#if 0
-/** Add to the current routerlist each router stored in the
- * signed directory <b>s</b>. If pkey is provided, check the signature
- * against pkey; else check against the pkey of the signing directory
- * server.
- *
- * If <b>dir_is_recent</b> is non-zero, then examine the
- * Recommended-versions line and take appropriate action.
- *
- * If <b>dir_is_cached</b> is non-zero, then we're reading it
- * from the cache so don't bother to re-write it to the cache.
- */
-int
-router_load_routerlist_from_directory(const char *s,
- crypto_pk_env_t *pkey,
- int dir_is_recent,
- int dir_is_cached)
-{
- routerlist_t *new_list = NULL;
- if (router_parse_routerlist_from_directory(s, &new_list, pkey,
- dir_is_recent,
- !dir_is_cached)) {
- log_fn(LOG_WARN, "Couldn't parse directory.");
- return -1;
- }
- if (routerlist) {
- /* Merge the new_list into routerlist, then free new_list. Also
- * keep a list of changed descriptors to inform controllers. */
- smartlist_t *changed = smartlist_create();
- SMARTLIST_FOREACH(new_list->routers, routerinfo_t *, r,
- {
- const char *msg;
- if (router_add_to_routerlist(r,&msg,0)>=0)
- smartlist_add(changed, r);
- });
- smartlist_clear(new_list->routers);
- routerlist->published_on_xx = new_list->published_on_xx;
- routerlist_free(new_list);
- control_event_descriptors_changed(changed);
- smartlist_free(changed);
- } else {
- routerlist = new_list;
- control_event_descriptors_changed(routerlist->routers);
- }
- router_normalize_routerlist(routerlist);
- return 0;
-}
-#endif
-
/** Helper: return a newly allocated string containing the name of the filename
* where we plan to cache <b>ns</b>. */
static char *
@@ -1964,196 +1897,6 @@ router_exit_policy_rejects_all(routerinfo_t *router)
== ADDR_POLICY_REJECTED;
}
-#if 0
-/** Release all space held in <b>rr</b>. */
-void
-running_routers_free(running_routers_t *rr)
-{
- if (!rr)
- return;
- if (rr->running_routers) {
- SMARTLIST_FOREACH(rr->running_routers, char *, s, tor_free(s));
- smartlist_free(rr->running_routers);
- }
- tor_free(rr);
-}
-
-/** Update the running/not-running status of every router in <b>list</b>, based
- * on the contents of <b>rr</b>. */
-static void
-routerlist_update_from_runningrouters(routerlist_t *list,
- running_routers_t *rr)
-{
- routerinfo_t *me = router_get_my_routerinfo();
- smartlist_t *all_routers;
- if (!list)
- return;
- if (list->published_on >= rr->published_on)
- return;
- if (list->running_routers_updated_on >= rr->published_on)
- return;
-
- all_routers = smartlist_create();
- if (me) /* learn if the dirservers think I'm verified */
- smartlist_add(all_routers, me);
-
- smartlist_add_all(all_routers,list->routers);
- SMARTLIST_FOREACH(rr->running_routers, const char *, cp,
- routers_update_status_from_entry(all_routers, rr->published_on,
- cp));
- smartlist_free(all_routers);
- list->running_routers_updated_on = rr->published_on;
-}
-
-/** We've just got a running routers list in <b>rr</b>; update the
- * status of the routers in <b>list</b>, and cache <b>rr</b> */
-void
-routerlist_set_runningrouters(routerlist_t *list, running_routers_t *rr)
-{
- routerlist_update_from_runningrouters(list,rr);
- if (list->running_routers != rr) {
- running_routers_free(list->running_routers);
- list->running_routers = rr;
- }
-}
-
-/** Update the is_running and is_verified fields of the router <b>router</b>,
- * based in its status in the list of strings stored in <b>running_list</b>.
- * All entries in <b>running_list</b> follow one of these formats:
- * <ol><li> <b>nickname</b> -- router is running and verified.
- * (running-routers format)
- * <li> !<b>nickname</b> -- router is not-running and verified.
- * (running-routers format)
- * <li> <b>nickname</b>=$<b>hexdigest</b> -- router is running and
- * verified. (router-status format)
- * (router-status format)
- * <li> !<b>nickname</b>=$<b>hexdigest</b> -- router is running and
- * verified. (router-status format)
- * <li> !<b>nickname</b> -- router is not-running and verified.
- * <li> $<b>hexdigest</b> -- router is running and unverified.
- * <li> !$<b>hexdigest</b> -- router is not-running and unverified.
- * </ol>
- *
- * Return 1 if we found router in running_list, else return 0.
- */
-int
-routers_update_status_from_entry(smartlist_t *routers,
- time_t list_time,
- const char *s)
-{
- int authdir = get_options()->AuthoritativeDir;
- int is_running = 1;
- int is_verified = 0, is_named = 0;
- int hex_digest_set = 0;
- char nickname[MAX_NICKNAME_LEN+1];
- char hexdigest[HEX_DIGEST_LEN+1];
- char digest[DIGEST_LEN];
- const char *cp, *end;
-
- /* First, parse the entry. */
- cp = s;
- if (*cp == '!') {
- is_running = 0;
- ++cp;
- }
-
- if (*cp != '$') {
- /* It starts with a non-dollar character; that's a nickname. The nickname
- * entry will either extend to a NUL (old running-routers format) or to an
- * equals sign (new router-status format). */
- is_verified = 1;
- is_named = 1;
- end = strchr(cp, '=');
- if (!end)
- end = strchr(cp,'\0');
- tor_assert(end);
- /* 'end' now points on character beyond the end of the nickname */
- if (end == cp || end-cp > MAX_NICKNAME_LEN) {
- log_fn(LOG_WARN, "Bad nickname length (%d) in router status entry (%s)",
- (int)(end-cp), s);
- return -1;
- }
- memcpy(nickname, cp, end-cp);
- nickname[end-cp]='\0';
- if (!is_legal_nickname(nickname)) {
- log_fn(LOG_WARN, "Bad nickname (%s) in router status entry (%s)",
- nickname, s);
- return -1;
- }
- cp = end;
- if (*cp == '=')
- ++cp;
- }
- /* 'end' now points to the start of a hex digest, or EOS. */
-
- /* Parse the hexdigest portion of the status. */
- if (*cp == '$') {
- hex_digest_set = 1;
- ++cp;
- if (strlen(cp) != HEX_DIGEST_LEN) {
- log_fn(LOG_WARN, "Bad length (%d) on digest in router status entry (%s)",
- (int)strlen(cp), s);
- return -1;
- }
- strlcpy(hexdigest, cp, sizeof(hexdigest));
- if (base16_decode(digest, DIGEST_LEN, hexdigest, HEX_DIGEST_LEN)<0) {
- log_fn(LOG_WARN, "Invalid digest in router status entry (%s)", s);
- return -1;
- }
- }
-
- /* Make sure that the entry was in the right format. */
- if (!hex_digest_set) {
- log_fn(LOG_WARN, "Invalid syntax for router-status member (%s)", s);
- return -1;
- }
-
- /* Okay, we're done parsing. For all routers that match, update their status.
- */
- SMARTLIST_FOREACH(routers, routerinfo_t *, r,
- {
- int nickname_matches = is_verified && !strcasecmp(r->nickname, nickname);
- int digest_matches = !memcmp(digest, r->identity_digest, DIGEST_LEN);
- if (!authdir) {
- /* If we're not an authoritative directory, update verified status.
- */
- if (nickname_matches && digest_matches)
- r->is_verified = r->is_named = 1;
- else if (digest_matches)
- r->is_verified = r->is_named = 0;
- }
- if (digest_matches)
- if (r->status_set_at < list_time) {
- if (!authdir || is_running)
- /* If we're an authoritative directory, only believe that servers
- * are down when we hear it ourselves. Otherwise, believe
- * what we're told.
- */
- r->is_running = is_running;
- r->status_set_at = time(NULL);
- }
- });
-
- return 0;
-}
-
-/** As router_update_status_from_entry, but consider all entries in
- * running_list. */
-int
-router_update_status_from_smartlist(routerinfo_t *router,
- time_t list_time,
- smartlist_t *running_list)
-{
- smartlist_t *rl;
- rl = smartlist_create();
- smartlist_add(rl,router);
- SMARTLIST_FOREACH(running_list, const char *, cp,
- routers_update_status_from_entry(rl,list_time,cp));
- smartlist_free(rl);
- return 0;
-}
-#endif
-
/** Add to the list of authorized directory servers one at
* <b>address</b>:<b>port</b>, with identity key <b>digest</b>. If
* <b>address</b> is NULL, add ourself. */