mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2025-02-25 07:07:52 +01:00
Using router_get_my_routerinfo()
This commit is contained in:
parent
2d879bd39f
commit
c30be5a82d
3 changed files with 13 additions and 14 deletions
|
@ -1111,7 +1111,6 @@ connection_listener_new(const struct sockaddr *listensockaddr,
|
||||||
start_reading = 1;
|
start_reading = 1;
|
||||||
|
|
||||||
tor_addr_from_sockaddr(&addr, listensockaddr, &usePort);
|
tor_addr_from_sockaddr(&addr, listensockaddr, &usePort);
|
||||||
|
|
||||||
log_notice(LD_NET, "Opening %s on %s",
|
log_notice(LD_NET, "Opening %s on %s",
|
||||||
conn_type_to_string(type), fmt_addrport(&addr, usePort));
|
conn_type_to_string(type), fmt_addrport(&addr, usePort));
|
||||||
|
|
||||||
|
|
|
@ -3103,7 +3103,7 @@ dirserv_get_routerdescs(smartlist_t *descs_out, const char *key,
|
||||||
DSR_HEX|DSR_SORT_UNIQ);
|
DSR_HEX|DSR_SORT_UNIQ);
|
||||||
SMARTLIST_FOREACH_BEGIN(digests, const char *, d) {
|
SMARTLIST_FOREACH_BEGIN(digests, const char *, d) {
|
||||||
if (router_digest_is_me(d)) {
|
if (router_digest_is_me(d)) {
|
||||||
/* make sure desc_routerinfo exists */
|
/* calling router_get_my_routerinfo() to make sure desc_routerinfo exists */
|
||||||
const routerinfo_t *ri = router_get_my_routerinfo();
|
const routerinfo_t *ri = router_get_my_routerinfo();
|
||||||
if (ri)
|
if (ri)
|
||||||
smartlist_add(descs_out, (void*) &(ri->cache_info));
|
smartlist_add(descs_out, (void*) &(ri->cache_info));
|
||||||
|
|
|
@ -1747,14 +1747,14 @@ router_compare_to_my_exit_policy(const tor_addr_t *addr, uint16_t port)
|
||||||
if (tor_addr_is_null(addr))
|
if (tor_addr_is_null(addr))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* look at desc_routerinfo->exit_policy for both the v4 and the v6
|
/* look at router_get_my_routerinfo()->exit_policy for both the v4 and the v6
|
||||||
* policies. The exit_policy field in desc_routerinfo is a bit unusual,
|
* policies. The exit_policy field in router_get_my_routerinfo() is a bit unusual,
|
||||||
* in that it contains IPv6 and IPv6 entries. We don't want to look
|
* in that it contains IPv6 and IPv6 entries. We don't want to look
|
||||||
* at desc_routerinfio->ipv6_exit_policy, since that's a port summary. */
|
* at router_get_my_routerinfo()->ipv6_exit_policy, since that's a port summary. */
|
||||||
if ((tor_addr_family(addr) == AF_INET ||
|
if ((tor_addr_family(addr) == AF_INET ||
|
||||||
tor_addr_family(addr) == AF_INET6)) {
|
tor_addr_family(addr) == AF_INET6)) {
|
||||||
return compare_tor_addr_to_addr_policy(addr, port,
|
return compare_tor_addr_to_addr_policy(addr, port,
|
||||||
desc_routerinfo->exit_policy) != ADDR_POLICY_ACCEPTED;
|
router_get_my_routerinfo()->exit_policy) != ADDR_POLICY_ACCEPTED;
|
||||||
#if 0
|
#if 0
|
||||||
} else if (tor_addr_family(addr) == AF_INET6) {
|
} else if (tor_addr_family(addr) == AF_INET6) {
|
||||||
return get_options()->IPv6Exit &&
|
return get_options()->IPv6Exit &&
|
||||||
|
@ -1775,7 +1775,7 @@ router_my_exit_policy_is_reject_star,(void))
|
||||||
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
|
if (!router_get_my_routerinfo()) /* make sure desc_routerinfo exists */
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return desc_routerinfo->policy_is_reject_star;
|
return router_get_my_routerinfo()->policy_is_reject_star;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Return true iff I'm a server and <b>digest</b> is equal to
|
/** Return true iff I'm a server and <b>digest</b> is equal to
|
||||||
|
@ -1836,10 +1836,10 @@ router_get_my_descriptor(void)
|
||||||
const char *body;
|
const char *body;
|
||||||
if (!router_get_my_routerinfo())
|
if (!router_get_my_routerinfo())
|
||||||
return NULL;
|
return NULL;
|
||||||
tor_assert(desc_routerinfo->cache_info.saved_location == SAVED_NOWHERE);
|
tor_assert(router_get_my_routerinfo()->cache_info.saved_location == SAVED_NOWHERE);
|
||||||
body = signed_descriptor_get_body(&desc_routerinfo->cache_info);
|
body = signed_descriptor_get_body(&router_get_my_routerinfo()->cache_info);
|
||||||
/* Make sure this is nul-terminated. */
|
/* Make sure this is nul-terminated. */
|
||||||
tor_assert(!body[desc_routerinfo->cache_info.signed_descriptor_len]);
|
tor_assert(!body[router_get_my_routerinfo()->cache_info.signed_descriptor_len]);
|
||||||
log_debug(LD_GENERAL,"my desc is '%s'", body);
|
log_debug(LD_GENERAL,"my desc is '%s'", body);
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
@ -2242,10 +2242,10 @@ check_descriptor_bandwidth_changed(time_t now)
|
||||||
{
|
{
|
||||||
static time_t last_changed = 0;
|
static time_t last_changed = 0;
|
||||||
uint64_t prev, cur;
|
uint64_t prev, cur;
|
||||||
if (!desc_routerinfo)
|
if (!router_get_my_routerinfo())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
prev = desc_routerinfo->bandwidthcapacity;
|
prev = router_get_my_routerinfo()->bandwidthcapacity;
|
||||||
cur = we_are_hibernating() ? 0 : rep_hist_bandwidth_assess();
|
cur = we_are_hibernating() ? 0 : rep_hist_bandwidth_assess();
|
||||||
if ((prev != cur && (!prev || !cur)) ||
|
if ((prev != cur && (!prev || !cur)) ||
|
||||||
cur > prev*2 ||
|
cur > prev*2 ||
|
||||||
|
@ -2299,11 +2299,11 @@ check_descriptor_ipaddress_changed(time_t now)
|
||||||
|
|
||||||
(void) now;
|
(void) now;
|
||||||
|
|
||||||
if (!desc_routerinfo)
|
if (router_get_my_routerinfo() == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* XXXX ipv6 */
|
/* XXXX ipv6 */
|
||||||
prev = desc_routerinfo->addr;
|
prev = router_get_my_routerinfo()->addr;
|
||||||
if (resolve_my_address(LOG_INFO, options, &cur, &method, &hostname) < 0) {
|
if (resolve_my_address(LOG_INFO, options, &cur, &method, &hostname) < 0) {
|
||||||
log_info(LD_CONFIG,"options->Address didn't resolve into an IP.");
|
log_info(LD_CONFIG,"options->Address didn't resolve into an IP.");
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue