[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Remove a bunch of #if0d code that I no longer need to look ...



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv26817/src/or

Modified Files:
	directory.c or.h routerlist.c routerparse.c 
Log Message:
Remove a bunch of #if0d code that I no longer need to look at.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -d -r1.282 -r1.283
--- directory.c	16 Sep 2005 16:41:45 -0000	1.282
+++ directory.c	16 Sep 2005 16:47:20 -0000	1.283
@@ -905,15 +905,6 @@
     if (router_parse_directory(body) < 0) {
       log_fn(LOG_NOTICE,"I failed to parse the directory I fetched from '%s:%d'. Ignoring.", conn->address, conn->port);
     }
-#if 0
-    if (router_load_routerlist_from_directory(body, NULL, !skewed, 0) < 0) {
-      log_fn(LOG_NOTICE,"I failed to parse the directory I fetched from '%s:%d'. Ignoring.", conn->address, conn->port);
-      tor_free(body); tor_free(headers); tor_free(reason);
-      return -1;
-    }
-    /* do things we've been waiting to do */
-    directory_has_arrived(time(NULL), conn->identity_digest);
-#endif
   }
 
   if (conn->purpose == DIR_PURPOSE_FETCH_RUNNING_LIST) {
@@ -931,21 +922,6 @@
       tor_free(body); tor_free(headers); tor_free(reason);
       return -1;
     }
-#if 0
-    if (!(rrs = router_parse_runningrouters(body, 1))) {
-      log_fn(LOG_WARN, "Can't parse runningrouters list (server '%s:%d')",
-             conn->address, conn->port);
-      tor_free(body); tor_free(headers); tor_free(reason);
-      return -1;
-    }
-    router_get_routerlist(&rl);
-    if (rl) {
-      routerlist_set_runningrouters(rl,rrs);
-      helper_nodes_set_status_from_directory();
-    } else {
-      running_routers_free(rrs);
-    }
-#endif
   }
 
   if (conn->purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) {

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.688
retrieving revision 1.689
diff -u -d -r1.688 -r1.689
--- or.h	16 Sep 2005 04:42:45 -0000	1.688
+++ or.h	16 Sep 2005 16:47:20 -0000	1.689
@@ -783,15 +783,6 @@
   int num_unreachable_notifications;
 } routerinfo_t;
 
-#if 0
-/** Contents of a running-routers list */
-typedef struct running_routers_t {
-  time_t published_on; /**< When was the list marked as published? */
-  /** Which ORs are on the list?  Entries may be prefixed with ! and $. */
-  smartlist_t *running_routers;
-} running_routers_t;
-#endif
-
 /** Contents of a single per-router entry in a network status object.
  */
 typedef struct routerstatus_t {
@@ -848,13 +839,6 @@
   /* XXXX011 NM This field is only used in moribund code; remove it
    * once the moribund code is dead. */
   time_t published_on_xx;
-#if 0
-  /** Which versions of tor are recommended by this directory? */
-  char *software_versions;
-  time_t running_routers_updated_on;
-  /** What is the most recently received running_routers structure? */
-  running_routers_t *running_routers;
-#endif
 } routerlist_t;
 
 /** Information on router used when extending a circuit.  (We don't need a
@@ -2088,9 +2072,6 @@
 routerinfo_t *router_get_by_digest(const char *digest);
 int router_digest_is_trusted_dir(const char *digest);
 void router_get_routerlist(routerlist_t **prouterlist);
-#if 0
-time_t routerlist_get_published_time(void);
-#endif
 void routerlist_free(routerlist_t *routerlist);
 void routerinfo_free(routerinfo_t *router);
 void routerstatus_free(routerstatus_t *routerstatus);
@@ -2105,10 +2086,6 @@
 int router_load_single_router(const char *s, const char **msg);
 void router_load_routers_from_string(const char *s, int from_cache,
                                      smartlist_t *requested_fingerprints);
-#if 0
-int router_load_routerlist_from_directory(const char *s,crypto_pk_env_t *pkey,
-                                        int dir_is_recent, int dir_is_cached);
-#endif
 typedef enum { NS_FROM_CACHE, NS_FROM_DIR, NS_GENERATED} networkstatus_source_t;
 int router_set_networkstatus(const char *s, time_t arrived_at,
                              networkstatus_source_t source,
@@ -2120,16 +2097,6 @@
                                           int need_uptime);
 
 int router_exit_policy_rejects_all(routerinfo_t *router);
-#if 0
-void running_routers_free(running_routers_t *rr);
-void routerlist_set_runningrouters(routerlist_t *list, running_routers_t *rr);
-int routers_update_status_from_entry(smartlist_t *routers,
-                                        time_t list_time,
-                                        const char *s);
-int router_update_status_from_smartlist(routerinfo_t *r,
-                                        time_t list_time,
-                                        smartlist_t *running_list);
-#endif
 void add_trusted_dir_server(const char *addr, uint16_t port,
                             const char *digest, int supports_v1);
 void clear_trusted_dir_servers(void);
@@ -2183,9 +2150,6 @@
 int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);
 addr_policy_t *router_parse_addr_policy_from_string(const char *s,
                                                     int assume_action);
-#if 0
-int check_software_version_against_directory(const char *directory);
-#endif
 int tor_version_parse(const char *s, tor_version_t *out);
 int tor_version_as_new_as(const char *platform, const char *cutoff);
 int tor_version_compare(tor_version_t *a, tor_version_t *b);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.299
retrieving revision 1.300
diff -u -d -r1.299 -r1.300
--- routerlist.c	16 Sep 2005 16:41:45 -0000	1.299
+++ routerlist.c	16 Sep 2005 16:47:20 -0000	1.300
@@ -923,16 +923,6 @@
   *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 @@
     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 @@
   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 @@
     == 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. */

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.142
retrieving revision 1.143
diff -u -d -r1.142 -r1.143
--- routerparse.c	16 Sep 2005 16:41:45 -0000	1.142
+++ routerparse.c	16 Sep 2005 16:47:20 -0000	1.143
@@ -247,35 +247,6 @@
   return -1;
 }
 
-#if 0
-/**
- * Find the first instance of "recommended-software ...\n" at the start of
- * a line; return a newly allocated string containing the "..." portion.
- * Return NULL if no such instance was found.
- */
-static char *
-get_recommended_software_from_directory(const char *str)
-{
-#define REC "recommended-software "
-  const char *cp = str, *eol;
-  size_t len = strlen(REC);
-  cp = str;
-  if (strcmpstart(str, REC)==0) {
-    cp += len;
-  } else {
-    cp = strstr(str, "\n"REC);
-    if (!cp)
-      return NULL;
-    cp += len+1;
-  }
-  eol = strchr(cp, '\n');
-  if (!eol)
-    return NULL;
-  return tor_strndup(cp, eol-cp);
-#undef REC
-}
-#endif
-
 /** Return 1 if <b>myversion</b> is not in <b>versionlist</b>, and if at least
  * one version of Tor on <b>versionlist</b> is newer than <b>myversion</b>.