From d9a99b9ba6582d40a929838e5af771204b9c964b Mon Sep 17 00:00:00 2001 From: Roger Dingledine Date: Wed, 10 Oct 2007 20:13:52 +0000 Subject: [PATCH] get r11842 closer to what i want svn:r11851 --- src/or/dirserv.c | 2 +- src/or/or.h | 1 + src/or/routerlist.c | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 7d69aa21a4..b849fd90b8 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1852,7 +1852,7 @@ get_possible_sybil_list(const smartlist_t *routers) last_addr = ri->addr; addr_count = 1; } else if (++addr_count > MAX_WITH_SAME_ADDR) { - if (!router_digest_is_trusted_dir(ri->cache_info.identity_digest) || + if (!router_addr_is_trusted_dir(ri->addr) || addr_count > MAX_WITH_SAME_ADDR_ON_AUTHORITY) digestmap_set(omit_as_sybil, ri->cache_info.identity_digest, ri); } diff --git a/src/or/or.h b/src/or/or.h index 85a686aa8e..9b34ed8992 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -3555,6 +3555,7 @@ int router_digest_is_trusted_dir_type(const char *digest, authority_type_t type); #define router_digest_is_trusted_dir(d) \ router_digest_is_trusted_dir_type((d), 0) +int router_addr_is_trusted_dir(uint32_t addr); routerlist_t *router_get_routerlist(void); void routerlist_reset_warnings(void); void routerlist_free(routerlist_t *routerlist); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 407295fe4e..ee9ff7d8d4 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -1783,6 +1783,20 @@ router_digest_is_trusted_dir_type(const char *digest, authority_type_t type) return 0; } +/** Return true iff addr is the address of one of our trusted + * directory authorities. */ +int +router_addr_is_trusted_dir(uint32_t addr) +{ + if (!trusted_dir_servers) + return 0; + SMARTLIST_FOREACH(trusted_dir_servers, trusted_dir_server_t *, ent, + if (ent->addr == addr) + return 1; + ); + return 0; +} + /** If hexdigest is correctly formed, base16_decode it into * digest, which must have DIGEST_LEN space in it. * Return 0 on success, -1 on failure.