From 1c8685681ef51618afac364fb350658fe5587dec Mon Sep 17 00:00:00 2001 From: Tommy Verrall Date: Thu, 26 Oct 2023 12:25:31 +0200 Subject: [PATCH] =?UTF-8?q?i=20hope=20for=20no=20more=20comments=20hold=20?= =?UTF-8?q?my=20=F0=9F=8D=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- explorer-api/src/geo_ip/location.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/explorer-api/src/geo_ip/location.rs b/explorer-api/src/geo_ip/location.rs index 52f88069f3..a507056828 100644 --- a/explorer-api/src/geo_ip/location.rs +++ b/explorer-api/src/geo_ip/location.rs @@ -118,12 +118,12 @@ impl GeoIp { } pub fn query(&self, address: &str, port: Option) -> Result, GeoIpError> { - let ip: IpAddr = FromStr::from_str(address).or_else(|_| { + let p = port.unwrap_or(FAKE_PORT); + let ip_result: Result = FromStr::from_str(address).or_else(|_| { debug!( "Fail to create IpAddr from {}. Trying using internal lookup...", &address ); - let p = port.unwrap_or(FAKE_PORT); match (address, p).to_socket_addrs() { Ok(mut addrs) => { if let Some(socket_addr) = addrs.next() { @@ -142,7 +142,10 @@ impl GeoIp { Err(GeoIpError::NoValidIP) } } - })?; + }); + + let ip = ip_result?; + let result = self .db .as_ref()