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

[or-cvs] We no longer need dirserv_load_from_directory_string, so d...



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

Modified Files:
	directory.c dirserv.c or.h routerlist.c test.c 
Log Message:
We no longer need dirserv_load_from_directory_string, so  dirserv_add_descriptor no longer has to keep track of where each descriptor ends.

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -d -r1.247 -r1.248
--- directory.c	25 Aug 2005 20:33:16 -0000	1.247
+++ directory.c	26 Aug 2005 21:28:15 -0000	1.248
@@ -1188,8 +1188,7 @@
 
   if (!strcmp(url,"/tor/")) { /* server descriptor post */
     const char *msg;
-    cp = body;
-    switch (dirserv_add_descriptor(&cp, &msg)) {
+    switch (dirserv_add_descriptor(body, &msg)) {
       case -2:
       case -1:
         /* malformed descriptor, or something wrong */

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.190
retrieving revision 1.191
diff -u -d -r1.190 -r1.191
--- dirserv.c	26 Aug 2005 21:11:53 -0000	1.190
+++ dirserv.c	26 Aug 2005 21:28:16 -0000	1.191
@@ -324,11 +324,9 @@
 
 
 
-/** Parse the server descriptor at *desc and maybe insert it into the
- * list of server descriptors, and (if the descriptor is well-formed)
- * advance *desc immediately past the descriptor's end.  Set msg to a
- * message that should be passed back to the origin of this descriptor, or
- * to NULL.
+/** Parse the server descriptor at desc and maybe insert it into the list of
+ * server descriptors.  Set msg to a message that should be passed back to the
+ * origin of this descriptor, or to NULL.
  *
  * Return 1 if descriptor is well-formed and accepted;
  *  0 if well-formed and server is unapproved but accepted;
@@ -336,33 +334,15 @@
  * -2 if we can't find a router descriptor in *desc.
  */
 int
-dirserv_add_descriptor(const char **desc, const char **msg)
+dirserv_add_descriptor(const char *desc, const char **msg)
 {
   routerinfo_t *ri = NULL;
-  char *start, *end;
-  char *desc_tmp = NULL;
   size_t desc_len;
   tor_assert(msg);
   *msg = NULL;
 
-  start = strstr(*desc, "router ");
-  if (!start) {
-    log_fn(LOG_WARN, "no 'router' line found. This is not a descriptor.");
-    return -2;
-  }
-  if ((end = strstr(start+6, "\nrouter "))) {
-    ++end; /* Include NL. */
-  } else if ((end = strstr(start+6, "\ndirectory-signature"))) {
-    ++end;
-  } else {
-    end = start+strlen(start);
-  }
-  desc_len = end-start;
-  desc_tmp = tor_strndup(start, desc_len); /* Is this strndup still needed???*/
-
   /* Check: is the descriptor syntactically valid? */
-  ri = router_parse_entry_from_string(desc_tmp, NULL);
-  tor_free(desc_tmp);
+  ri = router_parse_entry_from_string(desc, NULL);
   if (!ri) {
     log(LOG_WARN, "Couldn't parse descriptor");
     *msg = "Rejected: Couldn't parse server descriptor.";
@@ -470,6 +450,7 @@
     runningrouters_is_dirty = now;
 }
 
+#if 0
 /** Load all descriptors from a directory stored in the string
  * <b>dir</b>.
  */
@@ -489,6 +470,7 @@
   }
   return 0;
 }
+#endif
 
 /**
  * Allocate and return a description of the status of the server <b>desc</b>,

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.657
retrieving revision 1.658
diff -u -d -r1.657 -r1.658
--- or.h	26 Aug 2005 21:11:34 -0000	1.657
+++ or.h	26 Aug 2005 21:28:16 -0000	1.658
@@ -1628,9 +1628,8 @@
 int dirserv_router_fingerprint_is_known(const routerinfo_t *router);
 void dirserv_free_fingerprint_list(void);
 const char *dirserv_get_nickname_by_digest(const char *digest);
-int dirserv_add_descriptor(const char **desc, const char **msg);
+int dirserv_add_descriptor(const char *desc, const char **msg);
 char *dirserver_getinfo_unregistered(const char *question);
-int dirserv_load_from_directory_string(const char *dir);
 void dirserv_free_descriptors(void);
 int list_server_status(smartlist_t *routers, char **router_status_out);
 void dirserv_log_unreachable_servers(time_t now);

Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.257
retrieving revision 1.258
diff -u -d -r1.257 -r1.258
--- routerlist.c	26 Aug 2005 21:12:53 -0000	1.257
+++ routerlist.c	26 Aug 2005 21:28:16 -0000	1.258
@@ -1076,11 +1076,13 @@
     control_event_descriptors_changed(routerlist->routers);
   }
   router_normalize_routerlist(routerlist);
+#if 0
   if (get_options()->AuthoritativeDir) {
     /* Learn about the descriptors in the directory. */
     dirserv_load_from_directory_string(s);
 //XXXRD
   }
+#endif
   return 0;
 }
 

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/test.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -d -r1.194 -r1.195
--- test.c	26 Aug 2005 15:35:43 -0000	1.194
+++ test.c	26 Aug 2005 21:28:16 -0000	1.195
@@ -1283,11 +1283,9 @@
   r1.published_on = time(NULL);
   r2.published_on = time(NULL)-3*60*60;
   test_assert(router_dump_router_to_string(buf, 2048, &r1, pk2)>0);
-  cp = buf;
-  test_eq(dirserv_add_descriptor((const char**)&cp,&m), 1);
+  test_eq(dirserv_add_descriptor(buf,&m), 1);
   test_assert(router_dump_router_to_string(buf, 2048, &r2, pk1)>0);
-  cp = buf;
-  test_eq(dirserv_add_descriptor((const char**)&cp,&m), 1);
+  test_eq(dirserv_add_descriptor(buf,&m), 1);
   get_options()->Nickname = tor_strdup("DirServer");
   test_assert(!dirserv_dump_directory_to_string(&cp,pk3));
   test_assert(!router_parse_routerlist_from_directory(cp, &dir1, pk3, 1, 0));