@@ -33,7 +33,7 @@ import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||
import fr.xephi.authme.task.CleanupTask;
|
||||
import fr.xephi.authme.task.purge.PurgeService;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.geoip.GeoIpManager;
|
||||
import fr.xephi.authme.geoip.GeoLiteAPI;
|
||||
import fr.xephi.authme.service.MigrationService;
|
||||
import fr.xephi.authme.util.PlayerUtils;
|
||||
import org.bukkit.Server;
|
||||
@@ -74,7 +74,7 @@ public class AuthMe extends JavaPlugin {
|
||||
private DataSource database;
|
||||
private BukkitService bukkitService;
|
||||
private Injector injector;
|
||||
private GeoIpManager geoIpManager;
|
||||
private GeoLiteAPI geoLiteApi;
|
||||
private PlayerCache playerCache;
|
||||
|
||||
/**
|
||||
@@ -248,7 +248,7 @@ public class AuthMe extends JavaPlugin {
|
||||
permsMan = injector.getSingleton(PermissionsManager.class);
|
||||
bukkitService = injector.getSingleton(BukkitService.class);
|
||||
commandHandler = injector.getSingleton(CommandHandler.class);
|
||||
geoIpManager = injector.getSingleton(GeoIpManager.class);
|
||||
geoLiteApi = injector.getSingleton(GeoLiteAPI.class);
|
||||
|
||||
// Trigger construction of API classes; they will keep track of the singleton
|
||||
injector.getSingleton(NewAPI.class);
|
||||
@@ -374,7 +374,7 @@ public class AuthMe extends JavaPlugin {
|
||||
.replace("{SERVER}", server.getServerName())
|
||||
.replace("{VERSION}", server.getBukkitVersion())
|
||||
// TODO: We should cache info like this, maybe with a class that extends Player?
|
||||
.replace("{COUNTRY}", geoIpManager.getCountryName(ipAddress));
|
||||
.replace("{COUNTRY}", geoLiteApi.getCountryName(ipAddress));
|
||||
}
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ import java.net.URLConnection;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
public class GeoIpManager {
|
||||
public class GeoLiteAPI {
|
||||
private static final String LICENSE =
|
||||
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
|
||||
private static final String GEOIP_URL =
|
||||
@@ -28,14 +28,14 @@ public class GeoIpManager {
|
||||
private final File dataFile;
|
||||
|
||||
@Inject
|
||||
GeoIpManager(@DataFolder File dataFolder) {
|
||||
GeoLiteAPI(@DataFolder File dataFolder) {
|
||||
this.dataFile = new File(dataFolder, "GeoIP.dat");
|
||||
// Fires download of recent data or the initialization of the look up service
|
||||
isDataAvailable();
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
GeoIpManager(@DataFolder File dataFolder, LookupService lookupService) {
|
||||
GeoLiteAPI(@DataFolder File dataFolder, LookupService lookupService) {
|
||||
this.dataFile = dataFolder;
|
||||
this.lookupService = lookupService;
|
||||
}
|
||||
@@ -2,7 +2,7 @@ package fr.xephi.authme.service;
|
||||
|
||||
import com.github.authme.configme.properties.Property;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.geoip.GeoIpManager;
|
||||
import fr.xephi.authme.geoip.GeoLiteAPI;
|
||||
import fr.xephi.authme.initialization.Reloadable;
|
||||
import fr.xephi.authme.output.MessageKey;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
@@ -36,7 +36,7 @@ public class ValidationService implements Reloadable {
|
||||
@Inject
|
||||
private PermissionsManager permissionsManager;
|
||||
@Inject
|
||||
private GeoIpManager geoIpManager;
|
||||
private GeoLiteAPI geoLiteApi;
|
||||
|
||||
private Pattern passwordRegex;
|
||||
private Set<String> unrestrictedNames;
|
||||
@@ -115,7 +115,7 @@ public class ValidationService implements Reloadable {
|
||||
return true;
|
||||
}
|
||||
|
||||
String countryCode = geoIpManager.getCountryCode(hostAddress);
|
||||
String countryCode = geoLiteApi.getCountryCode(hostAddress);
|
||||
return validateWhitelistAndBlacklist(countryCode,
|
||||
ProtectionSettings.COUNTRIES_WHITELIST,
|
||||
ProtectionSettings.COUNTRIES_BLACKLIST);
|
||||
|
||||
Reference in New Issue
Block a user