mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
immediate reachability check for new relays
This commit is contained in:
parent
7231e289dd
commit
4f307e0382
7
changes/immediate_reachability_check
Normal file
7
changes/immediate_reachability_check
Normal file
@ -0,0 +1,7 @@
|
||||
o Minor features:
|
||||
- Directory authorities now do an immediate reachability check as soon
|
||||
as they hear about a new relay. This change should slightly reduce
|
||||
the time between setting up a relay and getting listed as running
|
||||
in the consensus. It should also improve the time between setting
|
||||
up a bridge and seeing use by bridge users.
|
||||
|
@ -3091,6 +3091,23 @@ dirserv_orconn_tls_done(const char *address,
|
||||
* skip testing. */
|
||||
}
|
||||
|
||||
/** Helper function for dirserv_test_reachability(). Start a TLS
|
||||
* connection to <b>router</b>, and annotate it with when we started
|
||||
* the test. */
|
||||
void
|
||||
dirserv_single_reachability_test(time_t now, routerinfo_t *router)
|
||||
{
|
||||
tor_addr_t router_addr;
|
||||
log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
|
||||
router->nickname, router->address, router->or_port);
|
||||
/* Remember when we started trying to determine reachability */
|
||||
if (!router->testing_since)
|
||||
router->testing_since = now;
|
||||
tor_addr_from_ipv4h(&router_addr, router->addr);
|
||||
connection_or_connect(&router_addr, router->or_port,
|
||||
router->cache_info.identity_digest);
|
||||
}
|
||||
|
||||
/** Auth dir server only: if <b>try_all</b> is 1, launch connections to
|
||||
* all known routers; else we want to load balance such that we only
|
||||
* try a few connections per call.
|
||||
@ -3117,7 +3134,6 @@ dirserv_test_reachability(time_t now, int try_all)
|
||||
|
||||
SMARTLIST_FOREACH_BEGIN(rl->routers, routerinfo_t *, router) {
|
||||
const char *id_digest = router->cache_info.identity_digest;
|
||||
tor_addr_t router_addr;
|
||||
if (router_is_me(router))
|
||||
continue;
|
||||
if (bridge_auth && router->purpose != ROUTER_PURPOSE_BRIDGE)
|
||||
@ -3125,13 +3141,7 @@ dirserv_test_reachability(time_t now, int try_all)
|
||||
// if (router->cache_info.published_on > cutoff)
|
||||
// continue;
|
||||
if (try_all || (((uint8_t)id_digest[0]) % 128) == ctr) {
|
||||
log_debug(LD_OR,"Testing reachability of %s at %s:%u.",
|
||||
router->nickname, router->address, router->or_port);
|
||||
/* Remember when we started trying to determine reachability */
|
||||
if (!router->testing_since)
|
||||
router->testing_since = now;
|
||||
tor_addr_from_ipv4h(&router_addr, router->addr);
|
||||
connection_or_connect(&router_addr, router->or_port, id_digest);
|
||||
dirserv_single_reachability_test(now, router);
|
||||
}
|
||||
} SMARTLIST_FOREACH_END(router);
|
||||
if (!try_all) /* increment ctr */
|
||||
|
@ -2696,7 +2696,8 @@ dirvote_add_vote(const char *vote_body, const char **msg_out, int *status_out)
|
||||
networkstatus_voter_info_t *vi_old = get_voter(v->vote);
|
||||
if (!memcmp(vi_old->vote_digest, vi->vote_digest, DIGEST_LEN)) {
|
||||
/* Ah, it's the same vote. Not a problem. */
|
||||
log_info(LD_DIR, "Discarding a vote we already have.");
|
||||
log_info(LD_DIR, "Discarding a vote we already have (from %s).",
|
||||
vi->address);
|
||||
if (*status_out < 200)
|
||||
*status_out = 200;
|
||||
goto discard;
|
||||
|
@ -3913,6 +3913,7 @@ void dirserv_orconn_tls_done(const char *address,
|
||||
uint16_t or_port,
|
||||
const char *digest_rcvd,
|
||||
int as_advertised);
|
||||
void dirserv_single_reachability_test(time_t now, routerinfo_t *router);
|
||||
void dirserv_test_reachability(time_t now, int try_all);
|
||||
int authdir_wants_to_reject_router(routerinfo_t *ri, const char **msg,
|
||||
int complain);
|
||||
|
@ -3204,7 +3204,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
||||
if (!in_consensus && (router->cache_info.published_on <=
|
||||
old_router->cache_info.published_on)) {
|
||||
/* Same key, but old. This one is not listed in the consensus. */
|
||||
log_debug(LD_DIR, "Skipping not-new descriptor for router '%s'",
|
||||
log_debug(LD_DIR, "Not-new descriptor for router '%s'",
|
||||
router->nickname);
|
||||
/* Only journal this desc if we'll be serving it. */
|
||||
if (!from_cache && should_cache_old_descriptors())
|
||||
@ -3247,9 +3247,15 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
|
||||
/* We haven't seen a router with this identity before. Add it to the end of
|
||||
* the list. */
|
||||
routerlist_insert(routerlist, router);
|
||||
if (!from_cache)
|
||||
if (!from_cache) {
|
||||
if (authdir) {
|
||||
/* launch an immediate reachability test, so we will have an opinion
|
||||
* soon in case we're generating a consensus soon */
|
||||
dirserv_single_reachability_test(time(NULL), router);
|
||||
}
|
||||
signed_desc_append_to_journal(&router->cache_info,
|
||||
&routerlist->desc_store);
|
||||
}
|
||||
directory_set_dirty();
|
||||
return ROUTER_ADDED_SUCCESSFULLY;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user