Ignore country check for localhost.

- don't log exception to console
This commit is contained in:
DNx5 2016-02-18 09:15:43 +07:00
parent 64688c7ae6
commit fbdd56d9de

View File

@ -89,11 +89,11 @@ public class GeoLiteAPI {
* @return String * @return String
*/ */
public static String getCountryCode(String ip) { public static String getCountryCode(String ip) {
if (isDataAvailable()) { if (!"127.0.0.1".equals(ip) && isDataAvailable()) {
try { try {
return databaseReader.country(InetAddress.getByName(ip)).getCountry().getIsoCode(); return databaseReader.country(InetAddress.getByName(ip)).getCountry().getIsoCode();
} catch (Exception e) { } catch (Exception e) {
ConsoleLogger.logException("Error while getting country code", e); ConsoleLogger.writeStackTrace(e);
} }
} }
return "--"; return "--";
@ -107,11 +107,11 @@ public class GeoLiteAPI {
* @return String * @return String
*/ */
public static String getCountryName(String ip) { public static String getCountryName(String ip) {
if (isDataAvailable()) { if (!"127.0.0.1".equals(ip) && isDataAvailable()) {
try { try {
return databaseReader.country(InetAddress.getByName(ip)).getCountry().getName(); return databaseReader.country(InetAddress.getByName(ip)).getCountry().getName();
} catch (Exception e) { } catch (Exception e) {
ConsoleLogger.logException("Error while getting country name", e); ConsoleLogger.writeStackTrace(e);
} }
} }
return "N/A"; return "N/A";