[or-cvs] More documentation

Nick Mathewson nickm at seul.org
Wed May 5 00:30:45 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv32606/src/or

Modified Files:
	dirserv.c router.c routerlist.c 
Log Message:
More documentation

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -d -r1.41 -r1.42
--- dirserv.c	30 Apr 2004 05:42:52 -0000	1.41
+++ dirserv.c	5 May 2004 00:30:43 -0000	1.42
@@ -4,6 +4,10 @@
 
 #include "or.h"
 
+/*****
+ * dirserv.c: Directory server core implementation.
+ *****/
+
 /* How old do we allow a router to get before removing it? (seconds) */
 #define ROUTER_MAX_AGE (60*60*24)
 
@@ -12,6 +16,7 @@
 
 extern or_options_t options; /* command-line and config-file options */
 
+/* Do we need to regenerate the directory when someone asks for it? */
 static int the_directory_is_dirty = 1;
 
 static int list_running_servers(char **nicknames_out);
@@ -24,9 +29,14 @@
   char *fingerprint;
 } fingerprint_entry_t;
 
+/* List of nickname->identity fingerprint mappings for all the routers
+ * that we recognize. Used to prevent Sybil attacks. */
 static fingerprint_entry_t fingerprint_list[MAX_ROUTERS_IN_DIR];
 static int n_fingerprints = 0;
 
+/* Add the fingerprint 'fp' for the nickname 'nickname' to the global
+ * list of recognized identity key fingerprints.
+ */
 void /* Should be static; exposed for testing */
 add_fingerprint_to_dir(const char *nickname, const char *fp)
 {
@@ -43,6 +53,8 @@
   ++n_fingerprints;
 }
 
+/* Add the nickname and fingerprint for this OR to the recognized list.
+ */
 int
 dirserv_add_own_fingerprint(const char *nickname, crypto_pk_env_t *pk)
 {
@@ -55,7 +67,12 @@
   return 0;
 }
 
-/* return 0 on success, -1 on failure */
+/* Parse the nickname->fingerprint mappings stored in the file named
+ * 'fname'.  The file format is line-based, with each non-blank
+ * holding one nickname, some space, and a fingerprint for that
+ * nickname.  On success, replace the current fingerprint list with
+ * the contents of 'fname' and return 0.  On failure, leave the
+ * current fingerprint list untouched, and return -1. */
 int
 dirserv_parse_fingerprint_file(const char *fname)
 {
@@ -112,8 +129,10 @@
   return -1;
 }
 
-/* return 1 if router's identity and nickname match,
- * -1 if they don't match, 0 if the nickname is not known. */
+/* Check whether 'router' has a nickname/identity key combination that
+ * we recognize from the fingerprint list.  Return 1 if router's
+ * identity and nickname match, -1 if we recognize the nickname but
+ * the identity key is wrong, and 0 if the nickname is not known. */
 int
 dirserv_router_fingerprint_is_known(const routerinfo_t *router)
 {
@@ -147,6 +166,7 @@
   }
 }
 
+/* Clear the current fingerprint list. */
 void
 dirserv_free_fingerprint_list()
 {
@@ -161,6 +181,9 @@
 /*
  *    Descriptor list
  */
+
+/* A directory server's view of a server descriptor.  Contains both
+ * parsed and unparsed versions. */
 typedef struct descriptor_entry_t {
   char *nickname;
   time_t published;
@@ -169,9 +192,11 @@
   routerinfo_t *router;
 } descriptor_entry_t;
 
+/* List of all server descriptors that this dirserv is holding. */
 static descriptor_entry_t *descriptor_list[MAX_ROUTERS_IN_DIR];
 static int n_descriptors = 0;
 
+/* Release the storage held by 'desc' */
 static void free_descriptor_entry(descriptor_entry_t *desc)
 {
   tor_free(desc->descriptor);
@@ -180,6 +205,8 @@
   free(desc);
 }
 
+/* Release all storage that the dirserv is holding for server
+ * descriptors. */
 void
 dirserv_free_descriptors()
 {
@@ -190,12 +217,13 @@
   n_descriptors = 0;
 }
 
-/* Return 1 if descriptor is well-formed and accepted;
- * 0 if well-formed and server or descriptor is unapproved;
- * -1 if not well-formed or other error.
+/* Parse the server descriptor at *desc and maybe insert it into the
+ * list of service descriptors, and (if the descriptor is well-formed)
+ * advance *desc immediately past the descriptor's end.
  *
- * Update *desc to point after the descriptor if the
- * descriptor is well-formed.
+ * Return 1 if descriptor is well-formed and accepted;
+ * 0 if well-formed and server is unapproved;
+ * -1 if not well-formed or other error.
  */
 int
 dirserv_add_descriptor(const char **desc)
@@ -307,6 +335,10 @@
   return 1;
 }
 
+/* Remove all descriptors whose nicknames or fingerprints we don't
+ * recognize.  (Descriptors that used to be good can become
+ * unrecognized when we reload the fingerprint list.)
+ */
 static void
 directory_remove_unrecognized(void)
 {
@@ -321,12 +353,19 @@
   }
 }
 
+/* Mark the directory as 'dirty' -- when we're next asked for a
+ * directory, we will rebuild it instead of reusing the most recently
+ * generated one.
+ */
 void
 directory_set_dirty()
 {
   the_directory_is_dirty = 1;
 }
 
+/* Load all descriptors from an earlier directory stored in the string
+ * 'dir'.
+ */
 int
 dirserv_init_from_directory_string(const char *dir)
 {
@@ -343,6 +382,10 @@
   return 0;
 }
 
+/* Set *nicknames_out to a comma-separated list of all the ORs that we
+ * believe are currently running (because we have open connections to
+ * them).  Return 0 on success; -1 on error.
+ */
 static int
 list_running_servers(char **nicknames_out)
 {

Index: router.c
===================================================================
RCS file: /home/or/cvsroot/src/or/router.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- router.c	4 May 2004 22:46:19 -0000	1.36
+++ router.c	5 May 2004 00:30:43 -0000	1.37
@@ -4,6 +4,11 @@
 
 #include "or.h"
 
+/*****
+ * router.c: OR functionality, including key maintenance, generating
+ * and uploading server descriptors, retrying OR connections.
+ *****/
+
 extern or_options_t options; /* command-line and config-file options */
 
 /* exposed for test.c */ void get_platform_str(char *platform, int len);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerlist.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -d -r1.68 -r1.69
--- routerlist.c	4 May 2004 18:17:45 -0000	1.68
+++ routerlist.c	5 May 2004 00:30:43 -0000	1.69
@@ -9,6 +9,13 @@
 
 #include "or.h"
 
+/*****
+ * routerlist.c: Code to parse descriptors and directories, and to
+ * maintain and access the global list of routerinfos for known
+ * servers.
+ *****/
+
+
 /****************************************************************************/
 
 extern or_options_t options; /* command-line and config-file options */



More information about the tor-commits mailing list