tor  0.4.2.0-alpha-dev
geoip_stats.h
Go to the documentation of this file.
1 /* Copyright (c) 2001 Matej Pfajfar.
2  * Copyright (c) 2001-2004, Roger Dingledine.
3  * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
4  * Copyright (c) 2007-2019, The Tor Project, Inc. */
5 /* See LICENSE for licensing information */
6 
12 #ifndef TOR_GEOIP_STATS_H
13 #define TOR_GEOIP_STATS_H
14 
15 #include "core/or/dos.h"
16 
21 typedef enum {
29 typedef enum {
44 #define GEOIP_NS_RESPONSE_NUM 6
45 
48 typedef enum {
49  DIRREQ_DIRECT = 0,
50  DIRREQ_TUNNELED = 1,
52 
55 typedef enum {
74 
78 typedef struct clientmap_entry_t {
79  HT_ENTRY(clientmap_entry_t) node;
80  tor_addr_t addr;
81  /* Name of pluggable transport used by this client. NULL if no
82  pluggable transport was used. */
83  char *transport_name;
84 
89  unsigned int last_seen_in_minutes:30;
90  unsigned int action:2;
91 
92  /* This object is used to keep some statistics per client address for the
93  * DoS mitigation subsystem. */
94  dos_client_stats_t dos_stats;
96 
97 int should_record_bridge_info(const or_options_t *options);
98 
100  const tor_addr_t *addr, const char *transport_name,
101  time_t now);
102 void geoip_remove_old_clients(time_t cutoff);
103 clientmap_entry_t *geoip_lookup_client(const tor_addr_t *addr,
104  const char *transport_name,
105  geoip_client_action_t action);
106 size_t geoip_client_cache_total_allocation(void);
107 size_t geoip_client_cache_handle_oom(time_t now, size_t min_remove_bytes);
108 
110 char *geoip_get_transport_history(void);
112  char **country_str, char **ipver_str);
113 char *geoip_get_request_history(void);
114 void geoip_stats_free_all(void);
115 
116 void geoip_start_dirreq(uint64_t dirreq_id, size_t response_size,
117  dirreq_type_t type);
118 void geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type,
119  dirreq_state_t new_state);
120 
121 void geoip_dirreq_stats_init(time_t now);
122 void geoip_reset_dirreq_stats(time_t now);
123 char *geoip_format_dirreq_stats(time_t now);
124 time_t geoip_dirreq_stats_write(time_t now);
125 void geoip_dirreq_stats_term(void);
126 void geoip_entry_stats_init(time_t now);
127 time_t geoip_entry_stats_write(time_t now);
128 void geoip_entry_stats_term(void);
129 void geoip_reset_entry_stats(time_t now);
130 char *geoip_format_entry_stats(time_t now);
131 void geoip_bridge_stats_init(time_t now);
132 char *geoip_format_bridge_stats(time_t now);
133 time_t geoip_bridge_stats_write(time_t now);
134 void geoip_bridge_stats_term(void);
135 const char *geoip_get_bridge_stats_extrainfo(time_t);
137 char *format_client_stats_heartbeat(time_t now);
138 
139 #endif /* !defined(TOR_GEOIP_STATS_H) */
void geoip_reset_dirreq_stats(time_t now)
Definition: geoip_stats.c:925
void geoip_change_dirreq_state(uint64_t dirreq_id, dirreq_type_t type, dirreq_state_t new_state)
Definition: geoip_stats.c:550
int geoip_get_client_history(geoip_client_action_t action, char **country_str, char **ipver_str)
Definition: geoip_stats.c:782
void geoip_note_client_seen(geoip_client_action_t action, const tor_addr_t *addr, const char *transport_name, time_t now)
Definition: geoip_stats.c:227
char * geoip_format_dirreq_stats(time_t now)
Definition: geoip_stats.c:966
dirreq_type_t
Definition: geoip_stats.h:48
char * geoip_format_bridge_stats(time_t now)
Definition: geoip_stats.c:1146
dirreq_state_t
Definition: geoip_stats.h:55
void geoip_dirreq_stats_init(time_t now)
Definition: geoip_stats.c:918
int should_record_bridge_info(const or_options_t *options)
Definition: geoip_stats.c:112
char * geoip_get_request_history(void)
Definition: geoip_stats.c:877
struct clientmap_entry_t clientmap_entry_t
time_t geoip_bridge_stats_write(time_t now)
Definition: geoip_stats.c:1237
void geoip_dirreq_stats_term(void)
Definition: geoip_stats.c:957
char * geoip_format_entry_stats(time_t now)
Definition: geoip_stats.c:1345
void geoip_entry_stats_init(time_t now)
Definition: geoip_stats.c:1320
void geoip_reset_entry_stats(time_t now)
Definition: geoip_stats.c:1327
time_t geoip_entry_stats_write(time_t now)
Definition: geoip_stats.c:1372
geoip_ns_response_t
Definition: geoip_stats.h:29
void geoip_note_ns_response(geoip_ns_response_t response)
Definition: geoip_stats.c:393
char * geoip_get_bridge_stats_controller(time_t)
Definition: geoip_stats.c:1309
void geoip_start_dirreq(uint64_t dirreq_id, size_t response_size, dirreq_type_t type)
Definition: geoip_stats.c:529
geoip_client_action_t
Definition: geoip_stats.h:21
Definition: geoip_stats.h:78
void geoip_bridge_stats_init(time_t now)
Definition: geoip_stats.c:1064
void geoip_entry_stats_term(void)
Definition: geoip_stats.c:1336
const char * geoip_get_bridge_stats_extrainfo(time_t)
Definition: geoip_stats.c:1300
void geoip_remove_old_clients(time_t cutoff)
Definition: geoip_stats.c:291
time_t geoip_dirreq_stats_write(time_t now)
Definition: geoip_stats.c:1029
void geoip_stats_free_all(void)
Definition: geoip_stats.c:1402
unsigned int last_seen_in_minutes
Definition: geoip_stats.h:89
void geoip_bridge_stats_term(void)
Definition: geoip_stats.c:1072
char * format_client_stats_heartbeat(time_t now)
Definition: geoip_stats.c:1205
char * geoip_get_transport_history(void)
Definition: geoip_stats.c:577