Commit 4d6af73d authored by Karsten Loesing's avatar Karsten Loesing Committed by Nick Mathewson
Browse files

If configured, write per-port exit statistics to disk periodically.

[Original patch series from Karsten, revised and squashed by Nick]
parent 078c34e2
Loading
Loading
Loading
Loading
+4 −0
Changes for ChangeLog: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -17,6 +17,10 @@ Changes in version 0.2.2.1-alpha - 2009-??-??
      help debug some conceivable causes of bug 930.
    - Directories that are configured with the --enable-geoip-stats flag
      now write their GeoIP stats to disk exactly every 24 hours.
    - Exit nodes can write statistics on the number of exit streams and
      transferred bytes per port to disk every 24 hours.  To enable this,
      run configure with the --enable-exit-stats option, and set
      "ExitPortStatistics 1" in your torrc.

  o Minor bugfixes
    - Hidden service clients didn't use a cached service descriptor that
+7 −0
Changes for configure.in: 7 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -85,6 +85,13 @@ case $host in
     ;;
esac

AC_ARG_ENABLE(exit-stats,
     AS_HELP_STRING(--enable-exit-stats, enable code for exits to collect per-port statistics))

if test "$enable_exit_stats" = "yes"; then
  AC_DEFINE(ENABLE_EXIT_STATS, 1, [Defined if we try to collect per-port statistics on exits])
fi

AC_ARG_ENABLE(geoip-stats,
     AS_HELP_STRING(--enable-geoip-stats, enable code for directories to collect per-country statistics))

+11 −0
Changes for src/or/config.c: 11 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -205,6 +205,7 @@ static config_var_t _option_vars[] = {
  V(ExitNodes,                   ROUTERSET, NULL),
  V(ExitPolicy,                  LINELIST, NULL),
  V(ExitPolicyRejectPrivate,     BOOL,     "1"),
  V(ExitPortStatistics,          BOOL,     "0"),
  V(FallbackNetworkstatusFile,   FILENAME,
    SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "fallback-consensus"),
  V(FascistFirewall,             BOOL,     "0"),
@@ -1383,6 +1384,16 @@ options_act(or_options_t *old_options)
  log_notice(LD_CONFIG, "Configured to measure usage by country and "
    "write aggregate statistics to disk. Check the geoip-stats file "
    "in your data directory once I've been running for 24 hours.");
#endif
#ifdef ENABLE_EXIT_STATS
  if (options->ExitPortStatistics)
    log_notice(LD_CONFIG, "Configured to measure exit port statistics. "
               "Look for the exit-stats file that will first be written to "
               "the data directory in 24 hours from now.");
#else
  if (options->ExitPortStatistics)
    log_warn(LD_CONFIG, "ExitPortStatistics enabled, but Tor was built "
             "without port statistics support.");
#endif
  /* Check if we need to parse and add the EntryNodes config option. */
  if (options->EntryNodes &&
+8 −2
Changes for src/or/connection.c: 8 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -1702,10 +1702,16 @@ connection_buckets_decrement(connection_t *conn, time_t now,
    tor_fragile_assert();
  }

  if (num_read > 0)
  if (num_read > 0) {
    if (conn->type == CONN_TYPE_EXIT)
      rep_hist_note_exit_bytes_read(conn->port, num_read, now);
    rep_hist_note_bytes_read(num_read, now);
  if (num_written > 0)
  }
  if (num_written > 0) {
    if (conn->type == CONN_TYPE_EXIT)
      rep_hist_note_exit_bytes_written(conn->port, num_written, now);
    rep_hist_note_bytes_written(num_written, now);
  }

  if (connection_counts_as_relayed_traffic(conn, now)) {
    global_relayed_read_bucket -= (int)num_read;
+2 −0
Changes for src/or/connection_edge.c: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -333,6 +333,8 @@ connection_edge_finished_connecting(edge_connection_t *edge_conn)
           escaped_safe_str(conn->address),conn->port,
           safe_str(fmt_addr(&conn->addr)));

  rep_hist_note_exit_stream_opened(conn->port, approx_time());

  conn->state = EXIT_CONN_STATE_OPEN;
  connection_watch_events(conn, READ_EVENT); /* stop writing, keep reading */
  if (connection_wants_to_flush(conn)) /* in case there are any queued relay
Loading