This commit is contained in:
@@ -41,7 +41,7 @@ public class GeoCountryService {
|
|||||||
response.getCountry().getName();
|
response.getCountry().getName();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed for input: {}", input, e);
|
log.error("Failed for input: {}", input, e);
|
||||||
return "UNKNOWN";
|
return "unknow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,17 +54,17 @@ public class GeoCountryService {
|
|||||||
for (String ip : ipList) {
|
for (String ip : ipList) {
|
||||||
try {
|
try {
|
||||||
String country = getCountryByIp(ip, locale);
|
String country = getCountryByIp(ip, locale);
|
||||||
if (!"UNKNOWN".equals(country)) {
|
if (!"unknow".equals(country)) {
|
||||||
uniqueCountries.add(country);
|
uniqueCountries.add(country);
|
||||||
}
|
}
|
||||||
|
|
||||||
String countryCode = getCountryCodeByIp(ip);
|
String countryCode = getCountryCodeByIp(ip);
|
||||||
if (!"UNKNOWN".equals(countryCode)) {
|
if (!"unknow".equals(countryCode)) {
|
||||||
uniqueCountryCodes.add(countryCode);
|
uniqueCountryCodes.add(countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
String city = getCityByIp(ip, locale);
|
String city = getCityByIp(ip, locale);
|
||||||
if (!"UNKNOWN".equals(city)) {
|
if (!"unknow".equals(city)) {
|
||||||
uniqueCities.add(city);
|
uniqueCities.add(city);
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -88,7 +88,7 @@ public class GeoCountryService {
|
|||||||
response.getCountry().getIsoCode();
|
response.getCountry().getIsoCode();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed for input: {}", input, e);
|
log.error("Failed for input: {}", input, e);
|
||||||
return "UNKNOWN";
|
return "unknow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,12 +96,13 @@ public class GeoCountryService {
|
|||||||
try {
|
try {
|
||||||
InetAddress ipAddress = InetAddress.getByName(ip);
|
InetAddress ipAddress = InetAddress.getByName(ip);
|
||||||
CityResponse response = cityDbReader.city(ipAddress);
|
CityResponse response = cityDbReader.city(ipAddress);
|
||||||
|
String cityName = response.getCity().getNames().getOrDefault(locale,
|
||||||
return response.getCity().getNames().getOrDefault(locale,
|
|
||||||
response.getCity().getName());
|
response.getCity().getName());
|
||||||
|
|
||||||
|
return cityName == null ? "unknow": cityName;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to get city for IP: {}", ip, e);
|
log.error("Failed to get city for IP: {}", ip, e);
|
||||||
return "UNKNOWN";
|
return "unknow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,12 +110,13 @@ public class GeoCountryService {
|
|||||||
try {
|
try {
|
||||||
InetAddress ipAddress = InetAddress.getByName(ip);
|
InetAddress ipAddress = InetAddress.getByName(ip);
|
||||||
CountryResponse response = countryDbReader.country(ipAddress);
|
CountryResponse response = countryDbReader.country(ipAddress);
|
||||||
|
String countryName = response.getCountry().getNames().getOrDefault(locale,
|
||||||
return response.getCountry().getNames().getOrDefault(locale,
|
|
||||||
response.getCountry().getName());
|
response.getCountry().getName());
|
||||||
|
|
||||||
|
return countryName == null ? "unknow": countryName;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to get country for IP: {}", ip, e);
|
log.error("Failed to get country for IP: {}", ip, e);
|
||||||
return "UNKNOWN";
|
return "unknow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +128,7 @@ public class GeoCountryService {
|
|||||||
return response.getCountry().getIsoCode();
|
return response.getCountry().getIsoCode();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("Failed to get country code for IP: {}", ip, e);
|
log.error("Failed to get country code for IP: {}", ip, e);
|
||||||
return "UNKNOWN";
|
return "unknow";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user