|
Tor 0.4.9.3-alpha-dev
|
Header file for geoip_stats.c. More...
#include "core/or/dos.h"#include "ext/ht.h"Go to the source code of this file.
Data Structures | |
| struct | clientmap_entry_t |
Macros | |
| #define | GEOIP_NS_RESPONSE_NUM 7 |
Enumerations | |
| enum | geoip_client_action_t { GEOIP_CLIENT_CONNECT = 0 , GEOIP_CLIENT_NETWORKSTATUS = 1 } |
| enum | geoip_ns_response_t { GEOIP_SUCCESS = 0 , GEOIP_REJECT_NOT_ENOUGH_SIGS = 1 , GEOIP_REJECT_UNAVAILABLE = 2 , GEOIP_REJECT_NOT_FOUND = 3 , GEOIP_REJECT_NOT_MODIFIED = 4 , GEOIP_REJECT_BUSY = 5 , GEOIP_SERVED = 6 } |
| enum | dirreq_type_t { DIRREQ_DIRECT = 0 , DIRREQ_TUNNELED = 1 } |
| enum | dirreq_state_t { DIRREQ_IS_FOR_NETWORK_STATUS = 0 , DIRREQ_FLUSHING_DIR_CONN_FINISHED = 1 , DIRREQ_END_CELL_SENT = 2 , DIRREQ_CIRC_QUEUE_FLUSHED = 3 , DIRREQ_CHANNEL_BUFFER_FLUSHED = 4 } |
Header file for geoip_stats.c.
Definition in file geoip_stats.h.
| #define GEOIP_NS_RESPONSE_NUM 7 |
Definition at line 48 of file geoip_stats.h.
| enum dirreq_state_t |
Possible states for either direct or tunneled directory requests that are relevant for determining network status download times.
Definition at line 59 of file geoip_stats.h.
| enum dirreq_type_t |
Directory requests that we are measuring can be either direct or tunneled.
Definition at line 52 of file geoip_stats.h.
Indicates an action that we might be noting geoip statistics on. Note that if we're noticing CONNECT, we're a bridge, and if we're noticing the others, we're not.
| Enumerator | |
|---|---|
| GEOIP_CLIENT_CONNECT | An incoming ORPort connection |
| GEOIP_CLIENT_NETWORKSTATUS | We've served a networkstatus consensus as a directory server. |
Definition at line 22 of file geoip_stats.h.
| enum geoip_ns_response_t |
Indicates either a positive reply or a reason for rejecting a network status request that will be included in geoip statistics.
Definition at line 30 of file geoip_stats.h.
| char * format_client_stats_heartbeat | ( | time_t | now | ) |
Return a newly allocated string holding our bridge usage stats by country in a format suitable for inclusion in our heartbeat message. Return NULL on failure.
Definition at line 1210 of file geoip_stats.c.
| void geoip_bridge_stats_init | ( | time_t | now | ) |
Initialize bridge stats.
Definition at line 1069 of file geoip_stats.c.
| void geoip_bridge_stats_term | ( | void | ) |
Stop collecting bridge stats in a way that we can re-start doing so in geoip_bridge_stats_init().
Definition at line 1077 of file geoip_stats.c.
| time_t geoip_bridge_stats_write | ( | time_t | now | ) |
Write bridge statistics to $DATADIR/stats/bridge-stats and return when we should next try to write statistics.
Definition at line 1241 of file geoip_stats.c.
| void geoip_change_dirreq_state | ( | uint64_t | dirreq_id, |
| dirreq_type_t | type, | ||
| dirreq_state_t | new_state | ||
| ) |
Change the state of the either direct or tunneled (see type) directory request with dirreq_id to new_state and possibly mark it as completed. If no entry can be found for the given key parts (e.g., if this is a directory request that we are not measuring, or one that was started in the previous measurement period), or if the state cannot be advanced to new_state, do nothing.
Definition at line 553 of file geoip_stats.c.
| size_t geoip_client_cache_handle_oom | ( | time_t | now, |
| size_t | min_remove_bytes | ||
| ) |
Definition at line 351 of file geoip_stats.c.
| size_t geoip_client_cache_total_allocation | ( | void | ) |
Definition at line 384 of file geoip_stats.c.
| void geoip_dirreq_stats_init | ( | time_t | now | ) |
Initialize directory request stats.
Definition at line 921 of file geoip_stats.c.
| void geoip_dirreq_stats_term | ( | void | ) |
Stop collecting directory request stats in a way that we can re-start doing so in geoip_dirreq_stats_init().
Definition at line 960 of file geoip_stats.c.
| time_t geoip_dirreq_stats_write | ( | time_t | now | ) |
If 24 hours have passed since the beginning of the current dirreq stats period, write dirreq stats to $DATADIR/stats/dirreq-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write dirreq stats or 0 if we never want to write.
Definition at line 1034 of file geoip_stats.c.
| void geoip_entry_stats_init | ( | time_t | now | ) |
Initialize entry stats.
Definition at line 1324 of file geoip_stats.c.
| void geoip_entry_stats_term | ( | void | ) |
Stop collecting entry stats in a way that we can re-start doing so in geoip_entry_stats_init().
Definition at line 1340 of file geoip_stats.c.
| time_t geoip_entry_stats_write | ( | time_t | now | ) |
If 24 hours have passed since the beginning of the current entry stats period, write entry stats to $DATADIR/stats/entry-stats (possibly overwriting an existing file) and reset counters. Return when we would next want to write entry stats or 0 if we never want to write.
Definition at line 1376 of file geoip_stats.c.
| char * geoip_format_bridge_stats | ( | time_t | now | ) |
Return a newly allocated string holding our bridge usage stats by country in a format suitable for inclusion in an extrainfo document. Return NULL on failure.
Definition at line 1151 of file geoip_stats.c.
| char * geoip_format_dirreq_stats | ( | time_t | now | ) |
Return a newly allocated string containing the dirreq statistics until now, or NULL if we're not collecting dirreq stats. Caller must ensure start_of_dirreq_stats_interval is in the past.
Definition at line 969 of file geoip_stats.c.
| char * geoip_format_entry_stats | ( | time_t | now | ) |
Return a newly allocated string containing the entry statistics until now, or NULL if we're not collecting entry stats. Caller must ensure start_of_entry_stats_interval lies in the past.
Definition at line 1349 of file geoip_stats.c.
| char * geoip_get_bridge_stats_controller | ( | time_t | now | ) |
Return a new string containing the recent bridge statistics to be returned to controller clients, or NULL if we don't have any bridge statistics.
Definition at line 1313 of file geoip_stats.c.
| const char * geoip_get_bridge_stats_extrainfo | ( | time_t | now | ) |
Return most recent bridge statistics for inclusion in extra-info descriptors, or NULL if we don't have recent bridge statistics.
Definition at line 1304 of file geoip_stats.c.
| int geoip_get_client_history | ( | geoip_client_action_t | action, |
| char ** | country_str, | ||
| char ** | ipver_str | ||
| ) |
Store a newly allocated comma-separated string in *country_str containing entries for all the countries from which we've seen enough clients connect as a bridge, directory server, or entry guard. 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. *country_str is set to NULL if we're not ready to export per country data yet.
Store a newly allocated comma-separated string in ipver_str containing entries for clients connecting over IPv4 and IPv6. The format is family=num where num is the number of IPs we've seen connecting over that protocol family, and family is 'v4' or 'v6'.
Return 0 on success and -1 if we're missing geoip data.
unresolved requests are stored at index 0.
Definition at line 785 of file geoip_stats.c.
| char * geoip_get_request_history | ( | void | ) |
Return a newly allocated string holding the per-country request history for v3 network statuses in a format suitable for an extra-info document, or NULL on failure.
Definition at line 880 of file geoip_stats.c.
| char * geoip_get_transport_history | ( | void | ) |
Return the bridge-ip-transports string that should be inserted in our extra-info descriptor. Return NULL if the bridge-ip-transports line should be empty.
String hash table (name of transport) -> (number of users).
Smartlist that contains copies of the names of the transports that have been used.
We do the following steps to form the transport history string: a) Foreach client that uses a pluggable transport, we increase the times that transport was used by one. If the client did not use a transport, we increase the number of times someone connected without obfuscation. b) Foreach transport we observed, we write its transport history string and push it to string_chunks. So, for example, if we've seen 665 obfs2 clients, we write "obfs2=665". c) We concatenate string_chunks to form the final string.
Definition at line 580 of file geoip_stats.c.
| clientmap_entry_t * geoip_lookup_client | ( | const tor_addr_t * | addr, |
| const char * | transport_name, | ||
| geoip_client_action_t | action | ||
| ) |
Definition at line 304 of file geoip_stats.c.
| void geoip_note_client_seen | ( | geoip_client_action_t | action, |
| const tor_addr_t * | addr, | ||
| const char * | transport_name, | ||
| time_t | now | ||
| ) |
Note that we've seen a client connect from the IP addr at time now. Ignored by all but bridges and directories if configured accordingly.
unresolved requests are stored at index 0.
Definition at line 229 of file geoip_stats.c.
| void geoip_note_ns_response | ( | geoip_ns_response_t | response | ) |
Note how we have handled a client's request for a v3 network status: with reason at time now.
Definition at line 396 of file geoip_stats.c.
| void geoip_remove_old_clients | ( | time_t | cutoff | ) |
Forget about all clients that haven't connected since cutoff.
Definition at line 293 of file geoip_stats.c.
| void geoip_reset_dirreq_stats | ( | time_t | now | ) |
Reset counters for dirreq stats.
Definition at line 928 of file geoip_stats.c.
| void geoip_reset_entry_stats | ( | time_t | now | ) |
Reset counters for entry stats.
Definition at line 1331 of file geoip_stats.c.
| void geoip_start_dirreq | ( | uint64_t | dirreq_id, |
| size_t | response_size, | ||
| dirreq_type_t | type | ||
| ) |
Note that an either direct or tunneled (see type) directory request for a v3 network status with unique ID dirreq_id of size response_size has started.
Definition at line 532 of file geoip_stats.c.
| void geoip_stats_free_all | ( | void | ) |
Release all storage held in this file.
Definition at line 1406 of file geoip_stats.c.
| int should_record_bridge_info | ( | const or_options_t * | options | ) |
Return 1 if we should collect geoip stats on bridge users, and include them in our extrainfo descriptor. Else return 0.
Definition at line 112 of file geoip_stats.c.