mirror of
https://codeberg.org/slatian/service.echoip-slatecave.git
synced 2025-07-16 22:13:30 +02:00
Made querying with paths possible (for wasier commandline usage)
This commit is contained in:
16
src/geoip.rs
16
src/geoip.rs
@ -50,7 +50,7 @@ pub struct MMDBCarrier {
|
||||
}
|
||||
|
||||
pub trait QueryLocation {
|
||||
fn query_location_for_ip(&self, address: IpAddr, laguages: &Vec<String>) -> Option<LocationResult>;
|
||||
fn query_location_for_ip(&self, address: IpAddr, laguages: &Vec<&String>) -> Option<LocationResult>;
|
||||
}
|
||||
|
||||
pub trait QueryAsn {
|
||||
@ -61,7 +61,7 @@ pub trait QueryAsn {
|
||||
|
||||
pub fn extract_localized_name(
|
||||
names: &Option<BTreeMap<&str, &str>>,
|
||||
languages: &Vec<String>)
|
||||
languages: &Vec<&String>)
|
||||
-> Option<String> {
|
||||
match names {
|
||||
Some(names) => {
|
||||
@ -76,7 +76,7 @@ names: &Option<BTreeMap<&str, &str>>,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geoip2_city_to_named_location(item: geoip2::model::City, languages: &Vec<String>) -> NamedLocation {
|
||||
pub fn geoip2_city_to_named_location(item: geoip2::model::City, languages: &Vec<&String>) -> NamedLocation {
|
||||
NamedLocation {
|
||||
iso_code: None,
|
||||
geoname_id: item.geoname_id,
|
||||
@ -84,7 +84,7 @@ pub fn geoip2_city_to_named_location(item: geoip2::model::City, languages: &Vec<
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geoip2_continent_to_named_location(item: geoip2::model::Continent, languages: &Vec<String>) -> NamedLocation {
|
||||
pub fn geoip2_continent_to_named_location(item: geoip2::model::Continent, languages: &Vec<&String>) -> NamedLocation {
|
||||
NamedLocation {
|
||||
iso_code: item.code.map(ToString::to_string),
|
||||
geoname_id: item.geoname_id,
|
||||
@ -92,7 +92,7 @@ pub fn geoip2_continent_to_named_location(item: geoip2::model::Continent, langua
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geoip2_country_to_named_location(item: geoip2::model::Country, languages: &Vec<String>) -> NamedLocation {
|
||||
pub fn geoip2_country_to_named_location(item: geoip2::model::Country, languages: &Vec<&String>) -> NamedLocation {
|
||||
NamedLocation {
|
||||
iso_code: item.iso_code.map(ToString::to_string),
|
||||
geoname_id: item.geoname_id,
|
||||
@ -100,7 +100,7 @@ pub fn geoip2_country_to_named_location(item: geoip2::model::Country, languages:
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geoip2_represented_country_to_named_location(item: geoip2::model::RepresentedCountry, languages: &Vec<String>) -> NamedLocation {
|
||||
pub fn geoip2_represented_country_to_named_location(item: geoip2::model::RepresentedCountry, languages: &Vec<&String>) -> NamedLocation {
|
||||
NamedLocation {
|
||||
iso_code: item.iso_code.map(ToString::to_string),
|
||||
geoname_id: item.geoname_id,
|
||||
@ -108,7 +108,7 @@ pub fn geoip2_represented_country_to_named_location(item: geoip2::model::Represe
|
||||
}
|
||||
}
|
||||
|
||||
pub fn geoip2_subdivision_to_named_location(item: geoip2::model::Subdivision, languages: &Vec<String>) -> NamedLocation {
|
||||
pub fn geoip2_subdivision_to_named_location(item: geoip2::model::Subdivision, languages: &Vec<&String>) -> NamedLocation {
|
||||
NamedLocation {
|
||||
iso_code: item.iso_code.map(ToString::to_string),
|
||||
geoname_id: item.geoname_id,
|
||||
@ -141,7 +141,7 @@ impl QueryAsn for MMDBCarrier {
|
||||
}
|
||||
|
||||
impl QueryLocation for MMDBCarrier {
|
||||
fn query_location_for_ip(&self, address: IpAddr, languages: &Vec<String>) -> Option<LocationResult> {
|
||||
fn query_location_for_ip(&self, address: IpAddr, languages: &Vec<&String>) -> Option<LocationResult> {
|
||||
match &self.mmdb {
|
||||
Some(mmdb) => {
|
||||
match mmdb.lookup::<geoip2::City>(address) {
|
||||
|
Reference in New Issue
Block a user