diff --git a/src/server/location.rs b/src/server/location.rs index 3e096bf6..a32fe446 100644 --- a/src/server/location.rs +++ b/src/server/location.rs @@ -340,14 +340,14 @@ impl Location { } #[cfg(test)] -mod test { +pub mod test { use super::*; use crate::error::HandlerResult; use std::collections::BTreeMap; use actix_http::http::{HeaderName, HeaderValue}; - const MMDB_LOC: &str = "mmdb/GeoLite2-City-Test.mmdb"; + pub const MMDB_LOC: &str = "mmdb/GeoLite2-City-Test.mmdb"; const TEST_ADDR: &str = "216.160.83.56"; #[test] diff --git a/src/web/handlers.rs b/src/web/handlers.rs index c1edecd0..fb2b9cd8 100644 --- a/src/web/handlers.rs +++ b/src/web/handlers.rs @@ -44,7 +44,12 @@ pub async fn get_tiles( let addr = match ip_addr_str.parse() { Ok(v) => v, Err(e) => { - return Err(HandlerErrorKind::General(format!("Invalid remote IP {:?}", e)).into()); + // Temporary: log the IP addr for debugging mmdb issues + return Err(HandlerErrorKind::General(format!( + "Invalid remote IP ({:?}) {:?}", + ip_addr_str, e + )) + .into()); } }; state diff --git a/src/web/test.rs b/src/web/test.rs index c210315c..87b1de53 100644 --- a/src/web/test.rs +++ b/src/web/test.rs @@ -12,7 +12,11 @@ use crate::{ build_app, error::{HandlerError, HandlerResult}, metrics::Metrics, - server::{cache, location::Location, ServerState}, + server::{ + cache, + location::{test::MMDB_LOC, Location}, + ServerState, + }, settings::{test_settings, Settings}, web::{dockerflow, handlers, middleware}, }; @@ -24,6 +28,7 @@ const UA: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100 fn get_test_settings() -> Settings { let treq = test::TestRequest::with_uri("/").to_http_request(); Settings { + maxminddb_loc: Some(MMDB_LOC.to_owned()), port: treq.uri().port_u16().unwrap_or(8080), host: treq.uri().host().unwrap_or("localhost").to_owned(), ..test_settings()