New, more flexible directory parsing backend. Uses a bit more RAM, but implements the new spec. Uses more RAM, but not so you would notice.

svn:r1235
This commit is contained in:
Nick Mathewson 2004-03-05 05:48:28 +00:00
parent 9d00c4b81c
commit 1e5b7bc6f1
5 changed files with 560 additions and 449 deletions

View File

@ -218,7 +218,7 @@ dirserv_add_descriptor(const char **desc)
cp = desc_tmp = tor_strndup(start, desc_len);
/* Check: is the descriptor syntactically valid? */
ri = router_get_entry_from_string(&cp);
ri = router_get_entry_from_string(cp, NULL);
if (!ri) {
log(LOG_WARN, "Couldn't parse descriptor");
goto err;

View File

@ -860,7 +860,7 @@ int router_set_routerlist_from_string(const char *s);
int router_get_dir_hash(const char *s, char *digest);
int router_get_router_hash(const char *s, char *digest);
int router_set_routerlist_from_directory(const char *s, crypto_pk_env_t *pkey);
routerinfo_t *router_get_entry_from_string(const char **s);
routerinfo_t *router_get_entry_from_string(const char *s, const char *end);
int router_add_exit_policy_from_string(routerinfo_t *router, const char *s);
int router_compare_addr_to_exit_policy(uint32_t addr, uint16_t port,
struct exit_policy_t *policy);

View File

@ -499,7 +499,7 @@ int router_dump_router_to_string(char *s, int maxlen, routerinfo_t *router,
#ifdef DEBUG_ROUTER_DUMP_ROUTER_TO_STRING
cp = s_tmp = s_dup = tor_strdup(s);
ri_tmp = router_get_entry_from_string(&cp);
ri_tmp = router_get_entry_from_string(cp, NULL);
if (!ri_tmp) {
log_fn(LOG_ERR, "We just generated a router descriptor we can't parse: <<%s>>",
s);

File diff suppressed because it is too large Load Diff

View File

@ -611,7 +611,7 @@ test_dir_format()
test_assert(router_dump_router_to_string(buf, 2048, &r1, pk2)>0);
cp = buf;
rp1 = router_get_entry_from_string((const char**)&cp);
rp1 = router_get_entry_from_string((const char*)cp,NULL);
test_assert(rp1);
test_streq(rp1->address, r1.address);
test_eq(rp1->or_port, r1.or_port);
@ -715,6 +715,7 @@ main(int c, char**v){
test_onion();
test_onion_handshake();
puts("\n========================= Directory Formats ===============");
add_stream_log(LOG_DEBUG, NULL, stdout);
test_dir_format();
puts("");