[tor-commits] [obfsproxy/master] Only mention connection statistics if we are a server.

nickm at torproject.org nickm at torproject.org
Mon Feb 13 16:37:08 UTC 2012


commit e9adc6b8e42cbedc9fb3d4e17e2b4426dac042d5
Author: George Kadianakis <desnacked at riseup.net>
Date:   Mon Feb 13 15:11:09 2012 +0200

    Only mention connection statistics if we are a server.
    
    Conflicts:
    
    	src/status.c
---
 src/network.c |    7 ++++++-
 src/status.c  |   14 +++++++++-----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/network.c b/src/network.c
index 0a6852e..4908409 100644
--- a/src/network.c
+++ b/src/network.c
@@ -551,11 +551,16 @@ open_outbound(conn_t *conn, bufferevent_data_cb readcb)
  success:
   log_info("%s (%s): Successful outbound connection to '%s'.",
            safe_str(conn->peername), conn->cfg->vtable->name, safe_str(peername));
-  status_note_connection(conn->peername);
   bufferevent_enable(buf, EV_READ|EV_WRITE);
   newconn->peername = peername;
   obfs_assert(connections);
   smartlist_add(connections, newconn);
+
+  /* If we are a server, we should note this connection and consider
+     it in our heartbeat status messages. */
+  if (conn->mode == LSN_SIMPLE_SERVER)
+    status_note_connection(conn->peername);
+
   return newconn;
 }
 
diff --git a/src/status.c b/src/status.c
index 60be008..80e1764 100644
--- a/src/status.c
+++ b/src/status.c
@@ -106,11 +106,15 @@ status_log_heartbeat(void)
   int hours = (int)((secs - (days * 86400)) / 3600);
   int last_reset_hours = (int) (now - last_reset_counters) / 3600;
   int minutes = (int)((secs - (days * 86400) - (hours * 3600)) / 60);
-  log_notice("Heartbeat: obfsproxy's uptime is %ld days, %d hours, and "
-           "%d minutes. During the last %d hours we saw %d connections "
-           "from %d unique addresses.",
-           days, hours, minutes, last_reset_hours,
-           connections, strmap_size(addresses));
+  log_info("Heartbeat: obfsproxy's uptime is %ld days, %d hours, and "
+           "%d minutes.", days, hours, minutes);
+
+  /* Also log connection stats, if we are keeping notes. */
+  if (strmap_size(addresses) > 0)
+    log_info("Heartbeat: During the last %d hours we saw %d connections "
+             "from %d unique addresses.",
+             last_reset_hours, connections, strmap_size(addresses));
+
   if (now - last_reset_counters >= RESET_COUNTERS) {
     log_info("Resetting connection counters.");
     connections_clear(1);





More information about the tor-commits mailing list