[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [tor/master] New GETINFO target to check if geoip is loaded
commit 96aed28f143298b33363a7a0ca997e2a4d2eae29
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date: Fri Aug 25 12:25:05 2017 -0400
New GETINFO target to check if geoip is loaded
Closes ticket 23237.
---
changes/feature23237 | 4 ++++
src/or/geoip.c | 9 +++++++++
2 files changed, 13 insertions(+)
diff --git a/changes/feature23237 b/changes/feature23237
new file mode 100644
index 000000000..261577261
--- /dev/null
+++ b/changes/feature23237
@@ -0,0 +1,4 @@
+ o Minor features (controller):
+ - Added new GETINFO targets ip-to-country/{ipv4,ipv6}-available, so
+ controllers can tell whether the geoip databases are loaded.
+ Closes ticket 23237.
diff --git a/src/or/geoip.c b/src/or/geoip.c
index 65d00b865..3944b2cf6 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -1665,6 +1665,15 @@ getinfo_helper_geoip(control_connection_t *control_conn,
sa_family_t family;
tor_addr_t addr;
question += strlen("ip-to-country/");
+
+ if (!strcmp(question, "ipv4-available") ||
+ !strcmp(question, "ipv6-available")) {
+ family = !strcmp(question, "ipv4-available") ? AF_INET : AF_INET6;
+ const int available = geoip_is_loaded(family);
+ tor_asprintf(answer, "%d", !! available);
+ return 0;
+ }
+
family = tor_addr_parse(&addr, question);
if (family != AF_INET && family != AF_INET6) {
*errmsg = "Invalid address family";
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits