Merge branch 'master' of github.com:GravitLauncher/Launcher

This commit is contained in:
zaxar163 2018-11-21 21:56:09 +03:00
commit 04149c9491
5 changed files with 14 additions and 7 deletions

View file

@ -93,6 +93,8 @@ public static final class Config extends ConfigObject {
public final int authRateLimitMilis; public final int authRateLimitMilis;
public final ListConfigEntry authLimitExclusions;
public final String authRejectString; public final String authRejectString;
public final String projectName; public final String projectName;
@ -122,6 +124,7 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) {
VerifyHelper.range(0, 1000000), "Illegal authRateLimit"); VerifyHelper.range(0, 1000000), "Illegal authRateLimit");
authRateLimitMilis = VerifyHelper.verifyInt(block.getEntryValue("authRateLimitMilis", IntegerConfigEntry.class), authRateLimitMilis = VerifyHelper.verifyInt(block.getEntryValue("authRateLimitMilis", IntegerConfigEntry.class),
VerifyHelper.range(10, 10000000), "Illegal authRateLimitMillis"); VerifyHelper.range(10, 10000000), "Illegal authRateLimitMillis");
authLimitExclusions = block.hasEntry("authLimitExclusions") ? block.getEntry("authLimitExclusions", ListConfigEntry.class) : null;
bindAddress = block.hasEntry("bindAddress") ? bindAddress = block.hasEntry("bindAddress") ?
block.getEntryValue("bindAddress", StringConfigEntry.class) : getAddress(); block.getEntryValue("bindAddress", StringConfigEntry.class) : getAddress();
authRejectString = block.hasEntry("authRejectString") ? authRejectString = block.hasEntry("authRejectString") ?
@ -129,7 +132,6 @@ private Config(BlockConfigEntry block, Path coredir, LaunchServer server) {
whitelistRejectString = block.hasEntry("whitelistRejectString") ? whitelistRejectString = block.hasEntry("whitelistRejectString") ?
block.getEntryValue("whitelistRejectString", StringConfigEntry.class) : "Вас нет в белом списке"; block.getEntryValue("whitelistRejectString", StringConfigEntry.class) : "Вас нет в белом списке";
// Set handlers & providers // Set handlers & providers
authHandler = new AuthHandler[1]; authHandler = new AuthHandler[1];
authHandler[0] = AuthHandler.newHandler(block.getEntryValue("authHandler", StringConfigEntry.class), authHandler[0] = AuthHandler.newHandler(block.getEntryValue("authHandler", StringConfigEntry.class),

View file

@ -1,8 +1,11 @@
package ru.gravit.launchserver.auth; package ru.gravit.launchserver.auth;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import ru.gravit.launcher.NeedGarbageCollection; import ru.gravit.launcher.NeedGarbageCollection;
import ru.gravit.launcher.serialize.config.entry.StringConfigEntry;
import ru.gravit.launchserver.LaunchServer; import ru.gravit.launchserver.LaunchServer;
public class AuthLimiter implements NeedGarbageCollection { public class AuthLimiter implements NeedGarbageCollection {
@ -50,10 +53,13 @@ public String toString() {
public final int rateLimit; public final int rateLimit;
public final int rateLimitMilis; public final int rateLimitMilis;
private HashMap<String, AuthEntry> map; private final HashMap<String, AuthEntry> map;
private final List<String> excludeIps;
public AuthLimiter(LaunchServer srv) { public AuthLimiter(LaunchServer srv) {
map = new HashMap<>(); map = new HashMap<>();
excludeIps = new ArrayList<>();
if (srv.config.authLimitExclusions != null) srv.config.authLimitExclusions.stream(StringConfigEntry.class).forEach(excludeIps::add);
rateLimit = srv.config.authRateLimit; rateLimit = srv.config.authRateLimit;
rateLimitMilis = srv.config.authRateLimitMilis; rateLimitMilis = srv.config.authRateLimitMilis;
} }
@ -66,6 +72,7 @@ public void garbageCollection() {
} }
public boolean isLimit(String ip) { public boolean isLimit(String ip) {
if (excludeIps.contains(ip)) return false;
if (map.containsKey(ip)) { if (map.containsKey(ip)) {
AuthEntry rate = map.get(ip); AuthEntry rate = map.get(ip);
long currenttime = System.currentTimeMillis(); long currenttime = System.currentTimeMillis();

View file

@ -54,10 +54,8 @@ protected AuthHandler(BlockConfigEntry block) {
super(block); super(block);
} }
public abstract UUID auth(AuthProviderResult authResult) throws IOException; public abstract UUID auth(AuthProviderResult authResult) throws IOException;
public abstract UUID checkServer(String username, String serverID) throws IOException; public abstract UUID checkServer(String username, String serverID) throws IOException;
@Override @Override

View file

@ -293,7 +293,8 @@ function updateProfilesList(profiles) {
index++; index++;
}); });
LogHelper.debug("Load selected %d profile",settings.profile); LogHelper.debug("Load selected %d profile",settings.profile);
serverHolder.set(serverList.getChildren().get(settings.profile)); if(profiles.length > 0)
serverHolder.set(serverList.getChildren().get(settings.profile));
} }
function pingServer(btn) { function pingServer(btn) {
@ -422,4 +423,4 @@ launcher.loadScript("dialog/overlay/debug/debug.js");
launcher.loadScript("dialog/overlay/processing/processing.js"); launcher.loadScript("dialog/overlay/processing/processing.js");
launcher.loadScript("dialog/overlay/settings/settings.js"); launcher.loadScript("dialog/overlay/settings/settings.js");
launcher.loadScript("dialog/overlay/options/options.js"); launcher.loadScript("dialog/overlay/options/options.js");
launcher.loadScript("dialog/overlay/update/update.js"); launcher.loadScript("dialog/overlay/update/update.js");

View file

@ -11,7 +11,6 @@
import javafx.scene.shape.Arc; import javafx.scene.shape.Arc;
import javafx.scene.shape.Circle; import javafx.scene.shape.Circle;
import javafx.util.Duration; 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. * Skin of the ring progress indicator where an arc grows and by the progress value up to 100% where the arc becomes a ring.