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

[or-cvs] r10217: Possible fix for bug 417 and bug 404: do not insert our rout (in tor/trunk: . src/or)



Author: nickm
Date: 2007-05-18 20:45:17 -0400 (Fri, 18 May 2007)
New Revision: 10217

Modified:
   tor/trunk/
   tor/trunk/src/or/or.h
   tor/trunk/src/or/router.c
Log:
 r12800@catbus:  nickm | 2007-05-18 20:45:15 -0400
 Possible fix for bug 417 and bug 404: do not insert our routerinfo directly; instead, re-parse it first.



Property changes on: tor/trunk
___________________________________________________________________
 svk:merge ticket from /tor/trunk [r12800] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2007-05-19 00:32:00 UTC (rev 10216)
+++ tor/trunk/src/or/or.h	2007-05-19 00:45:17 UTC (rev 10217)
@@ -3094,6 +3094,7 @@
                                              uint16_t port);
 
 #define ROUTER_REQUIRED_MIN_BANDWIDTH 10000
+
 #define ROUTER_MAX_DECLARED_BANDWIDTH INT32_MAX
 int router_is_unreliable(routerinfo_t *router, int need_uptime,
                          int need_capacity, int need_guard);
@@ -3131,7 +3132,6 @@
 void routerstatus_free(routerstatus_t *routerstatus);
 void networkstatus_free(networkstatus_t *networkstatus);
 void routerlist_free_all(void);
-routerinfo_t *routerinfo_copy(const routerinfo_t *router);
 void router_set_status(const char *digest, int up);
 void routerlist_remove_old_routers(void);
 void networkstatus_list_clean(time_t now);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2007-05-19 00:32:00 UTC (rev 10216)
+++ tor/trunk/src/or/router.c	2007-05-19 00:45:17 UTC (rev 10217)
@@ -319,6 +319,7 @@
   mydesc = router_get_my_descriptor();
   if (authdir_mode(options)) {
     const char *m;
+    routerinfo_t *ri;
     /* We need to add our own fingerprint so it gets recognized. */
     if (dirserv_add_own_fingerprint(options->Nickname, get_identity_key())) {
       log_err(LD_GENERAL,"Error adding own fingerprint to approved set");
@@ -328,7 +329,13 @@
       log_err(LD_GENERAL,"Error initializing descriptor.");
       return -1;
     }
-    if (dirserv_add_descriptor(router_get_my_routerinfo(), &m) < 0) {
+    ri = router_parse_entry_from_string(mydesc, NULL, 1);
+    if (!ri) {
+      log_err(LD_GENERAL,"Generated a routerinfo we couldn't parse.");
+      return -1;
+    }
+    if (dirserv_add_descriptor(ri, &m)
+        < 0) {
       log_err(LD_GENERAL,"Unable to add own descriptor to directory: %s",
               m?m:"<unknown error>");
       return -1;