aboutsummaryrefslogtreecommitdiff
path: root/src/core/mainloop
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2020-07-15 16:56:37 -0400
committerNick Mathewson <nickm@torproject.org>2020-07-16 09:02:10 -0400
commit9b5567df4eee09ab23dce3dec18801c57e39388b (patch)
tree94dee57dd1c8b1b6b3ba0efe6a8ad15b92748118 /src/core/mainloop
parentae8072e8ff57b7c809de825370518b6377e4478a (diff)
downloadtor-9b5567df4eee09ab23dce3dec18801c57e39388b.tar.gz
tor-9b5567df4eee09ab23dce3dec18801c57e39388b.zip
Improvements to output format for OR connection descriptions.
Only log the 'real_addr' when it is set to something. Only log the ID when it is set. When scrubbing the address, don't include a canonical address. (There should never be a canonical address for a connection with no ID set.)
Diffstat (limited to 'src/core/mainloop')
-rw-r--r--src/core/mainloop/connection.c22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index be952fdedf..282d90c2b0 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -418,20 +418,26 @@ connection_describe_peer_internal(const connection_t *conn,
} else if (conn->type == CONN_TYPE_OR) {
/* For OR connections, we have a lot to do. */
const or_connection_t *or_conn = TO_OR_CONN((connection_t *)conn);
- char id_buf[HEX_DIGEST_LEN+1];
- /* we report 'real_addr' as the address we're talking with */
- addr = &or_conn->real_addr;
+ /* we report 'real_addr' as the address we're talking with, if it's set.
+ *
+ * TODO: Eventually we should have 'addr' always mean the address on the
+ * internet, and have a separate 'canonical_addr' field.
+ */
+ if (!tor_addr_is_null(&or_conn->real_addr)) {
+ addr = &or_conn->real_addr;
+ }
/* We report the IDs we're talking to... */
if (fast_digest_is_zero(or_conn->identity_digest)) {
- strlcpy(id_buf, "unknown", sizeof(id_buf));
- scrub = true; // This could be a client, so scrub it.
+ // This could be a client, so scrub it. No identity to report.
+ scrub = true;
} else {
+ char id_buf[HEX_DIGEST_LEN+1];
base16_encode(id_buf, sizeof(id_buf),
or_conn->identity_digest, DIGEST_LEN);
+ tor_snprintf(extra_buf, sizeof(extra_buf),
+ " ID=%s", id_buf);
}
- tor_snprintf(extra_buf, sizeof(extra_buf),
- " ID=%s", id_buf);
- if (! tor_addr_eq(addr, &conn->addr)) {
+ if (! tor_addr_eq(addr, &conn->addr) && !scrub) {
/* We report canonical address, if it's different */
char canonical_addr_buf[TOR_ADDR_BUF_LEN];
if (tor_addr_to_str(canonical_addr_buf, &conn->addr,