Loading src/feature/relay/selftest.c +54 −29 Original line number Original line Diff line number Diff line Loading @@ -169,27 +169,17 @@ extend_info_from_router(const routerinfo_t *r, int family) return info; return info; } } /** Some time has passed, or we just got new directory information. /** Launch a self-testing circuit to our ORPort. The circuit can be used to * See if we currently believe our ORPort or DirPort to be * test reachability or bandwidth. <b>me</b> is our own routerinfo. * unreachable. If so, launch a new test for it. * * * For ORPort, we simply try making a circuit that ends at ourselves. * Logs an info-level status message. If <b>orport_reachable</b> is false, * Success is noticed in onionskin_answer(). * call it a reachability circuit. Otherwise, call it a bandwidth circuit. * * * For DirPort, we make a connection via Tor to our DirPort and ask * See router_do_reachability_checks() for details. */ * for our own server descriptor. static void * Success is noticed in connection_dir_client_reached_eof(). router_do_orport_reachability_checks(const routerinfo_t *me, */ int orport_reachable) void router_do_reachability_checks(int test_or, int test_dir) { { const routerinfo_t *me = router_get_my_routerinfo(); const or_options_t *options = get_options(); int orport_reachable = router_skip_orport_reachability_check(options); tor_addr_t addr; if (router_should_check_reachability(test_or, test_dir)) { if (test_or && (!orport_reachable || !circuit_enough_testing_circs())) { extend_info_t *ei = extend_info_from_router(me, AF_INET); extend_info_t *ei = extend_info_from_router(me, AF_INET); /* XXX IPv6 self testing */ /* XXX IPv6 self testing */ log_info(LD_CIRC, "Testing %s of my ORPort: %s:%d.", log_info(LD_CIRC, "Testing %s of my ORPort: %s:%d.", Loading @@ -200,12 +190,19 @@ router_do_reachability_checks(int test_or, int test_dir) extend_info_free(ei); extend_info_free(ei); } } /* XXX IPv6 self testing */ /** Launch a self-testing circuit, and ask an exit to connect to our DirPort. * <b>me</b> is our own routerinfo. * * See router_do_reachability_checks() for details. */ static void router_do_dirport_reachability_checks(const routerinfo_t *me) { tor_addr_t addr; tor_addr_from_ipv4h(&addr, me->addr); tor_addr_from_ipv4h(&addr, me->addr); if (test_dir && !router_skip_dirport_reachability_check(options) && if (!connection_get_by_type_addr_port_purpose( !connection_get_by_type_addr_port_purpose( CONN_TYPE_DIR, &addr, me->dir_port, CONN_TYPE_DIR, &addr, me->dir_port, DIR_PURPOSE_FETCH_SERVERDESC)) { DIR_PURPOSE_FETCH_SERVERDESC)) { /* XXX IPv6 self testing */ tor_addr_port_t my_dirport; tor_addr_port_t my_dirport; memcpy(&my_dirport.addr, &addr, sizeof(addr)); memcpy(&my_dirport.addr, &addr, sizeof(addr)); my_dirport.port = me->dir_port; my_dirport.port = me->dir_port; Loading @@ -222,6 +219,34 @@ router_do_reachability_checks(int test_or, int test_dir) directory_request_free(req); directory_request_free(req); } } } } /** Some time has passed, or we just got new directory information. * See if we currently believe our ORPort or DirPort to be * unreachable. If so, launch a new test for it. * * For ORPort, we simply try making a circuit that ends at ourselves. * Success is noticed in onionskin_answer(). * * For DirPort, we make a connection via Tor to our DirPort and ask * for our own server descriptor. * Success is noticed in connection_dir_client_reached_eof(). */ void router_do_reachability_checks(int test_or, int test_dir) { const routerinfo_t *me = router_get_my_routerinfo(); const or_options_t *options = get_options(); int orport_reachable = router_skip_orport_reachability_check(options); if (router_should_check_reachability(test_or, test_dir)) { if (test_or && (!orport_reachable || !circuit_enough_testing_circs())) { router_do_orport_reachability_checks(me, orport_reachable); } if (test_dir && !router_skip_dirport_reachability_check(options)) { router_do_dirport_reachability_checks(me); } } } } /** We've decided to start our reachability testing. If all /** We've decided to start our reachability testing. If all Loading Loading
src/feature/relay/selftest.c +54 −29 Original line number Original line Diff line number Diff line Loading @@ -169,27 +169,17 @@ extend_info_from_router(const routerinfo_t *r, int family) return info; return info; } } /** Some time has passed, or we just got new directory information. /** Launch a self-testing circuit to our ORPort. The circuit can be used to * See if we currently believe our ORPort or DirPort to be * test reachability or bandwidth. <b>me</b> is our own routerinfo. * unreachable. If so, launch a new test for it. * * * For ORPort, we simply try making a circuit that ends at ourselves. * Logs an info-level status message. If <b>orport_reachable</b> is false, * Success is noticed in onionskin_answer(). * call it a reachability circuit. Otherwise, call it a bandwidth circuit. * * * For DirPort, we make a connection via Tor to our DirPort and ask * See router_do_reachability_checks() for details. */ * for our own server descriptor. static void * Success is noticed in connection_dir_client_reached_eof(). router_do_orport_reachability_checks(const routerinfo_t *me, */ int orport_reachable) void router_do_reachability_checks(int test_or, int test_dir) { { const routerinfo_t *me = router_get_my_routerinfo(); const or_options_t *options = get_options(); int orport_reachable = router_skip_orport_reachability_check(options); tor_addr_t addr; if (router_should_check_reachability(test_or, test_dir)) { if (test_or && (!orport_reachable || !circuit_enough_testing_circs())) { extend_info_t *ei = extend_info_from_router(me, AF_INET); extend_info_t *ei = extend_info_from_router(me, AF_INET); /* XXX IPv6 self testing */ /* XXX IPv6 self testing */ log_info(LD_CIRC, "Testing %s of my ORPort: %s:%d.", log_info(LD_CIRC, "Testing %s of my ORPort: %s:%d.", Loading @@ -200,12 +190,19 @@ router_do_reachability_checks(int test_or, int test_dir) extend_info_free(ei); extend_info_free(ei); } } /* XXX IPv6 self testing */ /** Launch a self-testing circuit, and ask an exit to connect to our DirPort. * <b>me</b> is our own routerinfo. * * See router_do_reachability_checks() for details. */ static void router_do_dirport_reachability_checks(const routerinfo_t *me) { tor_addr_t addr; tor_addr_from_ipv4h(&addr, me->addr); tor_addr_from_ipv4h(&addr, me->addr); if (test_dir && !router_skip_dirport_reachability_check(options) && if (!connection_get_by_type_addr_port_purpose( !connection_get_by_type_addr_port_purpose( CONN_TYPE_DIR, &addr, me->dir_port, CONN_TYPE_DIR, &addr, me->dir_port, DIR_PURPOSE_FETCH_SERVERDESC)) { DIR_PURPOSE_FETCH_SERVERDESC)) { /* XXX IPv6 self testing */ tor_addr_port_t my_dirport; tor_addr_port_t my_dirport; memcpy(&my_dirport.addr, &addr, sizeof(addr)); memcpy(&my_dirport.addr, &addr, sizeof(addr)); my_dirport.port = me->dir_port; my_dirport.port = me->dir_port; Loading @@ -222,6 +219,34 @@ router_do_reachability_checks(int test_or, int test_dir) directory_request_free(req); directory_request_free(req); } } } } /** Some time has passed, or we just got new directory information. * See if we currently believe our ORPort or DirPort to be * unreachable. If so, launch a new test for it. * * For ORPort, we simply try making a circuit that ends at ourselves. * Success is noticed in onionskin_answer(). * * For DirPort, we make a connection via Tor to our DirPort and ask * for our own server descriptor. * Success is noticed in connection_dir_client_reached_eof(). */ void router_do_reachability_checks(int test_or, int test_dir) { const routerinfo_t *me = router_get_my_routerinfo(); const or_options_t *options = get_options(); int orport_reachable = router_skip_orport_reachability_check(options); if (router_should_check_reachability(test_or, test_dir)) { if (test_or && (!orport_reachable || !circuit_enough_testing_circs())) { router_do_orport_reachability_checks(me, orport_reachable); } if (test_dir && !router_skip_dirport_reachability_check(options)) { router_do_dirport_reachability_checks(me); } } } } /** We've decided to start our reachability testing. If all /** We've decided to start our reachability testing. If all Loading