diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-09-25 21:06:32 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-09-25 21:06:32 +0000 |
commit | 02c71a7eb4ddbe3841a7b804a99b7b509e05a9d9 (patch) | |
tree | b86dd38756044645f158c157a2b5279289198739 | |
parent | e06f140f978cb95c3f4655f24ccdf1753a04d230 (diff) | |
download | tor-02c71a7eb4ddbe3841a7b804a99b7b509e05a9d9.tar.gz tor-02c71a7eb4ddbe3841a7b804a99b7b509e05a9d9.zip |
Widen the conditions under which we whine about not having a geoip file to include "a country code was configured in a node list."
svn:r16968
-rw-r--r-- | src/or/config.c | 24 | ||||
-rw-r--r-- | src/or/geoip.c | 8 | ||||
-rw-r--r-- | src/or/or.h | 2 | ||||
-rw-r--r-- | src/or/routerlist.c | 7 |
4 files changed, 38 insertions, 3 deletions
diff --git a/src/or/config.c b/src/or/config.c index 36c0d4287d..219be16481 100644 --- a/src/or/config.c +++ b/src/or/config.c @@ -1163,6 +1163,30 @@ options_act_reversible(or_options_t *old_options, char **msg) return r; } +/** DOCDOC */ +int +options_need_geoip_info(or_options_t *options, const char **reason_out) +{ + int bridge_usage = + options->BridgeRelay && options->BridgeRecordUsageByCountry; + int routerset_usage = + routerset_needs_geoip(options->EntryNodes) || + routerset_needs_geoip(options->ExitNodes) || + routerset_needs_geoip(options->ExcludeExitNodes) || + routerset_needs_geoip(options->ExcludeNodes); + + if (routerset_usage && reason_out) { + *reason_out = "We've been configured to use (or avoid) nodes in certain " + "contries, and we need GEOIP information to figure out which ones they " + "are."; + } else if (bridge_usage && reason_out) { + *reason_out = "We've been configured to see which countries can access " + "us as a bridge, and we need GEOIP information to tell which countries " + "clients are in."; + } + return bridge_usage || routerset_usage; +} + /** Fetch the active option list, and take actions based on it. All of the * things we do should survive being done repeatedly. If present, * <b>old_options</b> contains the previous value of the options. diff --git a/src/or/geoip.c b/src/or/geoip.c index e948d60de4..a0f0d4ae90 100644 --- a/src/or/geoip.c +++ b/src/or/geoip.c @@ -178,10 +178,12 @@ int geoip_load_file(const char *filename, or_options_t *options) { FILE *f; - int severity = should_record_bridge_info(options) ? LOG_WARN : LOG_INFO; + const char *msg = ""; + int severity = options_need_geoip_info(options, &msg) ? LOG_WARN : LOG_INFO; clear_geoip_db(); if (!(f = fopen(filename, "r"))) { - log_fn(severity, LD_GENERAL, "Failed to open GEOIP file %s.", filename); + log_fn(severity, LD_GENERAL, "Failed to open GEOIP file %s. %s", + filename, msg); return -1; } if (!geoip_countries) { @@ -193,7 +195,7 @@ geoip_load_file(const char *filename, or_options_t *options) smartlist_free(geoip_entries); } geoip_entries = smartlist_create(); - log_info(LD_GENERAL, "Parsing GEOIP file."); + log_notice(LD_GENERAL, "Parsing GEOIP file."); while (!feof(f)) { char buf[512]; if (fgets(buf, (int)sizeof(buf), f) == NULL) diff --git a/src/or/or.h b/src/or/or.h index da1be00142..d21b30e5c6 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -2837,6 +2837,7 @@ char *options_get_datadir_fname2_suffix(or_options_t *options, or_state_t *get_or_state(void); int or_state_save(time_t now); +int options_need_geoip_info(or_options_t *options, const char **reason_out); int getinfo_helper_config(control_connection_t *conn, const char *question, char **answer); @@ -4294,6 +4295,7 @@ int routerset_parse(routerset_t *target, const char *s, const char *description); void routerset_union(routerset_t *target, const routerset_t *source); int routerset_is_list(const routerset_t *set); +int routerset_needs_geoip(const routerset_t *set); int routerset_contains_router(const routerset_t *set, routerinfo_t *ri); int routerset_contains_routerstatus(const routerset_t *set, routerstatus_t *rs); diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 71f6fd1cc7..3a5c4d5998 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -4882,6 +4882,13 @@ routerset_is_list(const routerset_t *set) } /** DOCDOC */ +int +routerset_needs_geoip(const routerset_t *set) +{ + return set && smartlist_len(set->country_names); +} + +/** DOCDOC */ static int routerset_is_empty(const routerset_t *set) { |