瀏覽代碼

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
Nick Mathewson 21 年之前
父節點
當前提交
1e5b7bc6f1
共有 5 個文件被更改,包括 557 次插入444 次删除
  1. 1 1
      src/or/dirserv.c
  2. 1 1
      src/or/or.h
  3. 1 1
      src/or/router.c
  4. 552 440
      src/or/routerlist.c
  5. 2 1
      src/or/test.c

+ 1 - 1
src/or/dirserv.c

@@ -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;

+ 1 - 1
src/or/or.h

@@ -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);

+ 1 - 1
src/or/router.c

@@ -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);

文件差異過大導致無法顯示
+ 552 - 440
src/or/routerlist.c


+ 2 - 1
src/or/test.c

@@ -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("");
 

部分文件因文件數量過多而無法顯示