aboutsummaryrefslogtreecommitdiff
path: root/src/app
diff options
context:
space:
mode:
Diffstat (limited to 'src/app')
-rw-r--r--src/app/config/config.c28
-rw-r--r--src/app/main/main.c6
2 files changed, 28 insertions, 6 deletions
diff --git a/src/app/config/config.c b/src/app/config/config.c
index b8cb50340f..6e7e131055 100644
--- a/src/app/config/config.c
+++ b/src/app/config/config.c
@@ -96,13 +96,16 @@
#include "feature/nodelist/networkstatus.h"
#include "feature/nodelist/nickname.h"
#include "feature/nodelist/nodelist.h"
+#include "feature/nodelist/routerlist.h"
#include "feature/nodelist/routerset.h"
#include "feature/relay/dns.h"
#include "feature/relay/ext_orport.h"
#include "feature/relay/routermode.h"
#include "feature/rend/rendclient.h"
#include "feature/rend/rendservice.h"
-#include "feature/stats/geoip.h"
+#include "lib/geoip/geoip.h"
+#include "feature/stats/geoip_stats.h"
+#include "feature/stats/predict_ports.h"
#include "feature/stats/rephist.h"
#include "lib/compress/compress.h"
#include "lib/crypt_ops/crypto_init.h"
@@ -8355,6 +8358,11 @@ config_load_geoip_file_(sa_family_t family,
const char *fname,
const char *default_fname)
{
+ const or_options_t *options = get_options();
+ const char *msg = "";
+ int severity = options_need_geoip_info(options, &msg) ? LOG_WARN : LOG_INFO;
+ int r;
+
#ifdef _WIN32
char *free_fname = NULL; /* Used to hold any temporary-allocated value */
/* XXXX Don't use this "<default>" junk; make our filename options
@@ -8364,12 +8372,16 @@ config_load_geoip_file_(sa_family_t family,
tor_asprintf(&free_fname, "%s\\%s", conf_root, default_fname);
fname = free_fname;
}
- geoip_load_file(family, fname);
+ r = geoip_load_file(family, fname, severity);
tor_free(free_fname);
#else /* !(defined(_WIN32)) */
(void)default_fname;
- geoip_load_file(family, fname);
+ r = geoip_load_file(family, fname, severity);
#endif /* defined(_WIN32) */
+
+ if (r < 0 && severity == LOG_WARN) {
+ log_warn(LD_GENERAL, "%s", msg);
+ }
}
/** Load geoip files for IPv4 and IPv6 if <a>options</a> and
@@ -8383,13 +8395,19 @@ config_maybe_load_geoip_files_(const or_options_t *options,
if (options->GeoIPFile &&
((!old_options || !opt_streq(old_options->GeoIPFile,
options->GeoIPFile))
- || !geoip_is_loaded(AF_INET)))
+ || !geoip_is_loaded(AF_INET))) {
config_load_geoip_file_(AF_INET, options->GeoIPFile, "geoip");
+ /* Okay, now we need to maybe change our mind about what is in
+ * which country. We do this for IPv4 only since that's what we
+ * store in node->country. */
+ refresh_all_country_info();
+ }
if (options->GeoIPv6File &&
((!old_options || !opt_streq(old_options->GeoIPv6File,
options->GeoIPv6File))
- || !geoip_is_loaded(AF_INET6)))
+ || !geoip_is_loaded(AF_INET6))) {
config_load_geoip_file_(AF_INET6, options->GeoIPv6File, "geoip6");
+ }
}
/** Initialize cookie authentication (used so far by the ControlPort
diff --git a/src/app/main/main.c b/src/app/main/main.c
index 90bc8c510f..8a24df2105 100644
--- a/src/app/main/main.c
+++ b/src/app/main/main.c
@@ -27,6 +27,7 @@
#include "core/or/command.h"
#include "core/or/connection_edge.h"
#include "core/or/connection_or.h"
+#include "core/or/dos.h"
#include "core/or/policies.h"
#include "core/or/protover.h"
#include "core/or/relay.h"
@@ -60,7 +61,9 @@
#include "feature/rend/rendcache.h"
#include "feature/rend/rendclient.h"
#include "feature/rend/rendservice.h"
-#include "feature/stats/geoip.h"
+#include "lib/geoip/geoip.h"
+#include "feature/stats/geoip_stats.h"
+#include "feature/stats/predict_ports.h"
#include "feature/stats/rephist.h"
#include "lib/compress/compress.h"
#include "lib/container/buffers.h"
@@ -754,6 +757,7 @@ tor_free_all(int postfork)
evdns_shutdown(1);
}
geoip_free_all();
+ geoip_stats_free_all();
dirvote_free_all();
routerlist_free_all();
networkstatus_free_all();