mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 02:09:24 +01:00
Remove ./configure option for entry and dir request statistics.
This commit is contained in:
parent
9d16a59fcc
commit
ab7729f472
14
configure.in
14
configure.in
@ -92,20 +92,6 @@ if test "$enable_dirreq_stats" = "yes"; then
|
||||
AC_DEFINE(ENABLE_DIRREQ_STATS, 1, [Defined if we try to collect per-country statistics])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(buffer-stats,
|
||||
AS_HELP_STRING(--enable-buffer-stats, enable code for relays to collect buffer statistics))
|
||||
|
||||
if test "$enable_buffer_stats" = "yes"; then
|
||||
AC_DEFINE(ENABLE_BUFFER_STATS, 1, [Defined if we try to collect buffer statistics])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(entry-stats,
|
||||
AS_HELP_STRING(--enable-entry-stats, enable code for entry guards to collect per-country statistics))
|
||||
|
||||
if test "$enable_entry_stats" = "yes"; then
|
||||
AC_DEFINE(ENABLE_ENTRY_STATS, 1, [Defined if we try to collect per-country statistics])
|
||||
fi
|
||||
|
||||
AC_ARG_ENABLE(gcc-warnings,
|
||||
AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings))
|
||||
|
||||
|
@ -188,12 +188,10 @@ static config_var_t _option_vars[] = {
|
||||
V(DirPort, UINT, "0"),
|
||||
V(DirPortFrontPage, FILENAME, NULL),
|
||||
OBSOLETE("DirPostPeriod"),
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
OBSOLETE("DirRecordUsageByCountry"),
|
||||
OBSOLETE("DirRecordUsageGranularity"),
|
||||
OBSOLETE("DirRecordUsageRetainIPs"),
|
||||
OBSOLETE("DirRecordUsageSaveInterval"),
|
||||
#endif
|
||||
V(DirReqStatistics, BOOL, "0"),
|
||||
VAR("DirServer", LINELIST, DirServers, NULL),
|
||||
V(DNSPort, UINT, "0"),
|
||||
@ -1409,7 +1407,6 @@ options_act(or_options_t *old_options)
|
||||
}
|
||||
|
||||
if (options->DirReqStatistics) {
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* Check if GeoIP database could be loaded. */
|
||||
if (!geoip_is_loaded()) {
|
||||
log_warn(LD_CONFIG, "Configured to measure directory request "
|
||||
@ -1420,10 +1417,6 @@ options_act(or_options_t *old_options)
|
||||
"country and write aggregate statistics to disk. Check the "
|
||||
"dirreq-stats file in your data directory that will first "
|
||||
"be written in 24 hours from now.");
|
||||
#else
|
||||
log_warn(LD_CONFIG, "DirReqStatistics enabled, but Tor was built "
|
||||
"without support for directory request statistics.");
|
||||
#endif
|
||||
}
|
||||
|
||||
if (options->ExitPortStatistics)
|
||||
@ -1442,7 +1435,6 @@ options_act(or_options_t *old_options)
|
||||
"without cell statistics support.");
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_ENTRY_STATS
|
||||
if (options->EntryStatistics) {
|
||||
if (should_record_bridge_info(options)) {
|
||||
/* Don't allow measuring statistics on entry guards when configured
|
||||
@ -1461,11 +1453,7 @@ options_act(or_options_t *old_options)
|
||||
"first be written to the data directory in 24 hours "
|
||||
"from now.");
|
||||
}
|
||||
#else
|
||||
if (options->EntryStatistics)
|
||||
log_warn(LD_CONFIG, "EntryStatistics enabled, but Tor was built "
|
||||
"without entry node statistics support.");
|
||||
#endif
|
||||
|
||||
/* Check if we need to parse and add the EntryNodes config option. */
|
||||
if (options->EntryNodes &&
|
||||
(!old_options ||
|
||||
|
@ -2302,13 +2302,11 @@ connection_handle_write(connection_t *conn, int force)
|
||||
/* else open, or closing */
|
||||
result = flush_buf_tls(or_conn->tls, conn->outbuf,
|
||||
max_to_write, &conn->outbuf_flushlen);
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* If we just flushed the last bytes, check if this tunneled dir
|
||||
* request is done. */
|
||||
if (buf_datalen(conn->outbuf) == 0 && conn->dirreq_id)
|
||||
geoip_change_dirreq_state(conn->dirreq_id, DIRREQ_TUNNELED,
|
||||
DIRREQ_OR_CONN_BUFFER_FLUSHED);
|
||||
#endif
|
||||
switch (result) {
|
||||
CASE_TOR_TLS_ERROR_ANY:
|
||||
case TOR_TLS_CLOSE:
|
||||
|
@ -2544,11 +2544,9 @@ connection_exit_begin_conn(cell_t *cell, circuit_t *circ)
|
||||
|
||||
log_debug(LD_EXIT,"Creating new exit connection.");
|
||||
n_stream = edge_connection_new(CONN_TYPE_EXIT, AF_INET);
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* Remember the tunneled request ID in the new edge connection, so that
|
||||
* we can measure download times. */
|
||||
TO_CONN(n_stream)->dirreq_id = circ->dirreq_id;
|
||||
#endif
|
||||
n_stream->_base.purpose = EXIT_PURPOSE_CONNECT;
|
||||
|
||||
n_stream->stream_id = rh.stream_id;
|
||||
@ -2785,11 +2783,9 @@ connection_exit_connect_dir(edge_connection_t *exitconn)
|
||||
dirconn->_base.purpose = DIR_PURPOSE_SERVER;
|
||||
dirconn->_base.state = DIR_CONN_STATE_SERVER_COMMAND_WAIT;
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* Note that the new dir conn belongs to the same tunneled request as
|
||||
* the edge conn, so that we can measure download times. */
|
||||
TO_CONN(dirconn)->dirreq_id = TO_CONN(exitconn)->dirreq_id;
|
||||
#endif
|
||||
connection_link_connections(TO_CONN(dirconn), TO_CONN(exitconn));
|
||||
|
||||
if (connection_add(TO_CONN(exitconn))<0) {
|
||||
|
@ -2562,7 +2562,6 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
goto done;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
{
|
||||
struct in_addr in;
|
||||
if (tor_inet_aton((TO_CONN(conn))->address, &in)) {
|
||||
@ -2578,7 +2577,6 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
|
||||
DIRREQ_DIRECT);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// note_request(request_type,dlen);
|
||||
(void) request_type;
|
||||
@ -3210,7 +3208,6 @@ connection_dir_finished_flushing(dir_connection_t *conn)
|
||||
tor_assert(conn);
|
||||
tor_assert(conn->_base.type == CONN_TYPE_DIR);
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* Note that we have finished writing the directory response. For direct
|
||||
* connections this means we're done, for tunneled connections its only
|
||||
* an intermediate step. */
|
||||
@ -3221,7 +3218,6 @@ connection_dir_finished_flushing(dir_connection_t *conn)
|
||||
geoip_change_dirreq_state(TO_CONN(conn)->global_identifier,
|
||||
DIRREQ_DIRECT,
|
||||
DIRREQ_FLUSHING_DIR_CONN_FINISHED);
|
||||
#endif
|
||||
switch (conn->_base.state) {
|
||||
case DIR_CONN_STATE_CLIENT_SENDING:
|
||||
log_debug(LD_DIR,"client finished sending command.");
|
||||
|
@ -347,7 +347,6 @@ geoip_determine_shares(time_t now)
|
||||
last_time_determined_shares = now;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/** Calculate which fraction of v2 and v3 directory requests aimed at caches
|
||||
* have been sent to us since the last call of this function up to time
|
||||
* <b>now</b>. Set *<b>v2_share_out</b> and *<b>v3_share_out</b> to the
|
||||
@ -367,7 +366,6 @@ geoip_get_mean_shares(time_t now, double *v2_share_out,
|
||||
share_seconds = 0;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Note that we've seen a client connect from the IP <b>addr</b> (host order)
|
||||
* at time <b>now</b>. Ignored by all but bridges and directories if
|
||||
@ -379,24 +377,17 @@ geoip_note_client_seen(geoip_client_action_t action,
|
||||
or_options_t *options = get_options();
|
||||
clientmap_entry_t lookup, *ent;
|
||||
if (action == GEOIP_CLIENT_CONNECT) {
|
||||
#ifdef ENABLE_ENTRY_STATS
|
||||
if (!options->EntryStatistics)
|
||||
/* Only remember statistics as entry guard or as bridge. */
|
||||
if (!options->EntryStatistics ||
|
||||
(!(options->BridgeRelay && options->BridgeRecordUsageByCountry)))
|
||||
return;
|
||||
#else
|
||||
if (!(options->BridgeRelay && options->BridgeRecordUsageByCountry))
|
||||
return;
|
||||
#endif
|
||||
/* Did we recently switch from bridge to relay or back? */
|
||||
if (client_history_starts > now)
|
||||
return;
|
||||
} else {
|
||||
#ifndef ENABLE_DIRREQ_STATS
|
||||
return;
|
||||
#else
|
||||
if (options->BridgeRelay || options->BridgeAuthoritativeDir ||
|
||||
!options->DirReqStatistics)
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Rotate the current request period. */
|
||||
@ -495,7 +486,6 @@ geoip_remove_old_clients(time_t cutoff)
|
||||
client_history_starts = cutoff;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/** How many responses are we giving to clients requesting v2 network
|
||||
* statuses? */
|
||||
static uint32_t ns_v2_responses[GEOIP_NS_RESPONSE_NUM];
|
||||
@ -503,7 +493,6 @@ static uint32_t ns_v2_responses[GEOIP_NS_RESPONSE_NUM];
|
||||
/** How many responses are we giving to clients requesting v3 network
|
||||
* statuses? */
|
||||
static uint32_t ns_v3_responses[GEOIP_NS_RESPONSE_NUM];
|
||||
#endif
|
||||
|
||||
/** Note that we've rejected a client's request for a v2 or v3 network
|
||||
* status, encoded in <b>action</b> for reason <b>reason</b> at time
|
||||
@ -512,7 +501,6 @@ void
|
||||
geoip_note_ns_response(geoip_client_action_t action,
|
||||
geoip_ns_response_t response)
|
||||
{
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
static int arrays_initialized = 0;
|
||||
if (!get_options()->DirReqStatistics)
|
||||
return;
|
||||
@ -528,10 +516,6 @@ geoip_note_ns_response(geoip_client_action_t action,
|
||||
ns_v3_responses[response]++;
|
||||
else
|
||||
ns_v2_responses[response]++;
|
||||
#else
|
||||
(void) action;
|
||||
(void) response;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Do not mention any country from which fewer than this number of IPs have
|
||||
@ -709,7 +693,6 @@ geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/** Return a newly allocated comma-separated string containing statistics
|
||||
* on network status downloads. The string contains the number of completed
|
||||
* requests, timeouts, and still running requests as well as the download
|
||||
@ -800,25 +783,18 @@ geoip_get_dirreq_history(geoip_client_action_t action,
|
||||
smartlist_free(dirreq_times);
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** How long do we have to have observed per-country request history before we
|
||||
* are willing to talk about it? */
|
||||
#define GEOIP_MIN_OBSERVATION_TIME (12*60*60)
|
||||
|
||||
/** Return a newly allocated comma-separated string containing entries for all
|
||||
* the countries from which we've seen enough clients connect. The entry
|
||||
* format is cc=num where num is the number of IPs we've seen connecting from
|
||||
* that country, and cc is a lowercased country code. Returns NULL if we don't
|
||||
* want to export geoip data yet. */
|
||||
char *
|
||||
geoip_get_client_history(time_t now, geoip_client_action_t action)
|
||||
/** Helper for geoip_get_client_history_dirreq() and
|
||||
* geoip_get_client_history_bridge(). */
|
||||
static char *
|
||||
geoip_get_client_history(time_t now, geoip_client_action_t action,
|
||||
int min_observation_time, unsigned granularity)
|
||||
{
|
||||
char *result = NULL;
|
||||
int min_observation_time = GEOIP_MIN_OBSERVATION_TIME;
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
min_observation_time = DIR_RECORD_USAGE_MIN_OBSERVATION_TIME;
|
||||
#endif
|
||||
if (!geoip_is_loaded())
|
||||
return NULL;
|
||||
if (client_history_starts < (now - min_observation_time)) {
|
||||
@ -830,10 +806,6 @@ geoip_get_client_history(time_t now, geoip_client_action_t action)
|
||||
clientmap_entry_t **ent;
|
||||
unsigned *counts = tor_malloc_zero(sizeof(unsigned)*n_countries);
|
||||
unsigned total = 0;
|
||||
unsigned granularity = IP_GRANULARITY;
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
granularity = DIR_RECORD_USAGE_GRANULARITY;
|
||||
#endif
|
||||
HT_FOREACH(ent, clientmap, &client_history) {
|
||||
int country;
|
||||
if ((*ent)->action != (int)action)
|
||||
@ -889,6 +861,34 @@ geoip_get_client_history(time_t now, geoip_client_action_t action)
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Return a newly allocated comma-separated string containing entries for
|
||||
* all the countries from which we've seen enough clients connect as a
|
||||
* directory. The entry format is cc=num where num is the number of IPs
|
||||
* we've seen connecting from that country, and cc is a lowercased country
|
||||
* code. Returns NULL if we don't want to export geoip data yet. */
|
||||
char *
|
||||
geoip_get_client_history_dirreq(time_t now,
|
||||
geoip_client_action_t action)
|
||||
{
|
||||
return geoip_get_client_history(now, action,
|
||||
DIR_RECORD_USAGE_MIN_OBSERVATION_TIME,
|
||||
DIR_RECORD_USAGE_GRANULARITY);
|
||||
}
|
||||
|
||||
/** Return a newly allocated comma-separated string containing entries for
|
||||
* all the countries from which we've seen enough clients connect as a
|
||||
* bridge. The entry format is cc=num where num is the number of IPs
|
||||
* we've seen connecting from that country, and cc is a lowercased country
|
||||
* code. Returns NULL if we don't want to export geoip data yet. */
|
||||
char *
|
||||
geoip_get_client_history_bridge(time_t now,
|
||||
geoip_client_action_t action)
|
||||
{
|
||||
return geoip_get_client_history(now, action,
|
||||
GEOIP_MIN_OBSERVATION_TIME,
|
||||
IP_GRANULARITY);
|
||||
}
|
||||
|
||||
/** Return a newly allocated string holding the per-country request history
|
||||
* for <b>action</b> in a format suitable for an extra-info document, or NULL
|
||||
* on failure. */
|
||||
@ -899,10 +899,6 @@ geoip_get_request_history(time_t now, geoip_client_action_t action)
|
||||
char *result;
|
||||
unsigned granularity = IP_GRANULARITY;
|
||||
int min_observation_time = GEOIP_MIN_OBSERVATION_TIME;
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
granularity = DIR_RECORD_USAGE_GRANULARITY;
|
||||
min_observation_time = DIR_RECORD_USAGE_MIN_OBSERVATION_TIME;
|
||||
#endif
|
||||
|
||||
if (client_history_starts >= (now - min_observation_time))
|
||||
return NULL;
|
||||
@ -948,7 +944,6 @@ geoip_get_request_history(time_t now, geoip_client_action_t action)
|
||||
static void
|
||||
dump_geoip_stats(void)
|
||||
{
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
time_t now = time(NULL);
|
||||
time_t request_start;
|
||||
char *filename = get_datadir_fname("dirreq-stats");
|
||||
@ -962,8 +957,10 @@ dump_geoip_stats(void)
|
||||
if (!get_options()->DirReqStatistics)
|
||||
goto done;
|
||||
|
||||
data_v2 = geoip_get_client_history(now, GEOIP_CLIENT_NETWORKSTATUS_V2);
|
||||
data_v3 = geoip_get_client_history(now, GEOIP_CLIENT_NETWORKSTATUS);
|
||||
data_v2 = geoip_get_client_history_dirreq(now,
|
||||
GEOIP_CLIENT_NETWORKSTATUS_V2);
|
||||
data_v3 = geoip_get_client_history_dirreq(now,
|
||||
GEOIP_CLIENT_NETWORKSTATUS);
|
||||
format_iso_time(since, geoip_get_history_start());
|
||||
format_iso_time(written, now);
|
||||
out = start_writing_to_stdio_file(filename, OPEN_FLAGS_APPEND,
|
||||
@ -1045,7 +1042,6 @@ dump_geoip_stats(void)
|
||||
tor_free(filename);
|
||||
tor_free(data_v2);
|
||||
tor_free(data_v3);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Store all our geoip statistics as entry guards into
|
||||
|
19
src/or/or.h
19
src/or/or.h
@ -20,9 +20,6 @@
|
||||
#ifndef INSTRUMENT_DOWNLOADS
|
||||
#define INSTRUMENT_DOWNLOADS 1
|
||||
#endif
|
||||
#ifndef ENABLE_DIRREQ_STATS
|
||||
#define ENABLE_DIRREQ_STATS 1
|
||||
#endif
|
||||
#ifndef ENABLE_BUFFER_STATS
|
||||
#define ENABLE_BUFFER_STATS 1
|
||||
#endif
|
||||
@ -975,10 +972,8 @@ typedef struct connection_t {
|
||||
* to the evdns_server_port is uses to listen to and answer connections. */
|
||||
struct evdns_server_port *dns_server_port;
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/** Unique ID for measuring tunneled network status requests. */
|
||||
uint64_t dirreq_id;
|
||||
#endif
|
||||
} connection_t;
|
||||
|
||||
/** Stores flags and information related to the portion of a v2 Tor OR
|
||||
@ -1965,10 +1960,9 @@ typedef struct circuit_t {
|
||||
* linked to an OR connection. */
|
||||
struct circuit_t *prev_active_on_n_conn;
|
||||
struct circuit_t *next; /**< Next circuit in linked list of all circuits. */
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
|
||||
/** Unique ID for measuring tunneled network status requests. */
|
||||
uint64_t dirreq_id;
|
||||
#endif
|
||||
} circuit_t;
|
||||
|
||||
/** Largest number of relay_early cells that we can send on a given
|
||||
@ -3640,15 +3634,11 @@ int dnsserv_launch_request(const char *name, int is_reverse);
|
||||
* leaking information. */
|
||||
#define DIR_RECORD_USAGE_GRANULARITY 8
|
||||
/** Time interval: Flush geoip data to disk this often. */
|
||||
#define DIR_RECORD_USAGE_RETAIN_IPS (24*60*60)
|
||||
#define DIR_ENTRY_RECORD_USAGE_RETAIN_IPS (24*60*60)
|
||||
/** How long do we have to have observed per-country request history before
|
||||
* we are willing to talk about it? */
|
||||
#define DIR_RECORD_USAGE_MIN_OBSERVATION_TIME (24*60*60)
|
||||
|
||||
/** Time interval: Flush geoip data to disk this often when measuring on an
|
||||
* entry guard. */
|
||||
#define ENTRY_RECORD_USAGE_RETAIN_IPS (24*60*60)
|
||||
|
||||
#ifdef GEOIP_PRIVATE
|
||||
int geoip_parse_entry(const char *line);
|
||||
#endif
|
||||
@ -3695,7 +3685,10 @@ typedef enum {
|
||||
void geoip_note_ns_response(geoip_client_action_t action,
|
||||
geoip_ns_response_t response);
|
||||
time_t geoip_get_history_start(void);
|
||||
char *geoip_get_client_history(time_t now, geoip_client_action_t action);
|
||||
char *geoip_get_client_history_dirreq(time_t now,
|
||||
geoip_client_action_t action);
|
||||
char *geoip_get_client_history_bridge(time_t now,
|
||||
geoip_client_action_t action);
|
||||
char *geoip_get_request_history(time_t now, geoip_client_action_t action);
|
||||
int getinfo_helper_geoip(control_connection_t *control_conn,
|
||||
const char *question, char **answer);
|
||||
|
@ -533,13 +533,11 @@ relay_send_command_from_edge(uint16_t stream_id, circuit_t *circ,
|
||||
log_debug(LD_OR,"delivering %d cell %s.", relay_command,
|
||||
cell_direction == CELL_DIRECTION_OUT ? "forward" : "backward");
|
||||
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
/* If we are sending an END cell and this circuit is used for a tunneled
|
||||
* directory request, advance its state. */
|
||||
if (relay_command == RELAY_COMMAND_END && circ->dirreq_id)
|
||||
geoip_change_dirreq_state(circ->dirreq_id, DIRREQ_TUNNELED,
|
||||
DIRREQ_END_CELL_SENT);
|
||||
#endif
|
||||
|
||||
if (cell_direction == CELL_DIRECTION_OUT && circ->n_conn) {
|
||||
/* if we're using relaybandwidthrate, this conn wants priority */
|
||||
@ -1047,7 +1045,6 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
||||
"Begin cell for known stream. Dropping.");
|
||||
return 0;
|
||||
}
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
if (rh.command == RELAY_COMMAND_BEGIN_DIR) {
|
||||
/* Assign this circuit and its app-ward OR connection a unique ID,
|
||||
* so that we can measure download times. The local edge and dir
|
||||
@ -1057,7 +1054,6 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
|
||||
circ->dirreq_id = ++next_id;
|
||||
TO_CONN(TO_OR_CIRCUIT(circ)->p_conn)->dirreq_id = circ->dirreq_id;
|
||||
}
|
||||
#endif
|
||||
|
||||
return connection_exit_begin_conn(cell, circ);
|
||||
case RELAY_COMMAND_DATA:
|
||||
@ -1849,14 +1845,13 @@ connection_or_flush_from_first_active_circuit(or_connection_t *conn, int max,
|
||||
orcirc->processed_cells++;
|
||||
}
|
||||
#endif
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
|
||||
/* If we just flushed our queue and this circuit is used for a
|
||||
* tunneled directory request, possibly advance its state. */
|
||||
if (queue->n == 0 && TO_CONN(conn)->dirreq_id)
|
||||
geoip_change_dirreq_state(TO_CONN(conn)->dirreq_id,
|
||||
DIRREQ_TUNNELED,
|
||||
DIRREQ_CIRC_QUEUE_FLUSHED);
|
||||
#endif
|
||||
|
||||
connection_write_to_buf(cell->body, CELL_NETWORK_SIZE, TO_CONN(conn));
|
||||
|
||||
|
@ -1907,13 +1907,9 @@ char *
|
||||
extrainfo_get_client_geoip_summary(time_t now)
|
||||
{
|
||||
static time_t last_purged_at = 0;
|
||||
int geoip_purge_interval = 48*60*60;
|
||||
#ifdef ENABLE_DIRREQ_STATS
|
||||
geoip_purge_interval = DIR_RECORD_USAGE_RETAIN_IPS;
|
||||
#endif
|
||||
#ifdef ENABLE_ENTRY_STATS
|
||||
geoip_purge_interval = ENTRY_RECORD_USAGE_RETAIN_IPS;
|
||||
#endif
|
||||
int geoip_purge_interval =
|
||||
(get_options()->DirReqStatistics || get_options()->EntryStatistics) ?
|
||||
DIR_ENTRY_RECORD_USAGE_RETAIN_IPS : 48*60*60;
|
||||
if (now > last_purged_at+geoip_purge_interval) {
|
||||
/* (Note that this also discards items in the client history with
|
||||
* action GEOIP_CLIENT_NETWORKSTATUS{_V2}, which doesn't matter
|
||||
@ -1922,7 +1918,7 @@ extrainfo_get_client_geoip_summary(time_t now)
|
||||
geoip_remove_old_clients(now-geoip_purge_interval);
|
||||
last_purged_at = now;
|
||||
}
|
||||
return geoip_get_client_history(now, GEOIP_CLIENT_CONNECT);
|
||||
return geoip_get_client_history_bridge(now, GEOIP_CLIENT_CONNECT);
|
||||
}
|
||||
|
||||
/** Return true iff <b>s</b> is a legally valid server nickname. */
|
||||
|
@ -4625,14 +4625,16 @@ test_geoip(void)
|
||||
/* and 17 observations in ZZ... */
|
||||
for (i=110; i < 127; ++i)
|
||||
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, i, now);
|
||||
s = geoip_get_client_history(now+5*24*60*60, GEOIP_CLIENT_CONNECT);
|
||||
s = geoip_get_client_history_bridge(now+5*24*60*60,
|
||||
GEOIP_CLIENT_CONNECT);
|
||||
test_assert(s);
|
||||
test_streq("zz=24,ab=16,xy=8", s);
|
||||
tor_free(s);
|
||||
|
||||
/* Now clear out all the AB observations. */
|
||||
geoip_remove_old_clients(now-6000);
|
||||
s = geoip_get_client_history(now+5*24*60*60, GEOIP_CLIENT_CONNECT);
|
||||
s = geoip_get_client_history_bridge(now+5*24*60*60,
|
||||
GEOIP_CLIENT_CONNECT);
|
||||
test_assert(s);
|
||||
test_streq("zz=24,xy=8", s);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user