forked from MinecraftUtilities/Backend
don't return maxmind data if it failed to load
This commit is contained in:
parent
2ad5556041
commit
67efda71d2
@ -191,6 +191,9 @@ public class MinecraftServer {
|
|||||||
* @return the location of the server
|
* @return the location of the server
|
||||||
*/
|
*/
|
||||||
public static GeoLocation fromMaxMind(CityResponse response) {
|
public static GeoLocation fromMaxMind(CityResponse response) {
|
||||||
|
if (response == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return new GeoLocation(
|
return new GeoLocation(
|
||||||
response.getCountry().getName(),
|
response.getCountry().getName(),
|
||||||
response.getMostSpecificSubdivision().getName(),
|
response.getMostSpecificSubdivision().getName(),
|
||||||
|
@ -40,8 +40,8 @@ public class MaxMindService {
|
|||||||
public MaxMindService(@Value("${maxmind.license}") String maxMindLicense) {
|
public MaxMindService(@Value("${maxmind.license}") String maxMindLicense) {
|
||||||
this.maxMindLicense = maxMindLicense;
|
this.maxMindLicense = maxMindLicense;
|
||||||
if (maxMindLicense.isBlank()) {
|
if (maxMindLicense.isBlank()) {
|
||||||
log.error("The MaxMind license key is not set, please set it in the configuration and try again");
|
log.error("The MaxMind license key is not set, please set it in the configuration and try again, disabling the MaxMind service...");
|
||||||
System.exit(1);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
File databaseFile = loadDatabase();
|
File databaseFile = loadDatabase();
|
||||||
@ -61,6 +61,9 @@ public class MaxMindService {
|
|||||||
* @return The GeoIP information
|
* @return The GeoIP information
|
||||||
*/
|
*/
|
||||||
public static CityResponse lookup(String query) {
|
public static CityResponse lookup(String query) {
|
||||||
|
if (database == null) { // The database isn't loaded, return null
|
||||||
|
return null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return database.city(InetAddress.getByName(query));
|
return database.city(InetAddress.getByName(query));
|
||||||
} catch (IOException | GeoIp2Exception e) {
|
} catch (IOException | GeoIp2Exception e) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user