mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-09-21 05:26:20 +02:00
r15531@tombo: nickm | 2007-12-17 17:19:24 -0500
Support raw IP-to-country as well as postprocessed format. Include GEOIP summary in extrainfo of bridges. svn:r12846
This commit is contained in:
parent
820159cac5
commit
25f78498f9
8
doc/TODO
8
doc/TODO
@ -31,18 +31,18 @@ R . spec
|
|||||||
. geoip caching and publishing for bridges
|
. geoip caching and publishing for bridges
|
||||||
R . spec
|
R . spec
|
||||||
- Implement
|
- Implement
|
||||||
. Code to load a geoip file from disk
|
o Code to load a geoip file from disk
|
||||||
o Truncated format
|
o Truncated format
|
||||||
- Full format.
|
o Full format.
|
||||||
o Actually invoke
|
o Actually invoke
|
||||||
o Code to store a GEOIP file in memory.
|
o Code to store a GEOIP file in memory.
|
||||||
o Code to remember client IPs.
|
o Code to remember client IPs.
|
||||||
. Code to generate history lines
|
o Code to generate history lines
|
||||||
- Make history lines match spec.
|
|
||||||
- Controller interface
|
- Controller interface
|
||||||
- Track consecutive time up, not time since last-forgotten IP.
|
- Track consecutive time up, not time since last-forgotten IP.
|
||||||
- Add log lines.
|
- Add log lines.
|
||||||
- Tests
|
- Tests
|
||||||
|
- Mention in dir-spec.txt
|
||||||
d let Vidalia use the geoip data too rather than doing its own
|
d let Vidalia use the geoip data too rather than doing its own
|
||||||
anonymized queries
|
anonymized queries
|
||||||
o bridge address disbursal strategies
|
o bridge address disbursal strategies
|
||||||
|
@ -81,9 +81,14 @@ geoip_load_file(const char *filename)
|
|||||||
geoip_entries = smartlist_create();
|
geoip_entries = smartlist_create();
|
||||||
country_idxplus1_by_lc_code = strmap_new();
|
country_idxplus1_by_lc_code = strmap_new();
|
||||||
while (!feof(f)) {
|
while (!feof(f)) {
|
||||||
|
char buf[512];
|
||||||
unsigned int low, high;
|
unsigned int low, high;
|
||||||
char b[3];
|
char b[3];
|
||||||
if (fscanf(f, "%u,%u,%2s", &low, &high, b) == 3) {
|
if (fgets(buf, sizeof(buf), f) == NULL)
|
||||||
|
break;
|
||||||
|
if (sscanf(buf,"%u,%u,%2s", &low, &high, b) == 3) {
|
||||||
|
geoip_add_entry(low, high, b);
|
||||||
|
} else if (sscanf(buf,"\"%u\",\"%u\",\"%2s\",", &low, &high, b) == 3) {
|
||||||
geoip_add_entry(low, high, b);
|
geoip_add_entry(low, high, b);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,6 +205,12 @@ geoip_remove_old_clients(time_t cutoff)
|
|||||||
#define MIN_IPS_TO_NOTE_ANYTHING 16
|
#define MIN_IPS_TO_NOTE_ANYTHING 16
|
||||||
#define IP_GRANULARITY 8
|
#define IP_GRANULARITY 8
|
||||||
|
|
||||||
|
time_t
|
||||||
|
geoip_get_history_start(void)
|
||||||
|
{
|
||||||
|
return client_history_starts;
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
geoip_get_client_history(time_t now)
|
geoip_get_client_history(time_t now)
|
||||||
{
|
{
|
||||||
|
@ -3208,6 +3208,7 @@ const char *geoip_get_country_name(int num);
|
|||||||
int geoip_is_loaded(void);
|
int geoip_is_loaded(void);
|
||||||
void geoip_note_client_seen(uint32_t addr, time_t now);
|
void geoip_note_client_seen(uint32_t addr, time_t now);
|
||||||
void geoip_remove_old_clients(time_t cutoff);
|
void geoip_remove_old_clients(time_t cutoff);
|
||||||
|
time_t geoip_get_history_start(void);
|
||||||
char *geoip_get_client_history(time_t now);
|
char *geoip_get_client_history(time_t now);
|
||||||
void geoip_free_all(void);
|
void geoip_free_all(void);
|
||||||
|
|
||||||
|
@ -1694,6 +1694,7 @@ int
|
|||||||
extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
||||||
crypto_pk_env_t *ident_key)
|
crypto_pk_env_t *ident_key)
|
||||||
{
|
{
|
||||||
|
or_options_t *options = get_options();
|
||||||
char identity[HEX_DIGEST_LEN+1];
|
char identity[HEX_DIGEST_LEN+1];
|
||||||
char published[ISO_TIME_LEN+1];
|
char published[ISO_TIME_LEN+1];
|
||||||
char digest[DIGEST_LEN];
|
char digest[DIGEST_LEN];
|
||||||
@ -1708,14 +1709,32 @@ extrainfo_dump_to_string(char *s, size_t maxlen, extrainfo_t *extrainfo,
|
|||||||
|
|
||||||
result = tor_snprintf(s, maxlen,
|
result = tor_snprintf(s, maxlen,
|
||||||
"extra-info %s %s\n"
|
"extra-info %s %s\n"
|
||||||
"published %s\n%s"
|
"published %s\n%s",
|
||||||
"router-signature\n",
|
|
||||||
extrainfo->nickname, identity,
|
extrainfo->nickname, identity,
|
||||||
published, bandwidth_usage);
|
published, bandwidth_usage);
|
||||||
tor_free(bandwidth_usage);
|
tor_free(bandwidth_usage);
|
||||||
if (result<0)
|
if (result<0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
if (options->BridgeRelay && options->BridgeRecordUsageByCountry) {
|
||||||
|
char *geoip_summary = geoip_get_client_history(time(NULL));
|
||||||
|
if (geoip_summary) {
|
||||||
|
char geoip_start[ISO_TIME_LEN+1];
|
||||||
|
format_iso_time(geoip_start, geoip_get_history_start());
|
||||||
|
result = tor_snprintf(s+strlen(s), maxlen-strlen(s),
|
||||||
|
"geoip-start-time %s\n"
|
||||||
|
"geoip-client-origins %s\n",
|
||||||
|
geoip_start, geoip_summary);
|
||||||
|
tor_free(geoip_summary);
|
||||||
|
if (result<0)
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
len = strlen(s);
|
len = strlen(s);
|
||||||
|
strlcat(s+len, "router-signature\n", maxlen-len);
|
||||||
|
len += strlen(s+len);
|
||||||
if (router_get_extrainfo_hash(s, digest)<0)
|
if (router_get_extrainfo_hash(s, digest)<0)
|
||||||
return -1;
|
return -1;
|
||||||
if (router_append_dirobj_signature(s+len, maxlen-len, digest, ident_key)<0)
|
if (router_append_dirobj_signature(s+len, maxlen-len, digest, ident_key)<0)
|
||||||
|
Loading…
Reference in New Issue
Block a user