mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 20:33:31 +01:00
Add exit policy and bw to dirvotes - unfortunately also to v2 statuses
svn:r16536
This commit is contained in:
parent
91f654f2ff
commit
24da63ea7b
@ -1866,11 +1866,27 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
|||||||
int r;
|
int r;
|
||||||
struct in_addr in;
|
struct in_addr in;
|
||||||
char *cp;
|
char *cp;
|
||||||
|
char *summary;
|
||||||
|
|
||||||
char published[ISO_TIME_LEN+1];
|
char published[ISO_TIME_LEN+1];
|
||||||
char ipaddr[INET_NTOA_BUF_LEN];
|
char ipaddr[INET_NTOA_BUF_LEN];
|
||||||
char identity64[BASE64_DIGEST_LEN+1];
|
char identity64[BASE64_DIGEST_LEN+1];
|
||||||
char digest64[BASE64_DIGEST_LEN+1];
|
char digest64[BASE64_DIGEST_LEN+1];
|
||||||
|
routerinfo_t* desc = router_get_by_digest(rs->identity_digest);
|
||||||
|
|
||||||
|
if (!desc) {
|
||||||
|
char id[HEX_DIGEST_LEN+1];
|
||||||
|
char dd[HEX_DIGEST_LEN+1];
|
||||||
|
|
||||||
|
base16_encode(id, sizeof(id), rs->identity_digest, DIGEST_LEN);
|
||||||
|
base16_encode(dd, sizeof(dd), rs->descriptor_digest, DIGEST_LEN);
|
||||||
|
log_warn(LD_BUG, "Cannot get the descriptor with digest %s for %s.",
|
||||||
|
id, dd);
|
||||||
|
return -1;
|
||||||
|
};
|
||||||
|
tor_assert(!memcmp(desc->cache_info.signed_descriptor_digest,
|
||||||
|
rs->descriptor_digest,
|
||||||
|
DIGEST_LEN));
|
||||||
|
|
||||||
format_iso_time(published, rs->published_on);
|
format_iso_time(published, rs->published_on);
|
||||||
digest_to_base64(identity64, rs->identity_digest);
|
digest_to_base64(identity64, rs->identity_digest);
|
||||||
@ -1896,7 +1912,8 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
|||||||
cp = buf + strlen(buf);
|
cp = buf + strlen(buf);
|
||||||
/* NOTE: Whenever this list expands, be sure to increase MAX_FLAG_LINE_LEN*/
|
/* NOTE: Whenever this list expands, be sure to increase MAX_FLAG_LINE_LEN*/
|
||||||
r = tor_snprintf(cp, buf_len - (cp-buf),
|
r = tor_snprintf(cp, buf_len - (cp-buf),
|
||||||
"s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
|
"s%s%s%s%s%s%s%s%s%s%s%s%s%s\n"
|
||||||
|
"w Bandwidth=%d\n",
|
||||||
/* These must stay in alphabetical order. */
|
/* These must stay in alphabetical order. */
|
||||||
rs->is_authority?" Authority":"",
|
rs->is_authority?" Authority":"",
|
||||||
rs->is_bad_directory?" BadDirectory":"",
|
rs->is_bad_directory?" BadDirectory":"",
|
||||||
@ -1910,7 +1927,8 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
|||||||
rs->is_stable?" Stable":"",
|
rs->is_stable?" Stable":"",
|
||||||
rs->is_unnamed?" Unnamed":"",
|
rs->is_unnamed?" Unnamed":"",
|
||||||
rs->is_v2_dir?" V2Dir":"",
|
rs->is_v2_dir?" V2Dir":"",
|
||||||
rs->is_valid?" Valid":"");
|
rs->is_valid?" Valid":"",
|
||||||
|
router_get_advertised_bandwidth_capped(desc));
|
||||||
if (r<0) {
|
if (r<0) {
|
||||||
log_warn(LD_BUG, "Not enough space in buffer.");
|
log_warn(LD_BUG, "Not enough space in buffer.");
|
||||||
return -1;
|
return -1;
|
||||||
@ -1926,6 +1944,16 @@ routerstatus_format_entry(char *buf, size_t buf_len,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
summary = policy_summarize(desc->exit_policy);
|
||||||
|
if (summary) {
|
||||||
|
r = tor_snprintf(cp, buf_len - (cp-buf), "p %s\n", summary);
|
||||||
|
if (r<0) {
|
||||||
|
log_warn(LD_BUG, "Not enough space in buffer.");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
tor_free(summary);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1431,6 +1431,19 @@ router_get_advertised_bandwidth(routerinfo_t *router)
|
|||||||
* routers by bandwidth. */
|
* routers by bandwidth. */
|
||||||
#define DEFAULT_MAX_BELIEVABLE_BANDWIDTH 10000000 /* 10 MB/sec */
|
#define DEFAULT_MAX_BELIEVABLE_BANDWIDTH 10000000 /* 10 MB/sec */
|
||||||
|
|
||||||
|
/** Return the smaller of the router's configured BandwidthRate
|
||||||
|
* and its advertised capacity, capped by max-believe-bw. */
|
||||||
|
uint32_t
|
||||||
|
router_get_advertised_bandwidth_capped(routerinfo_t *router)
|
||||||
|
{
|
||||||
|
uint32_t result = router->bandwidthcapacity;
|
||||||
|
if (result > router->bandwidthrate)
|
||||||
|
result = router->bandwidthrate;
|
||||||
|
if (result > DEFAULT_MAX_BELIEVABLE_BANDWIDTH)
|
||||||
|
result = DEFAULT_MAX_BELIEVABLE_BANDWIDTH;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/** Eventually, the number we return will come from the directory
|
/** Eventually, the number we return will come from the directory
|
||||||
* consensus, so clients can dynamically update to better numbers.
|
* consensus, so clients can dynamically update to better numbers.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user