[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] connection_describe_peer(): add nonzero ports to nonscrubbed addrs.



commit aa33b88778c2eda110eb79cfe887621853010287
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Mon Jul 13 14:47:58 2020 -0400

    connection_describe_peer(): add nonzero ports to nonscrubbed addrs.
---
 src/core/mainloop/connection.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c
index bde002fd2e..a3cebfecdd 100644
--- a/src/core/mainloop/connection.c
+++ b/src/core/mainloop/connection.c
@@ -461,8 +461,15 @@ connection_describe_peer_internal(const connection_t *conn,
     }
   }
 
-  if (scrub) {
-    address = safe_str(address);
+  char portbuf[7];
+  portbuf[0]=0;
+  if (scrub && get_options()->SafeLogging_ != SAFELOG_SCRUB_NONE) {
+    address = "[scrubbed]";
+  } else {
+    /* Only set the port if we're not scrubbing the address. */
+    if (conn->port != 0) {
+      tor_snprintf(portbuf, sizeof(portbuf), ":%d", conn->port);
+    }
   }
 
   const char *sp = include_preposition ? " " : "";
@@ -470,7 +477,7 @@ connection_describe_peer_internal(const connection_t *conn,
     prep = "";
 
   tor_snprintf(peer_buf, sizeof(peer_buf),
-               "%s%s%s%s", prep, sp, address, extra_buf);
+               "%s%s%s%s%s", prep, sp, address, portbuf, extra_buf);
   return peer_buf;
 }
 



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits