summaryrefslogtreecommitdiff
path: root/src/or/geoip.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-12-17 22:44:16 +0000
committerNick Mathewson <nickm@torproject.org>2007-12-17 22:44:16 +0000
commit25f78498f91ba9f482bc654d3af8905b600d4f7f (patch)
tree4b72b48bf0bfd5006ebbf1b03b3e32d82ca144b1 /src/or/geoip.c
parent820159cac540b4777fb639de663d72f04690e2a2 (diff)
downloadtor-25f78498f91ba9f482bc654d3af8905b600d4f7f.tar.gz
tor-25f78498f91ba9f482bc654d3af8905b600d4f7f.zip
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
Diffstat (limited to 'src/or/geoip.c')
-rw-r--r--src/or/geoip.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/or/geoip.c b/src/or/geoip.c
index eeeb453f2f..c9fb91cdfb 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -81,9 +81,14 @@ geoip_load_file(const char *filename)
geoip_entries = smartlist_create();
country_idxplus1_by_lc_code = strmap_new();
while (!feof(f)) {
+ char buf[512];
unsigned int low, high;
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);
}
}
@@ -200,6 +205,12 @@ geoip_remove_old_clients(time_t cutoff)
#define MIN_IPS_TO_NOTE_ANYTHING 16
#define IP_GRANULARITY 8
+time_t
+geoip_get_history_start(void)
+{
+ return client_history_starts;
+}
+
char *
geoip_get_client_history(time_t now)
{