Join process cleanup, change some default settings (should improve performance and security with default settings)

This commit is contained in:
Gabriele C 2016-11-15 18:41:27 +01:00
parent 15ff9ae442
commit b53f71706a
8 changed files with 13 additions and 42 deletions

View File

@ -208,9 +208,11 @@ public class PlayerListener implements Listener {
final String name = player.getName();
if (validationService.isUnrestricted(name)) {
return;
} else if (onJoinVerifier.refusePlayerForFullServer(event)) {
}
if (onJoinVerifier.refusePlayerForFullServer(event)) {
return;
} else if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
}
if (event.getResult() != PlayerLoginEvent.Result.ALLOWED) {
return;
}
@ -223,8 +225,8 @@ public class PlayerListener implements Listener {
// Slow stuff
final PlayerAuth auth = dataSource.getAuth(name);
final boolean isAuthAvailable = (auth != null);
onJoinVerifier.checkAntibot(player, isAuthAvailable);
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
onJoinVerifier.checkAntibot(player, isAuthAvailable);
onJoinVerifier.checkNameCasing(player, auth);
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
} catch (FailedVerificationException e) {

View File

@ -22,9 +22,7 @@ import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.GameMode;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -39,9 +37,6 @@ import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
*/
public class AsynchronousJoin implements AsynchronousProcess {
private static final boolean DISABLE_COLLISIONS = MethodUtils
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
@Inject
private AuthMe plugin;
@ -75,20 +70,14 @@ public class AsynchronousJoin implements AsynchronousProcess {
AsynchronousJoin() {
}
public void processJoin(final Player player) {
final String name = player.getName().toLowerCase();
final String ip = PlayerUtils.getPlayerIp(player);
if (isPlayerUnrestricted(name)) {
if (service.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name)) {
return;
}
// Prevent player collisions in 1.9
if (DISABLE_COLLISIONS) {
player.setCollidable(false);
}
if (service.getProperty(RestrictionSettings.FORCE_SURVIVAL_MODE)
&& !service.hasPermission(player, PlayerStatePermission.BYPASS_FORCE_SURVIVAL)) {
bukkitService.runTask(() -> player.setGameMode(GameMode.SURVIVAL));
@ -115,7 +104,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
return;
}
final boolean isAuthAvailable = database.isAuthAvailable(name);
if (isAuthAvailable) {
@ -189,10 +177,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
}
private boolean isPlayerUnrestricted(String name) {
return service.getProperty(RestrictionSettings.UNRESTRICTED_NAMES).contains(name);
}
/**
* Returns whether the name is restricted based on the restriction settings.
*

View File

@ -14,23 +14,17 @@ import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginManager;
import org.bukkit.potion.PotionEffectType;
import javax.inject.Inject;
import static fr.xephi.authme.settings.properties.PluginSettings.KEEP_COLLISIONS_DISABLED;
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
public class ProcessSyncPlayerLogin implements SynchronousProcess {
private static final boolean RESTORE_COLLISIONS = MethodUtils
.getAccessibleMethod(LivingEntity.class, "setCollidable", new Class[]{}) != null;
@Inject
private AuthMe plugin;
@ -88,10 +82,6 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
// because LimboCache#restoreData teleport player to last location.
}
if (RESTORE_COLLISIONS && !service.getProperty(KEEP_COLLISIONS_DISABLED)) {
player.setCollidable(true);
}
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
restoreInventory(player);
}

View File

@ -17,6 +17,8 @@ import java.net.URLConnection;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
import static com.maxmind.geoip.LookupService.GEOIP_MEMORY_CACHE;
public class GeoIpService {
private static final String LICENSE =
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
@ -57,7 +59,7 @@ public class GeoIpService {
boolean dataIsOld = (System.currentTimeMillis() - dataFile.lastModified()) > TimeUnit.DAYS.toMillis(30);
if (!dataIsOld) {
try {
lookupService = new LookupService(dataFile);
lookupService = new LookupService(dataFile, GEOIP_MEMORY_CACHE);
ConsoleLogger.info(LICENSE);
return true;
} catch (IOException e) {

View File

@ -25,7 +25,7 @@ public class HooksSettings implements SettingsHolder {
@Comment("Do we need to disable Essentials SocialSpy on join?")
public static final Property<Boolean> DISABLE_SOCIAL_SPY =
newProperty("Hooks.disableSocialSpy", true);
newProperty("Hooks.disableSocialSpy", false);
@Comment("Do we need to force /motd Essentials command on join?")
public static final Property<Boolean> USE_ESSENTIALS_MOTD =

View File

@ -52,13 +52,6 @@ public class PluginSettings implements SettingsHolder {
public static final Property<Boolean> ENABLE_PERMISSION_CHECK =
newProperty("permission.EnablePermissionCheck", false);
@Comment({
"Keeps collisions disabled for logged players",
"Works only with MC 1.9"
})
public static final Property<Boolean> KEEP_COLLISIONS_DISABLED =
newProperty("settings.restrictions.keepCollisionsDisabled", false);
@Comment({
"Log level: INFO, FINE, DEBUG. Use INFO for general messages,",
"FINE for some additional detailed ones (like password failed),",

View File

@ -108,7 +108,7 @@ public class RegistrationSettings implements SettingsHolder {
"Do we need to prevent people to login with another case?",
"If Xephi is registered, then Xephi can login, but not XEPHI/xephi/XePhI"})
public static final Property<Boolean> PREVENT_OTHER_CASE =
newProperty("settings.preventOtherCase", false);
newProperty("settings.preventOtherCase", true);
private RegistrationSettings() {

View File

@ -90,7 +90,7 @@ public class RestrictionSettings implements SettingsHolder {
@Comment("Should players be kicked on wrong password?")
public static final Property<Boolean> KICK_ON_WRONG_PASSWORD =
newProperty("settings.restrictions.kickOnWrongPassword", false);
newProperty("settings.restrictions.kickOnWrongPassword", true);
@Comment({
"Should not logged in players be teleported to the spawn?",
@ -139,7 +139,7 @@ public class RestrictionSettings implements SettingsHolder {
@Comment("Should we deny the tabcomplete feature before logging in? Requires ProtocolLib.")
public static final Property<Boolean> DENY_TABCOMPLETE_BEFORE_LOGIN =
newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", true);
newProperty("settings.restrictions.DenyTabCompleteBeforeLogin", false);
@Comment({
"Should we display all other accounts from a player when he joins?",