[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] [tor/master 06/11] Do not emit an extra-info-digest descriptor line if the digest is zero.
Author: Robert Ransom <rransom.8774@xxxxxxxxx>
Date: Sun, 14 Nov 2010 22:17:32 -0800
Subject: Do not emit an extra-info-digest descriptor line if the digest is zero.
Commit: 213bcb3c4022ef3535a50f2d9375ba79eccf11b4
---
src/or/router.c | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/or/router.c b/src/or/router.c
index 725a515..2705a78 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1746,6 +1746,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
char digest[DIGEST_LEN];
char published[ISO_TIME_LEN+1];
char fingerprint[FINGERPRINT_LEN+1];
+ int has_extra_info_digest;
char extra_info_digest[HEX_DIGEST_LEN+1];
size_t onion_pkeylen, identity_pkeylen;
size_t written;
@@ -1796,8 +1797,13 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
family_line = tor_strdup("");
}
- base16_encode(extra_info_digest, sizeof(extra_info_digest),
- router->cache_info.extra_info_digest, DIGEST_LEN);
+ has_extra_info_digest =
+ tor_digest_is_zero(router->cache_info.extra_info_digest);
+
+ if (has_extra_info_digest) {
+ base16_encode(extra_info_digest, sizeof(extra_info_digest),
+ router->cache_info.extra_info_digest, DIGEST_LEN);
+ }
/* Generate the easy portion of the router descriptor. */
result = tor_snprintf(s, maxlen,
@@ -1808,7 +1814,7 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
"opt fingerprint %s\n"
"uptime %ld\n"
"bandwidth %d %d %d\n"
- "opt extra-info-digest %s\n%s"
+ "%s%s%s%s"
"onion-key\n%s"
"signing-key\n%s"
"%s%s%s%s",
@@ -1823,7 +1829,9 @@ router_dump_router_to_string(char *s, size_t maxlen, routerinfo_t *router,
(int) router->bandwidthrate,
(int) router->bandwidthburst,
(int) router->bandwidthcapacity,
- extra_info_digest,
+ has_extra_info_digest ? "opt extra-info-digest " : "",
+ has_extra_info_digest ? extra_info_digest : "",
+ has_extra_info_digest ? "\n" : "",
options->DownloadExtraInfo ? "opt caches-extra-info\n" : "",
onion_pkey, identity_pkey,
family_line,
--
1.7.1