diff options
-rw-r--r-- | src/or/dirserv.c | 2 | ||||
-rw-r--r-- | src/or/or.h | 1 | ||||
-rw-r--r-- | src/or/routerlist.c | 14 |
3 files changed, 16 insertions, 1 deletions
diff --git a/src/or/dirserv.c b/src/or/dirserv.c index 7d69aa21a..b849fd90b 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 85a686aa8..9b34ed899 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 407295fe4..ee9ff7d8d 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 <b>addr</b> 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. |