[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] r14936: forward-port r14934 (tor/trunk/src/or)



Author: arma
Date: 2008-06-04 05:02:25 -0400 (Wed, 04 Jun 2008)
New Revision: 14936

Modified:
   tor/trunk/src/or/config.c
   tor/trunk/src/or/geoip.c
   tor/trunk/src/or/or.h
   tor/trunk/src/or/router.c
Log:
forward-port r14934


Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-06-04 08:59:14 UTC (rev 14935)
+++ tor/trunk/src/or/config.c	2008-06-04 09:02:25 UTC (rev 14936)
@@ -1282,7 +1282,7 @@
       tor_snprintf(actual_fname, len, "%s\\geoip", conf_root);
     }
 #endif
-    geoip_load_file(actual_fname);
+    geoip_load_file(actual_fname, options);
     tor_free(actual_fname);
   }
   /* Check if we need to parse and add the EntryNodes config option. */

Modified: tor/trunk/src/or/geoip.c
===================================================================
--- tor/trunk/src/or/geoip.c	2008-06-04 08:59:14 UTC (rev 14935)
+++ tor/trunk/src/or/geoip.c	2008-06-04 09:02:25 UTC (rev 14936)
@@ -122,6 +122,14 @@
     return 0;
 }
 
+/** Return 1 if we should collect geoip stats on bridge users, and
+ * include them in our extrainfo descriptor. Else return 0. */
+int
+should_record_bridge_info(or_options_t *options)
+{
+  return options->BridgeRelay && options->BridgeRecordUsageByCountry;
+}
+
 /** Clear the GeoIP database and reload it from the file
  * <b>filename</b>. Return 0 on success, -1 on failure.
  *
@@ -136,12 +144,13 @@
  * with '#' (comments).
  */
 int
-geoip_load_file(const char *filename)
+geoip_load_file(const char *filename, or_options_t *options)
 {
   FILE *f;
+  int severity = should_record_bridge_info(options) ? LOG_WARN : LOG_INFO;
   clear_geoip_db();
   if (!(f = fopen(filename, "r"))) {
-    log_warn(LD_GENERAL, "Failed to open GEOIP file %s.", filename);
+    log_fn(severity, LD_GENERAL, "Failed to open GEOIP file %s.", filename);
     return -1;
   }
   geoip_countries = smartlist_create();

Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h	2008-06-04 08:59:14 UTC (rev 14935)
+++ tor/trunk/src/or/or.h	2008-06-04 09:02:25 UTC (rev 14936)
@@ -3294,7 +3294,8 @@
 #ifdef GEOIP_PRIVATE
 int geoip_parse_entry(const char *line);
 #endif
-int geoip_load_file(const char *filename);
+int should_record_bridge_info(or_options_t *options);
+int geoip_load_file(const char *filename, or_options_t *options);
 int geoip_get_country_by_ip(uint32_t ipaddr);
 int geoip_get_n_countries(void);
 const char *geoip_get_country_name(int num);

Modified: tor/trunk/src/or/router.c
===================================================================
--- tor/trunk/src/or/router.c	2008-06-04 08:59:14 UTC (rev 14935)
+++ tor/trunk/src/or/router.c	2008-06-04 09:02:25 UTC (rev 14936)
@@ -1822,7 +1822,7 @@
   if (result<0)
     return -1;
 
-  if (options->BridgeRelay && options->BridgeRecordUsageByCountry) {
+  if (should_record_bridge_info(options)) {
     static time_t last_purged_at = 0;
     char *geoip_summary;
     time_t now = time(NULL);