Merge pull request #1301 from nymtech/feature/update-geo-ip

Update to use new geo_locate stats
This commit is contained in:
Tommy Verrall
2022-06-01 11:43:11 +01:00
committed by GitHub
3 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -5,13 +5,13 @@ An API that provides data for the [Network Explorer](../explorer).
Features:
- geolocates mixnodes using https://freegeoip.app/
- geolocates mixnodes using https://app.ipbase.com/
- calculates how many nodes are in each country
- proxies mixnode API requests to add HTTPS
## Running
Supply the environment variable `GEO_IP_SERVICE_API_KEY` with a key from https://freegeoip.app/.
Supply the environment variable `GEO_IP_SERVICE_API_KEY` with a key from https://app.ipbase.com/.
Run as a service and reverse proxy with `nginx` to add `https` with Lets Encrypt.
@@ -129,7 +129,7 @@ enum LocateError {
async fn locate(ip: &str) -> Result<GeoLocation, LocateError> {
let api_key = ::std::env::var("GEO_IP_SERVICE_API_KEY")
.expect("Env var GEO_IP_SERVICE_API_KEY is not set");
let uri = format!("{}/{}?apikey={}", crate::GEO_IP_SERVICE, ip, api_key);
let uri = format!("{}/?apikey={}&ip={}", crate::GEO_IP_SERVICE, api_key, ip);
match reqwest::get(uri.clone()).await {
Ok(response) => {
if response.status() == 429 {
+1 -1
View File
@@ -18,7 +18,7 @@ mod state;
mod tasks;
mod validators;
const GEO_IP_SERVICE: &str = "https://api.freegeoip.app/json";
const GEO_IP_SERVICE: &str = "https://api.ipbase.com/json";
const COUNTRY_DATA_REFRESH_INTERVAL: u64 = 60 * 15; // every 15 minutes
#[tokio::main]