aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2005-08-26 21:28:16 +0000
committerNick Mathewson <nickm@torproject.org>2005-08-26 21:28:16 +0000
commite24d540d818a0474493ebad2c9ceec3fd755f2c0 (patch)
tree9edced9efbdedfda30621b9c03d8a2d7fd1751ce
parent208bdf5f27d796c3da8f1b83795c3f2df9dfde7d (diff)
downloadtor-e24d540d818a0474493ebad2c9ceec3fd755f2c0.tar
tor-e24d540d818a0474493ebad2c9ceec3fd755f2c0.tar.gz
We no longer need dirserv_load_from_directory_string, so dirserv_add_descriptor no longer has to keep track of where each descriptor ends.
svn:r4861
-rw-r--r--src/or/directory.c3
-rw-r--r--src/or/dirserv.c32
-rw-r--r--src/or/or.h3
-rw-r--r--src/or/routerlist.c2
-rw-r--r--src/or/test.c6
5 files changed, 13 insertions, 33 deletions
diff --git a/src/or/directory.c b/src/or/directory.c
index 740dc1ba0..9e92b485b 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1188,8 +1188,7 @@ directory_handle_command_post(connection_t *conn, char *headers,
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 */
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index a4b9abf69..fdf3c18ff 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -324,11 +324,9 @@ dirserv_wants_to_reject_router(routerinfo_t *ri, int *verified,
-/** 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 @@ dirserv_wants_to_reject_router(routerinfo_t *ri, int *verified,
* -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 @@ directory_set_dirty()
runningrouters_is_dirty = now;
}
+#if 0
/** Load all descriptors from a directory stored in the string
* <b>dir</b>.
*/
@@ -489,6 +470,7 @@ dirserv_load_from_directory_string(const char *dir)
}
return 0;
}
+#endif
/**
* Allocate and return a description of the status of the server <b>desc</b>,
diff --git a/src/or/or.h b/src/or/or.h
index 9180a61cf..eb699afdd 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1628,9 +1628,8 @@ int dirserv_parse_fingerprint_file(const char *fname);
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);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 2dcbfbb36..207d51455 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1076,11 +1076,13 @@ router_load_routerlist_from_directory(const char *s,
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;
}
diff --git a/src/or/test.c b/src/or/test.c
index 604c68694..4a91399a2 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -1283,11 +1283,9 @@ test_dir_format(void)
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));