mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-30 23:53:32 +01:00
Extract the "do these routers have the same addr:orport" logic into a fn
This commit is contained in:
parent
b2473357f2
commit
f5b7e039f3
@ -3136,7 +3136,7 @@ dirserv_should_launch_reachability_test(routerinfo_t *ri, routerinfo_t *ri_old)
|
|||||||
/* It just came out of hibernation; launch a reachability test */
|
/* It just came out of hibernation; launch a reachability test */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (ri_old->addr != ri->addr || ri_old->or_port != ri->or_port) {
|
if (! routers_have_same_or_addr(ri, ri_old)) {
|
||||||
/* Address or port changed; launch a reachability test */
|
/* Address or port changed; launch a reachability test */
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1257,6 +1257,13 @@ mark_all_trusteddirservers_up(void)
|
|||||||
router_dir_info_changed();
|
router_dir_info_changed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return true iff r1 and r2 have the same address and OR port. */
|
||||||
|
int
|
||||||
|
routers_have_same_or_addr(const routerinfo_t *r1, const routerinfo_t *r2)
|
||||||
|
{
|
||||||
|
return r1->addr == r2->addr && r1->or_port == r2->or_port;
|
||||||
|
}
|
||||||
|
|
||||||
/** Reset all internal variables used to count failed downloads of network
|
/** Reset all internal variables used to count failed downloads of network
|
||||||
* status objects. */
|
* status objects. */
|
||||||
void
|
void
|
||||||
@ -3246,8 +3253,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
|||||||
log_debug(LD_DIR, "Replacing entry for router '%s/%s' [%s]",
|
log_debug(LD_DIR, "Replacing entry for router '%s/%s' [%s]",
|
||||||
router->nickname, old_router->nickname,
|
router->nickname, old_router->nickname,
|
||||||
hex_str(id_digest,DIGEST_LEN));
|
hex_str(id_digest,DIGEST_LEN));
|
||||||
if (router->addr == old_router->addr &&
|
if (routers_have_same_or_addr(router, old_router)) {
|
||||||
router->or_port == old_router->or_port) {
|
|
||||||
/* these carry over when the address and orport are unchanged. */
|
/* these carry over when the address and orport are unchanged. */
|
||||||
router->last_reachable = old_router->last_reachable;
|
router->last_reachable = old_router->last_reachable;
|
||||||
router->testing_since = old_router->testing_since;
|
router->testing_since = old_router->testing_since;
|
||||||
|
@ -35,6 +35,7 @@ int router_get_my_share_of_directory_requests(double *v2_share_out,
|
|||||||
void router_reset_status_download_failures(void);
|
void router_reset_status_download_failures(void);
|
||||||
void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
|
void routerlist_add_family(smartlist_t *sl, routerinfo_t *router);
|
||||||
int routers_in_same_family(routerinfo_t *r1, routerinfo_t *r2);
|
int routers_in_same_family(routerinfo_t *r1, routerinfo_t *r2);
|
||||||
|
int routers_have_same_or_addr(const routerinfo_t *r1, const routerinfo_t *r2);
|
||||||
void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
|
void add_nickname_list_to_smartlist(smartlist_t *sl, const char *list,
|
||||||
int must_be_running);
|
int must_be_running);
|
||||||
int router_nickname_is_in_list(routerinfo_t *router, const char *list);
|
int router_nickname_is_in_list(routerinfo_t *router, const char *list);
|
||||||
|
Loading…
Reference in New Issue
Block a user