[or-cvs] authorities do not replace server descriptors where nothing...
Nick Mathewson
nickm at seul.org
Wed Oct 12 18:25:28 UTC 2005
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv17903/src/or
Modified Files:
directory.c dirserv.c routerlist.c
Log Message:
authorities do not replace server descriptors where nothing semantically relevant has changed since the last upload.
Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/directory.c,v
retrieving revision 1.303
retrieving revision 1.304
diff -u -d -r1.303 -r1.304
--- directory.c 5 Oct 2005 20:45:18 -0000 1.303
+++ directory.c 12 Oct 2005 18:25:25 -0000 1.304
@@ -1441,7 +1441,7 @@
if (!authdir_mode(get_options())) {
/* we just provide cached directories; we don't want to
* receive anything. */
- write_http_status_line(conn, 400, "Nonauthoritative directory does not not store server descriptors.");
+ write_http_status_line(conn, 400, "Nonauthoritative directory does not accept posted server descriptors.");
return 0;
}
Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/dirserv.c,v
retrieving revision 1.247
retrieving revision 1.248
diff -u -d -r1.247 -r1.248
--- dirserv.c 8 Oct 2005 06:02:41 -0000 1.247
+++ dirserv.c 12 Oct 2005 18:25:25 -0000 1.248
@@ -439,7 +439,7 @@
dirserv_add_descriptor(const char *desc, const char **msg)
{
int r;
- routerinfo_t *ri = NULL;
+ routerinfo_t *ri = NULL, *ri_old = NULL;
tor_assert(msg);
*msg = NULL;
@@ -450,6 +450,19 @@
*msg = "Rejected: Couldn't parse server descriptor.";
return -2;
}
+ /* Check whether this descriptor is semantically identical to the last one
+ * from this server. (We do this here and not in router_add_to_routerlist
+ * because we want to be able to accept the newest router descriptor that
+ * another authority has, so we all converge on the same one.) */
+ ri_old = router_get_by_digest(ri->identity_digest);
+ if (ri_old && ri_old->published_on < ri->published_on &&
+ router_differences_are_cosmetic(ri_old, ri)) {
+ log_fn(LOG_INFO,
+ "Not replacing descriptor from '%s'; differences are cosmetic.",
+ ri->nickname);
+ *msg = "Not replacing router descriptor; no information has changed since the last one with this identity.";
+ return 0;
+ }
if ((r = router_add_to_routerlist(ri, msg, 0))<0) {
return r == -1 ? 0 : -1;
} else {
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.338
retrieving revision 1.339
diff -u -d -r1.338 -r1.339
--- routerlist.c 12 Oct 2005 17:16:25 -0000 1.338
+++ routerlist.c 12 Oct 2005 18:25:25 -0000 1.339
@@ -2533,8 +2533,6 @@
if (!routerstatus_list)
return;
- log_fn(LOG_NOTICE, "Here, %d %d", reset_failures, assume_recognized);
-
SMARTLIST_FOREACH(routers, routerinfo_t *, router,
{
rs = router_get_combined_status_by_digest(router->identity_digest);
@@ -2864,11 +2862,19 @@
int
router_differences_are_cosmetic(routerinfo_t *r1, routerinfo_t *r2)
{
+ tor_assert(r1 && r2);
+
/* post-0.1.1.6 servers know what they're doing. */
if (tor_version_as_new_as(r1->platform, "0.1.1.6-alpha") ||
tor_version_as_new_as(r1->platform, "0.1.1.6-alpha"))
return 0;
+ if (r1->published_on > r2->published_on) {
+ routerinfo_t *ri_tmp = r2;
+ r2 = r1;
+ r1 = ri_tmp;
+ }
+
/* If any key fields differ, they're different. */
if (strcasecmp(r1->address, r2->address) ||
strcasecmp(r1->nickname, r2->nickname) ||
@@ -2901,8 +2907,12 @@
return 0;
/* Did more than 6 hours pass? */
- if (r1->published_on + 6*60*60 < r2->published_on ||
- r2->published_on + 6*60*60 < r1->published_on)
+ if (r1->published_on + 6*60*60 < r2->published_on)
+ return 0;
+
+ /* Did uptime fail to increase by approximately the amount we would think,
+ * give or take 30 minutes? */
+ if (abs(r2->uptime - (r1->uptime + (r2->published_on-r1->published_on)))>30*60)
return 0;
/* Otherwise, the difference is cosmetic. */
More information about the tor-commits
mailing list