diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index ac995a57..a696c718 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -93,6 +93,8 @@ public static final class Config extends ConfigObject { public final int authRateLimitMilis; + public final ListConfigEntry authLimitExclusions; + public final String authRejectString; public final String projectName; @@ -122,6 +124,7 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) { VerifyHelper.range(0, 1000000), "Illegal authRateLimit"); authRateLimitMilis = VerifyHelper.verifyInt(block.getEntryValue("authRateLimitMilis", IntegerConfigEntry.class), VerifyHelper.range(10, 10000000), "Illegal authRateLimitMillis"); + authLimitExclusions = block.hasEntry("authLimitExclusions") ? block.getEntry("authLimitExclusions", ListConfigEntry.class) : null; bindAddress = block.hasEntry("bindAddress") ? block.getEntryValue("bindAddress", StringConfigEntry.class) : getAddress(); authRejectString = block.hasEntry("authRejectString") ? @@ -129,7 +132,6 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) { whitelistRejectString = block.hasEntry("whitelistRejectString") ? block.getEntryValue("whitelistRejectString", StringConfigEntry.class) : "Вас нет в белом списке"; - // Set handlers & providers authHandler = new AuthHandler[1]; authHandler[0] = AuthHandler.newHandler(block.getEntryValue("authHandler", StringConfigEntry.class), diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java index a66bbff3..faef83be 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/AuthLimiter.java @@ -1,8 +1,11 @@ package ru.gravit.launchserver.auth; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import ru.gravit.launcher.NeedGarbageCollection; +import ru.gravit.launcher.serialize.config.entry.StringConfigEntry; import ru.gravit.launchserver.LaunchServer; public class AuthLimiter implements NeedGarbageCollection { @@ -50,10 +53,13 @@ public String toString() { public final int rateLimit; public final int rateLimitMilis; - private HashMap map; + private final HashMap map; + private final List excludeIps; public AuthLimiter(LaunchServer srv) { map = new HashMap<>(); + excludeIps = new ArrayList<>(); + if (srv.config.authLimitExclusions != null) srv.config.authLimitExclusions.stream(StringConfigEntry.class).forEach(excludeIps::add); rateLimit = srv.config.authRateLimit; rateLimitMilis = srv.config.authRateLimitMilis; } @@ -66,6 +72,7 @@ public void garbageCollection() { } public boolean isLimit(String ip) { + if (excludeIps.contains(ip)) return false; if (map.containsKey(ip)) { AuthEntry rate = map.get(ip); long currenttime = System.currentTimeMillis(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java index 41e7bd8f..1f0aae81 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/auth/handler/AuthHandler.java @@ -54,10 +54,8 @@ protected AuthHandler(BlockConfigEntry block) { super(block); } - public abstract UUID auth(AuthProviderResult authResult) throws IOException; - public abstract UUID checkServer(String username, String serverID) throws IOException; @Override diff --git a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java index ffa3f07d..e73f55d2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java +++ b/Launcher/src/main/java/ru/gravit/launcher/gui/indicator/RingProgressIndicatorSkin.java @@ -11,7 +11,6 @@ import javafx.scene.shape.Arc; import javafx.scene.shape.Circle; import javafx.util.Duration; -import ru.gravit.launcher.LauncherAPI; /** * Skin of the ring progress indicator where an arc grows and by the progress value up to 100% where the arc becomes a ring.